0

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)'
Graham
  • 7,431
  • 18
  • 59
  • 84
  • Never mind guys, While waiting for a response I was messing around and actually found a way to do it! instead of making a seperate imput I added a input on the meta_date line it self : data, meta_data = ts.get_intraday(symbol=input('Put here: '), interval='1min', outputsize='full') – Bakhrom Abdurakhmonov Dec 12 '18 at 23:06
  • Please answer your own question instead of leaving this in the comments. This helps others who search for this issue in future instantly see that there is a solution their problem. – Graham Dec 13 '18 at 00:34

1 Answers1

0

Never mind guys, While waiting for a response I was messing around and actually found a way to do it! instead of making a seperate imput I added a input on the meta_date line it self : data, meta_data = ts.get_intraday(symbol=input('Put here: '), interval='1min', outputsize='full')