import pandas as pd from database.ohlc import insert from datetime import datetime, date, timedelta from iqfeed.iqfeed import get_daily_data today = date.today() symbol = 'VIX1Y.XO' yesterday = date.today() - timedelta(days=1) data = get_daily_data(symbol, start_date = datetime.combine(date(2016, 1, 1), datetime.min.time()), end_date = datetime.combine(yesterday, datetime.max.time())) data['Symbol'] = symbol data['Timeframe'] = '1d' 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)