user16836078
user16836078

Reputation:

Different price between yf.download and yf.Ticker

I am extracting the opening price of a stock, say "AAPL"(Apple Inc) using yfinance. I come across something very interesting, yet confusing details. I have used two methods to obtain the opening price of the stock, yf.Ticker and yf.download.

apple1 = yf.Ticker("AAPL")
apple2 = yf.download("AAPL")

As you can see in the dataframe below, the opening price for both methods shows totally different prices. Any idea what's happening here?

hist = apple1.history(period="max")
hist["Open"][:100]
Out[97]: 
Date
1980-12-12    0.100323
1980-12-15    0.095525
1980-12-16    0.088546
1980-12-17    0.090291
1980-12-18    0.092908
  
1981-04-30    0.099015
1981-05-01    0.099015
1981-05-04    0.099015
1981-05-05    0.098578
1981-05-06    0.095962
Name: Open, Length: 100, dtype: float64
apple2["Open"][:100]
Out[98]: 
Date
1980-12-12    0.128348
1980-12-15    0.122210
1980-12-16    0.113281
1980-12-17    0.115513
1980-12-18    0.118862
  
1981-04-30    0.126674
1981-05-01    0.126674
1981-05-04    0.126674
1981-05-05    0.126116
1981-05-06    0.122768
Name: Open, Length: 100, dtype: float64

Upvotes: 1

Views: 3240

Answers (1)

KarelZe
KarelZe

Reputation: 1703

history() allows you to set the auto_adjust=False parameter, which deactivates adjustments on OHLC (Open/High/Low/Close prices). By default, adjustments are enabled.

For download() adjustments are disabled by default.

If disabled for history(), both variants lead to the same result:

hist = apple1.history(period="max", auto_adjust=False)
hist["Open"][:100]

apple2 = yf.download("AAPL")
apple2["Open"][:100]

Equally, auto_adjust can also be enabled for download(). Which then yields the same (adjusted) results.

hist = apple1.history(period="max")
hist["Open"][:100]
apple2 = yf.download("AAPL", auto_adjust=True)
apple2["Open"][:100]

Upvotes: 3

Related Questions