Learn Algo Trading with Python | Codes | Youtube Series

Hi @Tradehull_Imran ,

the below mentioned error is appearing while running the code.

Error is :

exception got in ce_pe_option_df ‘<’ not supported between instances of ‘int’ and ‘str’
Getting Error at OTM strike Selection as ‘<’ not supported between instances of ‘int’ and ‘str’
Getting Error at OTM strike Selection as ‘<’ not supported between instances of ‘int’ and ‘str’
‘NoneType’ object has no attribute ‘upper’
Traceback (most recent call last):
File “C:\Users\SVIMS CAO\OneDrive\Desktop\Python\Revised\Dhan_Tradehull_V2.py”, line 516, in get_intraday_data
tradingsymbol = tradingsymbol.upper()
AttributeError: ‘NoneType’ object has no attribute ‘upper’
Traceback (most recent call last):
File “C:\Users\SVIMS CAO\OneDrive\Desktop\Python\Revised\Dhan_codebase usage.py”, line 52, in
intraday_hist_data[‘rsi’] = talib.RSI(intraday_hist_data[‘close’], timeperiod=14)
TypeError: ‘NoneType’ object is not subscriptable

Above mentioned error is appearing. i am using the Updated version of Dhan_Tradehull_V2.py file and Dhan Code base usage. Please check and guide me the possible solution

Use Dhan_Tradehull_V2 code base

it will auto download once you start running your codebase code


how do i solve this
?

Hi @Tradehull_Imran ,
Greetings for the eve :tada:

I’m using following code.
Here I’m fetching quote data,
But it almost takes 1min 16 sec to retrieve the required data.
How can we fetch the data with minimal time by using multiple Token Id or by any means.
If I scan for Nifty FNO stocks all the intraday time will go on scanning only.
Please help me out.
TIA :smiley:

SetExpiry = 0
Ops_S0_CE, Ops_S0_PE, ATM_Strike = tsl.ATM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry)

U1_CE_Strike, U1_PE_Strike, U1_CE_Price, U1_PE_Price = tsl.OTM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, OTM_count = 1)
U2_CE_Strike, U2_PE_Strike, U2_CE_Price, U2_PE_Price = tsl.OTM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, OTM_count = 2)
U3_CE_Strike, U3_PE_Strike, U3_CE_Price, U3_PE_Price = tsl.OTM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, OTM_count = 3)
U4_CE_Strike, U4_PE_Strike, U4_CE_Price, U4_PE_Price = tsl.OTM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, OTM_count = 4)
U5_CE_Strike, U5_PE_Strike, U5_CE_Price, U5_PE_Price = tsl.OTM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, OTM_count = 5)

L1_CE_Strike, L1_PE_Strike, L1_CE_Price, L1_PE_Price = tsl.ITM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, ITM_count = 1)
L2_CE_Strike, L2_PE_Strike, L2_CE_Price, L2_PE_Price = tsl.ITM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, ITM_count = 2)
L3_CE_Strike, L3_PE_Strike, L3_CE_Price, L3_PE_Price = tsl.ITM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, ITM_count = 3)
L4_CE_Strike, L4_PE_Strike, L4_CE_Price, L4_PE_Price = tsl.ITM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, ITM_count = 4)
L5_CE_Strike, L5_PE_Strike, L5_CE_Price, L5_PE_Price = tsl.ITM_Strike_Selection(Underlying = ListName, Expiry = SetExpiry, ITM_count = 5)

Hi @Tradehull_Imran ,
Greetings !!

I am very new to Algo Trading but i am very much want to follow you video series.

when i am running how to use updated codebase.py i am getting the below error in the begining itself. please help me resolve it.

Mibian requires scipy to work properly
Codebase Version 3
-----Logged into Dhan-----
dhanhq.init() takes 2 positional arguments but 3 were given
‘Tradehull’ object has no attribute ‘response’
Traceback (most recent call last):
File “C:\Users\pri\AppData\Local\Programs\Python\Python313\Lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py”, line 74, 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 “C:\Users\pri\AppData\Local\Programs\Python\Python313\Lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py”, line 52, in init
self.get_login(ClientCode,token_id)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\pri\AppData\Local\Programs\Python\Python313\Lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py”, line 80, in get_login
print(self.response)
^^^^^^^^^^^^^
AttributeError: ‘Tradehull’ object has no attribute ‘response’
Exception at calling ltp as ‘Tradehull’ object has no attribute ‘instrument_df’
PS C:\Users\pri\python learning>

