Unable to fetch the option chain data

@Tradehull_Imran Unable to fetch the market data. Showing this error since morning. Everything was working fine since yesterday. Today its showing this error.

[2026-03-17 09:43:48.958859] INFO: :white_check_mark: Login Successful — bot auto-logged in, no manual to
ken needed!
[2026-03-17 09:43:48.959476] INFO: No DHAN_STATIC_IP configured. Skipping static IP setup. (Required for order placement as per SEBI rules)
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:43:48.964998] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:43:48.966823] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:43:53.972913] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:43:53.973682] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:43:58.979268] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:43:58.979760] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:03.985248] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:03.985798] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:08.993569] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:08.995123] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:14.004198] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:14.006081] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:19.014410] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:19.015776] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:24.023137] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:24.024838] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:29.030336] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:29.030825] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:34.036455] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:34.037021] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:39.043354] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:39.043862] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…
got exception in pnl as ‘Tradehull’ object has no attribute ‘instrument_df’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Exception in Getting OHLC data as ‘Tradehull’ object has no attribute ‘instrument_df’
[2026-03-17 09:44:44.051937] ERROR [MarketData]: Failed to fetch market data or empty dataframe returned.
[2026-03-17 09:44:44.053376] ERROR [Strategy]: Failed to map Option Chain strikes. Retrying…

@Mahikbs Try official Python package code here.

Hi @Mahikbs ,

Itseems the login was not successful because of which instrument file was not downloaded, do retry to re run the program. If you still face issues send the screenshot of the cmd terminal with the codebase version.

D:\Data_for_trader\new idea>py dhan_option_chain.py
Codebase Version 3.1.2
Traceback (most recent call last):
File “D:\Data_for_trader\new idea\dhan_option_chain.py”, line 18, in
tsl = Tradehull(client_code, token_id, mode=“access_token”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Tradehull.init() got an unexpected keyword argument ‘mode’

D:\Data_for_trader\new idea>py dhan_option_chain.py
Codebase Version 3.1.2
-----Logged into Dhan-----
reading existing file all_instrument 2026-03-17.csv
Got the instrument file

d:\data_for_trader\new idea\dhan_option_chain.py(28)()
→ def get_chain():
(Pdb) atm, df = tsl.get_option_chain(Underlying=SYMBOL,exchange=“INDEX”,expiry=0,num_strikes=20)
Exception at getting Expiry list as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: ‘’}
Unable to find the correct Expiry for SENSEX
*** TypeError: cannot unpack non-iterable NoneType object

1 Like

Hi @ram_partap ,

Do update the codebase to latest version, follow the below thread’s steps-

Dear @Tradehull_Imran Sir,

I have updated both my Python version and the TradeHull library, but I am still facing an issue while fetching Option Chain data.

Environment Details:

  • Python Version: 3.12.3

  • Dhan_Tradehull Version: 3.3.2

  • dhanhq Version: 2.3.0rc1

Package Details:

pip show Dhan-Tradehull

Name: Dhan_Tradehull
Version: 3.3.2
Location: /home/ubuntu/TradingBot/.venv/lib/python3.12/site-packages
pip show dhanhq

Name: dhanhq
Version: 2.3.0rc1
Location: /home/ubuntu/TradingBot/.venv/lib/python3.12/site-packages

Console Output:

Mibian requires scipy to work properly
Codebase Version 3.3.2
Attempting authentication using ACCESS TOKEN.
Cached token profile validated successfully
Token validity: 24/07/2026 08:33
System is fetching the latest instrument file from Dhan
Already logged in for today, so reusing the validated token
Instrument file retrieved successfully
-----SUCCESSFULLY LOGGED INTO DHAN-----
Exception at calling ltp as {'status': 'failure', 'remarks': {'error_code': None, 'error_type': None, 'error_message': None}, 'data': ''}
Getting Error at Option Chain as 'NIFTY'

The login process completes successfully, and the instrument file is also downloaded without any issues. However, when fetching the Option Chain, the API fails and returns:

  • Exception at calling ltp

  • Getting Error at Option Chain as 'NIFTY'

Could you please help identify the cause of this issue? Also, please let me know if any changes are required in the code due to recent updates in the TradeHull library or the DhanHQ API.

Thank you.