[ad_1]
def get_live_data():
data = []
hist = []
today = pd.to_datetime('today').date()
dates = pd.date_range(start="1/1/2022", periods=8)
with RESTClient("b5vP8ekB39aPqMhrX3lwp7pAt2zha32M") as client:
for date in dates:
print(date)
resp = client.stocks_equities_grouped_daily('us', 'stocks', date)
for result in resp.results:
data.append(result)
hist_df = pd.DataFrame(hist)
df = pd.DataFrame(data)
# print(df.loc[df['T'] == 'AAPL'])
df = df.rename(columns={'T':'Symbol',
'c': 'Close',
'h': 'High',
'l': 'Low',
'o': 'Open',
't': 'Date',
'v': 'Volume'})
df['Date'] = df['Date'].apply(ts_to_datetime)
return df
I’m getting the error while running the function. Please check once I’m stuck here for like an hour
[ad_2]