yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Discrepancy Between yf.download & yf.Ticker().history()

Open keg5038 opened this issue 3 years ago • 3 comments

I am looking at Wheat Futures data (ticker=ZWZ22.CBT) & getting a discrepancy when running the following:

yf.Ticker("ZWZ22.CBT").history(interval="1d",period="10d").tail(30)

Returns data including today's trading day 2022-07-18.

Comparing this to: yf.download('ZWZ22.CBT') Which doesn't include 2022-07-18. The last day is 2022-07-15.

Why is there this discrepancy?

keg5038 avatar Jul 18 '22 20:07 keg5038

yfinance doesn't handle timezones well, so often returned data is off by one day. Except when period is specified, then Yahoo handles the timezones.

I have a branch that should fix this but needs volunteers to test before I merge. See https://github.com/ranaroussi/yfinance/issues/954#issuecomment-1182558587

ValueRaider avatar Jul 18 '22 21:07 ValueRaider

Thank you @ValueRaider for your quick response! I did a bit more testing & it looks like something to do with the start being specified as well:

yf.download("ZWZ22.CBT ZWU22.CBT", interval="1d",period='10d') This shows correctly, including 2022-07-19 data

The same command with 'start' included: yf.download("ZWZ22.CBT ZWU22.CBT",start='2022-07-01', interval="1d",period='10d') Information is the same as above, but does not include 2022-07-19 data.

I am not much of a programmer & have never contributed to open source but would be willing to try to help test if that would be helpful. Any suggestions on how to help?

keg5038 avatar Jul 19 '22 12:07 keg5038

Click the link. Then just use it, provide feedback.

ValueRaider avatar Jul 19 '22 20:07 ValueRaider

This should be solved in recent releases.

ValueRaider avatar Oct 27 '22 21:10 ValueRaider