Hi @Tradehull_Imran,
Problem in running the Algo code Dhan_codebase usage.py
This was working fine till yesterday but today it started giving error. I just updated the IDE which should not impact this.
dhanhq.init() takes 2 positional arguments but 3 were given
‘Tradehull’ object has no attribute ‘response’
‘Tradehull’ object has no attribute ‘Dhan’
‘Tradehull’ object has no attribute ‘Dhan’
Error at Gettting balance as ‘Tradehull’ object has no attribute ‘Dhan’
available_balance 0
‘Tradehull’ object has no attribute ‘sheet’
‘Tradehull’ object has no attribute ‘sheet’
‘Tradehull’ object has no attribute ‘sheet’
‘Tradehull’ object has no attribute ‘sheet’
‘Tradehull’ object has no attribute ‘Dhan’
‘Tradehull’ object has no attribute ‘Dhan’
exception got in ce_pe_option_df ‘Tradehull’ object has no attribute ‘instrument_df’
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 212, in get_login
self.Dhan = dhanhq(self.ClientCode, self.token_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: dhanhq.init() takes 2 positional arguments but 3 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 50, in init
self.get_login(ClientCode, token_id)
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 218, in get_login
print(self.response)
^^^^^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘response’
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 396, in get_intraday_data
script_exchange = {“NSE”: self.Dhan.NSE, “NFO”: self.Dhan.NSE_FNO, “BFO”: self.Dhan.BSE_FNO,
^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘Dhan’
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 396, in get_intraday_data
script_exchange = {“NSE”: self.Dhan.NSE, “NFO”: self.Dhan.NSE_FNO, “BFO”: self.Dhan.BSE_FNO,
^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘Dhan’
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 351, in get_historical_data
script_exchange = {“NSE”: self.Dhan.NSE, “NFO”: self.Dhan.NSE_FNO, “BFO”: self.Dhan.BSE_FNO,
^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘Dhan’
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 396, in get_intraday_data
script_exchange = {“NSE”: self.Dhan.NSE, “NFO”: self.Dhan.NSE_FNO, “BFO”: self.Dhan.BSE_FNO,
^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘Dhan’
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 519, in ATM_Strike_Selection
instrument_df = self.instrument_df.copy()
^^^^^^^^^^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘instrument_df’
— Logging error —
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 519, in ATM_Strike_Selection
instrument_df = self.instrument_df.copy()
^^^^^^^^^^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘instrument_df’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Python\Python_Install\Lib\logging_init_.py”, line 1110, in emit
msg = self.format(record)
^^^^^^^^^^^^^^^^^^^
File “D:\Python\Python_Install\Lib\logging_init_.py”, line 953, in format
return fmt.format(record)
^^^^^^^^^^^^^^^^^^
File “D:\Python\Python_Install\Lib\logging_init_.py”, line 687, in format
record.message = record.getMessage()
^^^^^^^^^^^^^^^^^^^
File “D:\Python\Python_Install\Lib\logging_init_.py”, line 377, in getMessage
msg = msg % self.args
~~~~~~^
TypeError: not all arguments converted during string formatting
Call stack:
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_codebase usage.py”, line 33, in
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(‘NIFTY’,‘30-09-2025’)
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 586, in ATM_Strike_Selection
self.logger.exception(“Got exception in ce_pe_option_df “, e)
Message: 'Got exception in ce_pe_option_df ’
Arguments: (AttributeError(”‘Tradehull’ object has no attribute ‘instrument_df’”),)
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 519, in ATM_Strike_Selection
instrument_df = self.instrument_df.copy()
^^^^^^^^^^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘instrument_df’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_codebase usage.py”, line 33, in
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(‘NIFTY’,‘30-09-2025’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D\Dhan Code\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 588, in ATM_Strike_Selection
return None, None, strike
^^^^^^
UnboundLocalError: cannot access local variable ‘strike’ where it is not associated with a value