I'm fairly new to python and I promise I looked around for a while before I came here but I'm trying to make a stock reader in which someone can just type in whichever stock they want and it shows the data for it. So far everything is going well but I am having trouble with the user input, here is my code:
from alpha_vantage.timeseries import TimeSeries
import matplotlib.pyplot as plt
pwd = input('Enter Ticker Symbol Here: ')
ts = TimeSeries(key='HQL2R9KNYW99K4BT', output_format='pandas')
data, meta_data = ts.get_intraday(symbol=**'TSLA'**, interval='1min', outputsize='full') *#But Instead of tesla I want it to be user input.*
data['4. close'].plot()
plt.title('Intraday Times Series for the MSFT stock (1 min)')
plt.show()
The error I am getting is:
Traceback (most recent call last):
File "C:/Users/abakh/PycharmProjects/stock1/Stock1.py", line 7, in <module>
data, meta_data = ts.get_intraday(symbol=' + pwd + ', interval='1min', outputsize='full')
File "C:\Users\abakh\PycharmProjects\stock1\venv\lib\site-packages\alpha_vantage\alphavantage.py", line 178, in _format_wrapper
data = call_response[data_key]
KeyError: 'Time Series (1min)'