Problem Definition: Not getting the complete last candle (OHLC) data of 5 mins at the end of the 5 minute interval, in live market. The issue is I get say 10:15 data only at the end of 10:20 with the following code, that I have been running this as part of the overall code:
Code for Reference While True: if (datetime.now().second == 30) and (datetime.now().minute % 5 == 0): from_date = datetime.strftime(datetime.now() - timedelta(100), '%Y-%m-%d') to_date = datetime.today().strftime('%Y-%m-%d') records = kite.historical_data(instrument_token=256265, from_date=from_date, to_date=to_date, interval=interval1) df = pd.DataFrame(records)
I have tried the following both with this line added and without df.drop(df.tail(1).index, inplace=True), but I do not get the correct OHLC for 5 min data, even though I have given 30 seconds more, just in case.
@hkr, The historical data API is provided for backtesting purposes only. For live market strategies, you can generate candles at your end using the Websocket API data. You can get started from here.
The historical data API is provided for backtesting purposes only. For live market strategies, you can generate candles at your end using the Websocket API data.
You can get started from here.