-
-
Save vedranmarkulj/df7cda00f20a950efa664fed59a3aadc to your computer and use it in GitHub Desktop.
get_main_df_05.py
This file contains 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
from get_historical_data import AlphaVantage | |
import pandas as pd | |
import json | |
def get_main_data_frame(symbol): | |
. | |
. | |
. | |
# | |
# convert data to data frame | |
# | |
df = pd.read_json(json.dumps(list_historical_data__daily)) | |
# | |
# prepare data, and add calculated fields to data frame | |
# | |
df['date_str'] = df['date'] | |
df.set_index('date', inplace=True) | |
df.sort_index(inplace=True) | |
df['price_close_lag'] = df['price_close'].shift(1) | |
df['price_close_lead'] = df['price_close'].shift(-1) | |
df.insert(0, 'date_id', range(1, 1 + len(df))) | |
# | |
# returns data frame | |
# | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment