I am facing an issue where I am unable to fetch live market data (LTP) or historical candle data for NIFTY 50 and other indices using the SmartAPI.
Issue Summary:
- I used the correct token for NIFTY 50 (
99926000
) from your Scrip Master file (https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json
).
{"token":"99926000","symbol":"Nifty 50","name":"NIFTY","expiry":"","strike":"0.000000","lotsize":"1","instrumenttype":"AMXIDX","exch_seg":"NSE","tick_size":"0.000000"},
- I tried fetching both LTP and historical data but did not receive any response.
- I also tried changing the exchange from NSE to NFO, but it did not resolve the issue.
Steps I Tried & Results:
1️⃣ Fetching LTP for NIFTY 50
ltp_data = smartApi.ltpData("NSE", "99926000")
print("LTP Response:", ltp_data)
- Expected Outcome: It should return the last traded price (LTP) for NIFTY 50.
- Actual Outcome: No data received / Empty response.
2️⃣ Fetching Historical Data for NIFTY 50 Spot (NSE)
historicParam = {
"exchange": "NSE",
"symboltoken": "99926000",
"interval": "ONE_HOUR",
"fromdate": "2025-03-01 09:15",
"todate": "2025-03-03 15:30"
}
data = smartApi.getCandleData(historicParam)
print("Historical Data Response:", data)
- Expected Outcome: It should return historical OHLC candle data for NIFTY 50.
- Actual Outcome: No data received / Empty response.
3️⃣ Fetching Historical Data for NIFTY Futures (NFO)
historicParam = {
"exchange": "NFO",
"symboltoken": "99926000",
"interval": "ONE_HOUR",
"fromdate": "2025-03-01 09:15",
"todate": "2025-03-03 15:30"
}
data = smartApi.getCandleData(historicParam)
print("Historical Data Response:", data)
- Expected Outcome: It should return historical OHLC candle data for NIFTY Futures.
- Actual Outcome: No data received / Empty response.