When I am calling for data with kite.historical data, does that include the current time candle?

being
Hi,

So for my bot, I want it to take a look at the last fully formed candle.

Let's say the bot runs at 9.24, if I grab the data using historical data to get ohlc at the time, will that include the candle until 9.24 (5 min chart) or the last ohlc value there will be of 9.20 candle?

Mainly want to understand if when checking for signals should I remove the last row received from ohlc or not? Cause currently in backtesting I am getting trades but not when live.
Tagged:
  • SRIJAN
    Depends on the 'to' parameter you input.

    If you fetch data data until current time,you will get the current running candle as well.
    In that case,you have to look at the 2nd last row for the last completed candle.
  • being
    Hi @SRIJAN ,

    This is how I am calling for data

    def fetchOHLC(ticker,interval,duration):
    instrument = instrumentLookup(instrument_df,ticker)
    data = pd.DataFrame(kite.historical_data(instrument,dt.date.today()-dt.timedelta(duration),
    dt.date.today(),interval))
    data.set_index("date",inplace=True)
    return data


    the way I call is fetchOHLC("ACC","5minute",5)

    Does this include the candle that is still forming? I am still bit of noob thus asking.
  • SRIJAN
    You can print your parameters and check their values.


    The 'to' is date.today(),so,it will only fetch data till the previous trading day.
  • being
    I have not been able to check it in the live market yet but when pulling data after market hours I get today's data as well i.e the last closed candle.

    The question is whether or not when running it in live market do we get the last closed candle as the last row or current live candle as the last row.
  • SRIJAN
    This isn't possible. You can't get today's data if you use datetime.date.today(). To get today's data,you have to use datetime.datetime.today().

    And as told above,you do get the latest live candle if you fetch data until current time.
Sign In or Register to comment.