Hello Imran Sir

what is the use of these two lines ?

get_quote and get_ltp are throwing error …

→ ltp = tsl.get_ltp_data(names = [‘NIFTY 28 AUG 24000 CALL’, ‘NIFTY 28 AUG 24000 PUT’])
(Pdb++) n
Exception for instrument name NIFTY 28 AUG 24000 CALL as Check the Tradingsymbol
Exception for instrument name NIFTY 28 AUG 24000 PUT as Check the Tradingsymbol
[0] > ←[33;01mg:\sree\test\2.py←[00m(←[36;01m33←[00m)()
→ print(ltp)

actual code is …

ltp = tsl.get_ltp_data(names = [‘NIFTY 28 AUG 24000 CALL’, ‘NIFTY 28 AUG 24000 PUT’])
print(ltp)

Is there any one to respond … Algos are not fetching any sort of data from past 2 days which were working fine earlier. Is it a techinical glitch. Whom should I contact regarding this …

Hey @Tradehull_Imran Sir,
good day! thanks for all your contribution.

I need a help for resolving the error, pls help me for the same.

Its resolved now, thanks!

import pdb	
from Dhan_Tradehull import Tradehull

client_code = "XXX"
token_id = "XXXX"
tsl = Tradehull(client_code,token_id)


for distance in range(1,10):
	
	ce_name, pe_name, ce_strike, pe_strike = tsl.OTM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=distance)
	#print(distance,"---",ce_name,"---", pe_name,"---",ce_strike,"---",pe_strike)
	ce_ltp_data   = tsl.get_ltp_data(ce_name)
	if ce_ltp_data < 10:
		print(ce_name,ce_ltp_data)

and my error is


C:\Users\Admin\Desktop\Dhan Algo\5. Session5- Python Part 2\5. Session5- Python Part 2>py "Session 5.py"
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-08-29.csv
Got the instrument file
Traceback (most recent call last):
  File "Session 5.py", line 14, in <module>
    if ce_ltp_data < 10:
TypeError: '<' not supported between instances of 'dict' and 'int'

C:\Users\Admin\Desktop\Dhan Algo\5. Session5- Python Part 2\5. Session5- Python Part 2>

am not able to install libraries as i have the latest python installed its showing error

link is not available. please share again episode 2 download link. thank tou

1 Like

hey @Tradehull_Imran
greetings sir im not able to fetch Sensex options data
code

CE_symbol_name, PE_symbol_name, CE_ITM_price, PE_ITM_price = tsl.ITM_Strike_Selection(Underlying=‘SENSEX’, Expiry=0, ITM_count=1)
sensex_data_ce = tsl.get_historical_data(tradingsymbol=‘CE_symbol_name’, exchange=‘BFO’, timeframe=“1”)
print(sensex_data_ce)

cmd
C:\Users\seans\OneDrive\Desktop\advance algoseries\strategies _deploy>py testing_for_otm.py
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-09-03.csv
Got the instrument file
Exception in Getting OHLC data as Check the Tradingsymbol or Exchange
None
–Return–
[0] > c:\users\seans\onedrive\desktop\advance algoseries\strategies _deploy\testing_for_otm.p
y(52)()->None → pdb.set_trace()
(Pdb++)

what should i doo

Can you share the session 2 files, google drive link is returning an error

Can you share the session 2 files, google drive link is returning an error

@RahulDeshpande I am unable to find session 2 zip as it says not found when I click on the link, is there a latest version ?

good day gentlemen, I was not able to see session 2 codes file I think it has been removed kindly guide me @Tradehull_Imran thank you in advance. I will be grateful if u respond timely. (Libraries.bat) and Sublime Text is required.

Hello, @RahulDeshpande ,new algo trader here, the session 2 installation.zip is not available on google drive, it says the ‘Sorry, the file you have requested does not exist.’ Please re-upload the file. Thank You.