pythonalpha-vantage

Alpha vantage AAPL prices do not align with other data sources


I'm using the following code to download and plot AAPL daily stock prices:

from alpha_vantage.timeseries import TimeSeries
import matplotlib.pyplot as plt

ts = TimeSeries(key='YOUR_API_KEY', output_format='pandas')

data, meta_data = ts.get_daily(symbol='AAPL', outputsize='full')
plt.figure(figsize=(10,6))

data['3. low'].plot()
plt.grid(linestyle='-', linewidth=2)
plt.title('AAPL stock price daily')
plt.savefig('sample.png')
plt.show()

This is the plot that I am getting: enter image description here

Obviously, this price drop in 2015 doesn't look right. Also AAPL has never been that expensive. Moreover, this data contradicts with other stock prices sources, e.g. Google.

Am I misusing the API? Is this a bug?


Solution

  • As @Pedro Lobito noted, the data should be adjusted with stocks split times. So, after using get_daily_adjusted function and plotting '5. adjusted close' values, the result is as expected: enter image description here

    Code:

    from alpha_vantage.timeseries import TimeSeries
    import matplotlib.pyplot as plt
    ts = TimeSeries(key='YOUR_API_KEY', output_format='pandas')
    
    data, meta_data = ts.get_daily_adjusted(symbol='AAPL', outputsize='full')
    plt.figure(figsize=(10,6))
    
    data['5. adjusted close'].plot()
    
    plt.grid(linestyle='-', linewidth=2)
    plt.title('AAPL stock price daily')
    plt.savefig('sample.png')
    plt.show()