Skip to content

Instantly share code, notes, and snippets.

@JialunC
Created October 30, 2017 02:38
Show Gist options
  • Save JialunC/63cb6aade28a5fa9f4ab9d77b89d87da to your computer and use it in GitHub Desktop.
Save JialunC/63cb6aade28a5fa9f4ab9d77b89d87da to your computer and use it in GitHub Desktop.
My Synchronous Code
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