pythonyfinance

Yfinance history returns different result each time


I use Yfinance to download historical prices and have found that the function returns different result each time. Is it an error or am I doing something wrong?

import yfinance as yf
msft = yf.Ticker('AAK.ST')
data_1 = msft.history(period="max")
data_2 = msft.history(period="max")

The result differs every time I run the code and below is an example where the first two rows differs but the third is equal.

enter image description here

There are a lot of rows that differs:

enter image description here

Any suggestions why, and how to handle this?


Solution

  • The differences that you are seeing are small and might be rounding errors. The result that you get with the history method are adjusted (which may cause these rounding errors). When I turn off the adjustment the results seem to be consistently the same:

    import yfinance as yf
    aak = yf.Ticker('AAK.ST')
    data_1 = aak.history(period="max", auto_adjust=False)
    data_2 = aak.history(period="max", auto_adjust=False)
    
    data_1.iloc[:3, :]
    data_2.iloc[:3, :]