I have get_historical_data call in the on_ticks function with 15minute interval. It doesnt seem to update the data accordingly. For example, If I start the code at 1:05 PM, I will have data until 1:00 PM candle. This is fine. But when time crosses 1:15PM, I expect to see the data refreshed with the new candle, which is not happening. To test it, I left the execution on for whole day yesterday and last candle recorded was 10:00 AM candle ,the time when I started the script.
But when I exit the script and restart it will have the latest data. But this doesnt work in a loop
@rakeshr : I found the issue, I was using date.today() instead of date.now() of datetime package ,which was also giving me time stamp at the time of execution and to_date is limiting the time period.
I have seen that you were recommending people not to use historical_data api for live trading. Would this be a problem even if I am planning to use 15min time frame?
@rjv17, what is 100 in from_date = to_date -100, is it 100 minutes? Whatever the time_frame is, trading using historical api is not recommended because of huge latency. Due to which you will have trouble filling your orders at desired price point, which in turn defeats the purpose of algo trading
I have seen that you were recommending people not to use historical_data api for live trading. Would this be a problem even if I am planning to use 15min time frame?
No, it should not be a problem for longer time frame.
You don't seem to be storing historical data requests properly.Can you paste here historical APIs call part of code?
to_date = date.now() //#psuedo code
from_date = to_date - 100 //#psuedo code
def on_ticks(ws, ticks):
for i in range(0,len(planned_trades_df)):# Multiple instruments are stored in planned_df
symbol = planned_trades_df.loc[i]['Symbol']
instrument_token = planned_trades_df.loc[i]['Instrument Token']
interval = planned_trades_df.loc[i]['Interval']
records = get_historical_data(kite,instrument_token,interval,from_date,to_date)
print("Got Historical Data")
This records is sent to a strategy function
I found the issue, I was using date.today() instead of date.now() of datetime package ,which was also giving me time stamp at the time of execution and to_date is limiting the time period.
I have seen that you were recommending people not to use historical_data api for live trading.
Would this be a problem even if I am planning to use 15min time frame?
Whatever the time_frame is, trading using historical api is not recommended because of huge latency. Due to which you will have trouble filling your orders at desired price point, which in turn defeats the purpose of algo trading
And all my orders are coded to be MARKET. Will it work?