Search code examples
pythonfinanceyahoo-financeyfinance

Python yFInance api how to get close share price instead of adjusted close share price?


I am trying to get closing share price from yFinance API for Devon DVN. The problem is that the API gives adjusted closing share price as closing share price in the response data which can sometimes be different.

As seen in yahoo finance, DVN closing share price for 9th Sept 2021 was 28.45, and adjusted closing share price was 27.96

enter image description here

In API response from yFinance I get the closing share price as 27.96 which should be the adjusted value, not the closing value.

enter image description here

Now how do I get the closing share price from yFinance instead of adjusted share price?


Solution

  • Using the download function of Yahoo Finance, you can get both the closing price and the adjusted closing price.

    import yfinance as yf
    data = yf.download("DVN", start='2021-09-01', end='2021-09-11')
    
    data
        Open    High    Low     Close   Adj Close   Volume
    Date                        
    2021-08-31  29.660000   30.320000   29.420000   29.549999   29.041054   11534800
    2021-09-01  29.400000   29.590000   27.670000   28.240000   27.753616   20559000
    2021-09-02  28.600000   29.969999   28.600000   29.320000   28.815016   11711300
    2021-09-03  29.209999   29.799999   29.000000   29.170000   28.667601   7305300
    2021-09-07  28.900000   29.330000   28.730000   29.059999   28.559494   5939700
    2021-09-08  29.250000   29.620001   28.030001   28.230000   27.743790   8874000
    2021-09-09  28.010000   29.080000   27.730000   28.450001   27.960001   9205700
    2021-09-10  28.700001   29.030001   28.020000   28.070000   28.070000   6581800