22 lines
681 B
Python
22 lines
681 B
Python
import pandas as pd
|
|
|
|
from database.ohlc import insert
|
|
from datetime import datetime, date
|
|
from iqfeed.iqfeed import get_historical_data, minutes
|
|
|
|
today = date.today()
|
|
symbol = 'SPY'
|
|
data = get_historical_data(symbol, minutes(5),
|
|
start_date = datetime.combine(date(2023, 1, 1), datetime.min.time()),
|
|
end_date = datetime.combine(today, datetime.max.time()))
|
|
|
|
data['Symbol'] = symbol
|
|
data['Timeframe'] = '5m'
|
|
data['Timestamp'] = pd.to_datetime(data['Date'])
|
|
data['Date'] = data['Timestamp'].dt.date
|
|
data = data.rename(columns={
|
|
'Period Volume': 'Volume'
|
|
})
|
|
data = data[['Symbol', 'Date', 'Timeframe', 'Timestamp', 'Open', 'High', 'Low', 'Close', 'Volume']]
|
|
|
|
insert(data) |