Re-order intraday data columns, add a time column, and rename volume column
This commit is contained in:
parent
b2a15b86ea
commit
8e78ee15ce
@ -98,14 +98,16 @@ def get_historical_data(symbol: str, interval: int, date: datetime = None,
|
||||
data = data.replace(',\n','\n')[:-1]
|
||||
|
||||
data = StringIO(data)
|
||||
data = pd.read_csv(data, index_col = False, names = columns)
|
||||
data = pd.read_csv(data, index_col = False, names = iqfeed_columns)
|
||||
|
||||
if data[columns].isna().any(axis = 1).any() or data.empty:
|
||||
return pd.DataFrame(columns = columns)
|
||||
if data[iqfeed_columns].isna().any(axis = 1).any() or data.empty:
|
||||
return pd.DataFrame(columns = intraday_columns)
|
||||
|
||||
data['Date'] = pd.to_datetime(data['Date'])
|
||||
data['Date'] = data['Date'].dt.date
|
||||
return data
|
||||
timestamp = pd.to_datetime(data['Date'])
|
||||
data['Date'] = timestamp.dt.date
|
||||
data['Time'] = timestamp.dt.time
|
||||
data = data.rename(columns = { 'Period Volume': 'Volume' })
|
||||
return data[intraday_columns]
|
||||
|
||||
if __name__ == '__main__':
|
||||
symbols = ['SPY']
|
||||
|
Loading…
Reference in New Issue
Block a user