Learn Algo Trading with Python | Codes | Youtube Series

hi @rahulcse56

Do double check if below details are okey and run it again

also let me know if it works for you after making changes

hi @Subhajitpanja

in “Dhan_codebase usage.py”, line 33
ce_name, pe_name, strike = tsl.ATM_Strike_Selection('NIFTY','05-09-2024')

‘05-09-2024’ is a expired date for Nifty contract.
you need to place next expiries date here

@Tradehull_Imran Sir, Once you will free, please review this one

-----Logged into Dhan-----
reading existing file all_instrument 2024-10-16.csv
Got the instrument file
available_balance 686.15
Traceback (most recent call last):
  File "c:\Users\Subhajit Panja\Documents\Algorithim_HQ\Dhan codebase\Dhan_Tradehull.py", line 132, in order_placement
    security_id = self.instrument_df[((self.instrument_df['SEM_TRADING_SYMBOL']==tradingsymbol)|(self.instrument_df['SEM_CUSTOM_SYMBOL']==tradingsymbol))&(self.instrument_df['SEM_EXM_EXCH_ID']==instrument_exchange[exchange])].iloc[-1]['SEM_SMST_SECURITY_ID']
  File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1103, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1656, in _getitem_axis
    self._validate_integer(key, axis)
  File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1589, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds
Traceback (most recent call last):
  File "c:\Users\Subhajit Panja\Documents\Algorithim_HQ\Dhan codebase\Dhan_Tradehull.py", line 132, in order_placement
    security_id = self.instrument_df[((self.instrument_df['SEM_TRADING_SYMBOL']==tradingsymbol)|(self.instrument_df['SEM_CUSTOM_SYMBOL']==tradingsymbol))&(self.instrument_df['SEM_EXM_EXCH_ID']==instrument_exchange[exchange])].iloc[-1]['SEM_SMST_SECURITY_ID']
  File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1103, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1656, in _getitem_axis
    self._validate_integer(key, axis)
  File "C:\Users\Subhajit Panja\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\indexing.py", line 1589, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds

It is triggering the order but still some error is showing to output
@Tradehull_Imran Sir

I have changed 05-09-2024 to17-10-2024

dear rahul sir

episode 4 codes link given in youtube description is not working pls look in to this

1 Like

Now I got that issue is fixed

Thank you so much sir for your effort take my respect
@Tradehull_Imran Sir

@ddeogharkar

  1. Let me know which OS are you using windows/mac/linux ?
  2. I am giving you a new file Dhan_websocket SSL_issue_fixed.py
    instead of running Dhan_websocket.py, now run Dhan_websocket SSL_issue_fixed.py

HI @Tradehull_Imran, I am using windows

I have tried the attached file, but I am still facing the same issue. I am not sure I have tried many things by searching on Google but have had no luck.

Getting below error :
Reading existing file all_instrument 2024-10-16.csv
Watchlist changed. Reconnecting the feed…
Disconnected from WebSocket feed.

Thanks for your help and quick response.


jab me mere dhan account ka
Access Token
dalta hu tab esa ata he ?

@Tradehull_Imran - I am not able to connect to Dhan API using my code.

please advise soon.

@Tradehull_Imran
Output : Error

hi @ddeogharkar

Do send me complete zip of your folder, and share on the google drive link
share it with: tradehull_mentorship@tradehull.com

hi @Mukesh_Upadhyay

Do send me complete zip of your folder, and share on the google drive link
share it with: tradehull_mentorship@tradehull.com

Hi @Abhishek_Konda
No module named dhanhq, this means the installation was not completed

do visit Session 2 for installation

https://www.youtube.com/watch?v=YAyIoDJYorA

and download installation files from here

okay will try again.

hi @Mukesh_Upadhyay
It seems that you have subscribed to Dhan Trading api only,

you also need to subscribe to Dhan Data Api

for data api check this video at timestamp: 2:03

1 Like

hi @ddeogharkar

  1. I tried running your files on my laptop… it worked fine on my end
  2. The last error you have reported, does not seems to have SSL certificate issue,
    add one or below scripts in your watchlist.
SENSEX BSE_IDX
BANKEX BSE_IDX
NIFTY NSE_IDX
BANKNIFTY NSE_IDX
FINNIFTY NSE_IDX
MIDCPNIFTY NSE_IDX

run it again and send me complete error screenshot. and the screenshot of the excel

  1. If we still we find SSL issue, maybe a quicker method would be to install files on AWS free 2GB server and test the same. There we would have a Free + Dedicated + Secure + Enough Bandwidth environment, and the files would run normally there.

also make sure while adding script in watchlist, dont keep a whitespace at the end of script name or exchange name

@Tradehull_Imran - The below error is poping out in loop when I run dhan websocket code.

Hi @Abhishek_Konda

  1. Check this link and see if all the steps are correct
    Learn Algo Trading with Python | Codes | Youtube Series - #73 by Tradehull_Imran

after step 1 run and see if you still get error, If The error says SSL follow below steps

  1. check this thread, and check answers that were provided to @ddeogharkar
    the same issue is faced and resolved there.
    Learn Algo Trading with Python | Codes | Youtube Series - #105 by ddeogharkar

sir one request dont keep code files on google drive if possible keep it on git hub so in office environment we can download it because google drive is block in many organisation

1 Like

Hi @Tradehull_Imran , today i tried adding ~300 symbols to the websocket excel file. I observed the data faced significant lag. Also the connection was disconnecting often (almost at every minute end) and reconnecting. Is it normal?
What is the limiting factor ?- computing power// the code/ dhan websocket