Stock Options - Historical Data Error via Dhan

Please guide as I am unable to fetch stock options using code

underlying = ‘HDFCBANK’

ce_symbol, pe_symbol, _ = tsl.ATM_Strike_Selection(Underlying=underlying, Expiry=0)

strike = ce_symbol if ce_symbol else pe_symbol

option_chain = tsl.get_option_chain(Underlying=underlying, exchange=“NSE”, expiry=0, num_strikes=10)

historical_data = tsl.get_historical_data(tradingsymbol=strike, exchange=‘NSE’, timeframe=“1”)

Error message shown to me is - Exception in Getting OHLC data as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘DH-905’, ‘error_type’: ‘Input_Exception’, ‘error_message’: ‘System is unable to fetch data due to incorrect parameters or no data present’}, ‘data’: {‘errorType’: ‘Input_Exception’, ‘errorCode’: ‘DH-905’, ‘errorMessage’: ‘System is unable to fetch data due to incorrect parameters or no data present’}}

Hi @Karun149 ,

After getting the strike, to fetch historical data for option strike use exchange = “NFO”.

historical_data = tsl.get_historical_data(tradingsymbol=strike, exchange=‘NFO’, timeframe=“1”)

Let me know if you face any issues.