Created
October 30, 2017 02:38
-
-
Save JialunC/63cb6aade28a5fa9f4ab9d77b89d87da to your computer and use it in GitHub Desktop.
My Synchronous Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import pandas as pd | |
import config | |
def store_json(symbol): | |
payload = { | |
'function': 'TIME_SERIES_DAILY_ADJUSTED', | |
'symbol': symbol, | |
'outputsize': 'full', | |
'apikey': config.ALPHA_API_KEY, | |
# AA api default data type is json, another option is csv | |
'datatype': 'json' | |
} | |
r = requests.get('https://www.alphavantage.co/query?', params=payload) | |
data = json.loads(r.text)['Time Series (Daily)'] | |
with open(f'./data/data_{symbol}.json', 'w') as outfile: | |
json.dump(data, outfile) | |
if __name__ == '__main__': | |
store_json('ROKU') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment