ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.96k stars 2.45k forks source link

Inconsistent floating point values in history method #1871

Open melgazar9 opened 9 months ago

melgazar9 commented 9 months ago

Describe bug

Not sure if this is an issue with yahoo-finance in general, the yfinance package here, or potentially even pandas. Floating point numbers 3+ decimals out are consistently returned differently on different time intervals and tickers.

Simple code that reproduces your problem

I tried this both with and without caching and on mac and ubuntu. It is more inconsistent on mac but also happens on ubuntu. Here's a reproducible example:

import yfinance as yf

t = yf.Ticker('AAPL')
for i in range(20):
    t.history(start='2020-01-02', interval='1d')

Debug log

N/A

Bad data proof

Screenshot 2024-02-26 at 6 58 40 PM Screenshot 2024-02-26 at 6 48 20 PM

yfinance version

0.2.37

Python version

3.10.12

Operating system

Mac M1 Chip and Ubuntu 22.04 LTS