Skip to content

Instantly share code, notes, and snippets.

@vedranmarkulj
Last active February 25, 2018 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedranmarkulj/b6120b12aa817bfa129c98cf6c0d2d44 to your computer and use it in GitHub Desktop.
Save vedranmarkulj/b6120b12aa817bfa129c98cf6c0d2d44 to your computer and use it in GitHub Desktop.
get_main_df_04.py
from get_historical_data import AlphaVantage
import pandas as pd
import json
def get_main_data_frame(symbol):
.
.
.
#
# Find and list all relevant keys in the original historical data response
#
list_keys = []
list_historical_data__daily = []
for key in historical_data_daily['Time Series (Daily)']:
list_keys.append(key)
for k in list_keys:
#
# Extract relevant data from original historical data response
#
data = historical_data_daily['Time Series (Daily)'][k]
price_open = data['1. open']
price_high = data['2. high']
price_low = data['3. low']
price_close = data['4. close']
dict_data = dict([
(u'date', k),
(u'symbol', symbol),
(u'price_open', price_open),
(u'price_high', price_high),
(u'price_low', price_low),
(u'price_close', price_close),
])
list_historical_data__daily.append(dict_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment