Hi Team, I was trying to fetch historical candle data for instrument "NSE_EQ|INE466L01038"
I used this addhoc script to fetch the data
import pandas as pd
import json
apiInstance = upstox_client.HistoryV3Api()
def get_historical_candle_data(symbol: str, toDate: str,fromDate: str, timePeriod: str, multiplier: str = "15"):
try:
response = apiInstance.get_historical_candle_data1(symbol, timePeriod, multiplier, toDate, fromDate)
candles = getattr(response.data, "candles", None)
candles_df = pd.DataFrame(
candles,
columns=["timestamp", "open", "high", "low", "close", "volume", "oi"]
)
count = 0
for _, row in candles_df.iterrows():
count += 1
print(row["timestamp"], row["close"])
print(count)
except Exception as e:
print("Exception when calling HistoryV3Api->get_historical_candle_data1: %s\n" % e)
get_historical_candle_data("NSE_EQ|INE466L01038", "2025-06-10", "2025-06-09", "minutes")
I observed during market hours and even post market hours I am getting inconsistent candles for different fromDate
parameter. For eg for fromDate = "2025-05-27"
at 1:37 PM I am getting candles only upto 2025-06-10T11:00:00+05:30
. First I thought there may be some limit to the number of candles we get in a single call but then I tried fromDate = 2025-05-26
and got candles upto 2025-06-10T14:30:00+05:30
.
Am I doing something wrong here ? is this expected ?
one more query → In the Historical Candle Data V3 API why we get the candle data which is not closed yet, for eg at 9:32, I dont want 9:30 candle OHLC data as the candle is live, want the close price after the candle is actually closed.