To retrieve data from Alpha Vantage :
from alpha_vantage.timeseries
import TimeSeries
import matplotlib.pyplot as plt
import sys
def stockchart(symbol):
ts = TimeSeries(key='1ORS1XLM1YK1GK9Y', output_format='pandas')
data, meta_data = ts.get_intraday(symbol=symbol, interval='1min', outputsize='full')
print (data)
data['close'].plot()
plt.title('Stock chart')
plt.show()
symbol=input("Enter symbol name:") stockchart(symbol)
My question is if there is a way to specify start and end dates for the data. On the website they have mentioned on the limits to number data points but they have not mentioned if start and end dates could be used in the code and still not exceed the number of data points.
One API call to Alpha Vantage counts as just one API call. There are no limits to the number of data points from an API call.
To change the date range in python, run something like the following:
data_date_changed = data[:'2019-11-29']
This will give you everything from 2019-11-29 to the present time. The full code being:
from alpha_vantage.timeseries import TimeSeries
import matplotlib.pyplot as plt
import sys
def stockchart(symbol):
ts = TimeSeries(key='ABCDEFG', output_format='pandas')
data, meta_data = ts.get_intraday(symbol=symbol, interval='1min', outputsize='full')
data_date_changed = data[:'2019-11-29']
data_date_changed['4. close'].plot()
print(data_date_changed)
plt.title('Stock chart')
plt.show()
symbol=input("Enter symbol name:")
stockchart(symbol)