Convert date column to date object when returning historical intraday data

This commit is contained in:
moshferatu 2024-11-11 09:36:10 -08:00
parent 0f696e4a77
commit ace4fe91ea

View File

@ -93,8 +93,11 @@ def get_historical_data(symbol: str, interval: int, date: datetime = None,
data = data.replace(',\n','\n')[:-1]
data = StringIO(data)
return pd.read_csv(data, index_col = False,
data = pd.read_csv(data, index_col = False,
names=['Date', 'High', 'Low', 'Open', 'Close', 'Total Volume', 'Period Volume'])
data['Date'] = pd.to_datetime(data['Date'])
data['Date'] = data['Date'].dt.date
return data
if __name__ == '__main__':
symbols = ['SPY']