-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Originating from price_history.py #14
Comments
I had a similar issue |
I also had this issue |
This worked for me: I watched the code at price_history.py and realized that the API key is retrieved as an environment variable called ALPHA_VANTAGE_API_KEY. So, I created the environment variable, run the script and it worked. |
Noob here. Can you please provide some instructions on how to do it? Or provide the code you used? I'm having the same issue |
Hi @yousufj56.
I don't know your background so I will go step by step, starting from the
very basic.
First of all, get your API key from the site. Go to
https://www.alphavantage.co/support/#api-key and get your query.
I work on Linux (OS based on Ubuntu 18) and python3. I think it works also
for Mac. So, to save the API KEY as an environment variable do the next:
export ALPHA_VANTAGE_API_KEY=YOURAPIKEYHERE. This simple step could make
your code work. Anyway, I'll continue with some basic steps for those that
are completely new.
Let's get the environment ready. I created a virtual environment on a new
folder. So, go into the folder (lets call it alpha) and create the
virtualenv:
virtualenv -p python3 env
Activate the virtual env from alpha folder:
source env/bin/activate
Install Alpha Vantage module for python:
pip install alphavantage
Write a basic code in a new python file, just to try it works. I called it
run.py:
from alphavantage.price_history import PriceHistory
history = PriceHistory(period='W', output_size='compact')
results = history.get('AAPL')
print(results.ticker)
print(results.records[-1:])
Execute the script:
python run.py
Hope this helps :)
For those using Windows: I cannot explain how you can do this in Windows,
as I don't use it. I guess you could easily find how to save Environment
Variables in Windows, which I think is the key to solve this error.
|
Thanks, thats helpful. But now i get a syntax error on this line: return f'{interval}min' You know whats happening? |
Got it, i moved the ' infront of f and now i can get data |
I was trying to use this wrapper and was getting this error. I then created a new file and tried running your example code presented at https://pypi.org/project/alphavantage/ and obtained the same error. Please fix since I would like to use this to obtain the date from the alphavantage data as a check when running code to add another day's data to a database.
File "C:\Users\User\Anaconda3\lib\site-packages\alphavantage\price_history.py", line 136, in get_results
updated_at, timezone, is_intraday = self.transform_meta_data(response['Meta Data'])
KeyError: 'Meta Data'
Or, if you could give me an idea of how to obtain the datestamp from the json file data that is normally downloaded, that would help too.
Thanks.
The text was updated successfully, but these errors were encountered: