0% found this document useful (0 votes)
27 views1 page

Code

The document provides a Python code snippet that uses the yfinance library to download stock data for ONGC.NS over a 5-day period with an hourly interval. It includes various optional parameters for data adjustment, market hours, and threading. The final output is a printed dictionary containing the downloaded data.

Uploaded by

Manikandan M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views1 page

Code

The document provides a Python code snippet that uses the yfinance library to download stock data for ONGC.NS over a 5-day period with an hourly interval. It includes various optional parameters for data adjustment, market hours, and threading. The final output is a printed dictionary containing the downloaded data.

Uploaded by

Manikandan M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import yfinance as yf

data = yf.download( # or pdr.get_data_yahoo(...


# tickers list or string as well
tickers = "ONGC.NS",

# use "period" instead of start/end


# valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
# (optional, default is '1mo')
period = "5d",

# fetch data by interval (including intraday if period < 60 days)


# valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
# (optional, default is '1d')
interval = "1h",

# group by ticker (to access via data['SPY'])


# (optional, default is 'column')
group_by = 'ticker',

# adjust all OHLC automatically


# (optional, default is False)
auto_adjust = True,

# download pre/post regular market hours data


# (optional, default is False)
prepost = True,

# use threads for mass downloading? (True/False/Integer)


# (optional, default is True)
threads = True,

# proxy URL scheme use use when downloading?


# (optional, default is None)
proxy = None
)

# whole python dictionary is printed here


print(data)

You might also like