History API is stop returning data for any MCX future stock
-
Hi @admin123 @admin @administrators ,
History API is stop returning data for MCX future stock's data.
Can you please resolve this issue or suggest if any changes has made recently to make it work.Thanks in advance!
Sample code -
def fetchDataOneline(in_exchange,in_symboltoken):
obj = SmartConnect(api_key=apikey)
data = obj.generateSession(username, pud, pyotp.TOTP(token).now())
refrashToken = data['data']['refreshToken']
res = obj.getProfile(refrashToken)
print(res['data']['exchanges'])
try:
historicParam = {
"exchange": in_exchange,
"symboltoken": in_symboltoken,
"interval": "FIVE_MINUTE",
"fromdate": "2023-06-10 15:55",
"todate":"2023-06-22 15:55"
}
historic_data = obj.getCandleData(historicParam)# Extract the candle data from the 'data' key candle_data = historic_data['data'] # Create a DataFrame from the candle data df = pd.DataFrame(candle_data, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume']) print(df) except Exception as e: print("Historic Api failed: {}".format(e.message)) # logout try: time.sleep(1) logout = obj.terminateSession('N51542847') print("Logout Successfully") except Exception as e: print("Logout failed: {}".format(e.message)) return df
in_exchange= "MCX"
in_symboltoken = "244731"Output:
-
Hi @N51542847
Apologies for delayed response.
We have verified for few of MCX future stock (Instance: ALUMINI24FEBFUT), we are able to fetch the data from the historical API. Kindly reverify and make sure the token passed is not expired and let us know if the issue still occurs.Thanks & Regards,
SmartAPI team