You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have observed that when using start date parameter with yf.download() session does not work. But it does work when period param is used instead.Also It works when end param is also used. The cache is being written on running the function. However, if I run the function for same tickers again ideally it should fetch from cache and the cache should not be written again. but the data is fetched from network and cache is written again with newly fetched data.
when writing debug log I realized I can debug with yf.enable_debug_mode().(I'm a rookie) and I think I have found the issue its because when the request it made it uses current time in unix seconds which changes the url every time thus preventing caching. Entering _make_request() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/ABB.NS DEBUG params={'period1': 1546281000, 'period2': 1732735151, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
Is this expected behaviour? or does this needs to be fixed?
Describe bug
I have observed that when using start date parameter with yf.download() session does not work. But it does work when period param is used instead.Also It works when end param is also used. The cache is being written on running the function. However, if I run the function for same tickers again ideally it should fetch from cache and the cache should not be written again. but the data is fetched from network and cache is written again with newly fetched data.
when writing debug log I realized I can debug with yf.enable_debug_mode().(I'm a rookie) and I think I have found the issue its because when the request it made it uses current time in unix seconds which changes the url every time thus preventing caching.
Entering _make_request() DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/ABB.NS DEBUG params={'period1': 1546281000, 'period2': 1732735151, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
Is this expected behaviour? or does this needs to be fixed?
Simple code that reproduces your problem
import requests_cache
import yfinance as yf
tickers = [
"ACC.ns",
"ABB.ns",
"AUBANK.ns",
"BAJFINANCE.NS",
"BALKRISIND.NS",
"APLLTD.NS",
"APOLLOHOSP.NS",
"APOLLOTYRE.NS",
"APTUS.NS",
"ASHOKLEY.NS",
]
session = requests_cache.CachedSession("stocstats.cache")
//fine. fetches from cache.
data = yf.download(tickers=tickers, period="1y", session=session)
//doesn't use cache
data = yf.download(tickers=tickers, start="2019-1-1", session=session)
print(data.head())
Debug log
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Entering history()
DEBUG Entering history()
DEBUG APOLLOHOSP.NS: Yahoo GET parameters: {'period1': '2019-01-01 00:00:00+05:30', 'period2': '2024-11-28 00:46:34+05:30', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/APOLLOHOSP.NS
DEBUG params={'period1': 1546281000, 'period2': 1732734994, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG APOLLOHOSP.NS: yfinance received OHLC data: 2019-01-01 03:45:00 -> 2024-11-27 09:59:56
DEBUG APOLLOHOSP.NS: OHLC after cleaning: 2019-01-01 09:15:00+05:30 -> 2024-11-27 15:29:56+05:30
DEBUG APOLLOHOSP.NS: OHLC after combining events: 2019-01-01 00:00:00+05:30 -> 2024-11-27 00:00:00+05:30
DEBUG APOLLOHOSP.NS: yfinance returning OHLC: 2019-01-01 00:00:00+05:30 -> 2024-11-27 00:00:00+05:30
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Entering history()
DEBUG Entering history()
DEBUG APLLTD.NS: Yahoo GET parameters: {'period1': '2019-01-01 00:00:00+05:30', 'period2': '2024-11-28 00:46:34+05:30', 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering get()
DEBUG Entering _make_request()
DEBUG url=https://query2.finance.yahoo.com/v8/finance/chart/APLLTD.NS
DEBUG params={'period1': 1546281000, 'period2': 1732734994, 'interval': '1d', 'includePrePost': False, 'events': 'div,splits,capitalGains'}
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
DEBUG Exiting _get_cookie_and_crumb_basic()
DEBUG Exiting _get_cookie_and_crumb()
DEBUG response code=200
DEBUG Exiting _make_request()
DEBUG Exiting get()
DEBUG APLLTD.NS: yfinance received OHLC data: 2019-01-01 03:45:00 -> 2024-11-27 09:59:58
DEBUG APLLTD.NS: OHLC after cleaning: 2019-01-01 09:15:00+05:30 -> 2024-11-27 15:29:58+05:30
DEBUG APLLTD.NS: OHLC after combining events: 2019-01-01 00:00:00+05:30 -> 2024-11-27 00:00:00+05:30
DEBUG APLLTD.NS: yfinance returning OHLC: 2019-01-01 00:00:00+05:30 -> 2024-11-27 00:00:00+05:30
DEBUG Exiting history()
DEBUG Exiting history()
DEBUG Exiting download()
Bad data proof
No response
yfinance
version0.2.50
Python version
3.10.12
Operating system
Ubuntu 22.04 LTS
The text was updated successfully, but these errors were encountered: