From ace4fe91ea2f78d4bbb4e81e1489c4c36aa4c8bb Mon Sep 17 00:00:00 2001 From: moshferatu Date: Mon, 11 Nov 2024 09:36:10 -0800 Subject: [PATCH] Convert date column to date object when returning historical intraday data --- iqfeed/iqfeed.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iqfeed/iqfeed.py b/iqfeed/iqfeed.py index b586dcc..5377ea1 100644 --- a/iqfeed/iqfeed.py +++ b/iqfeed/iqfeed.py @@ -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']