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.
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.
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.
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.
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.
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.
The 'to' is date.today(),so,it will only fetch data till the previous trading day.
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.
And as told above,you do get the latest live candle if you fetch data until current time.