Learn Algo Trading with Python | Codes | Youtube Series

so to learn Algo Trading , Data API is mandatory? which will cost 500?

“Sir, just like you had the option for client login and API key in your dhan_websocket, I don’t have that option in my app. Can you please explain why?”

Hi @jain79

  1. Follow below steps to Fix the SSL issue
    https://private-poc.madefortrade.in/t/learn-algo-trading-with-python-codes-youtube-series/32718/177?u=tradehull_imran

  2. Do remove SILVER-27Aug2024-78000-PE its a expired contract

  3. As of today market is closes so the data will not update, On Monday do re-run the files after following steps for fixing SSL issue.

Also on Monday do update me if its solved or not.

Hi @thakurmhn

Its a SSL issue, do follow below steps to fix the issue,
https://private-poc.madefortrade.in/t/learn-algo-trading-with-python-codes-youtube-series/32718/177?u=tradehull_imran

Also since market is closed we need to wait for Monday to get updated data.

Hi @sgoogal

As of now the code is fixed for windows users, we will release codebase with MAC compatibility in upcoming release.

Till then you may proceed with any windows machine or server

1 Like

Hi @Md_Naquibuddin
Yes its mandatory to subscribe to the dhanhq api to get the data

Hi @Manish_Goel
The SSL issue seems to be fixed

Also since market is closed we need to wait for Monday to get updated data.

Hi @Abhishek_Konda

Yes for the data, subscribing to paid dhanhq api is mandatory

hi @Md_Naquibuddin

  1. the screenshot of the code provided is of Dhan_websocket.py, we need to make the changes in line no 41 and 42… access_token line.. and the client_code line

  1. Also you need to make changes in Dhan_codebase usage.py, in the client_code and token_id variable

When we try to enter the codebase, this message appears. Why?"

@Tradehull_Imran Sir, you teach us Python in the simplest way possible, making it easy to understand. You also point out our mistakes and guide us on how to become independent in coding (algorithmic coding/Python/programming) through the debugging process. The best part is your constant motivation and encouragement, congratulating us on our efforts, even though the credit truly goes to you. I know teaching to someone with simple way is not the simplest at all. It’s requires lot of hard word and research.

Thanks @Dhan

2 Likes

Hi @Md_Naquibuddin
This means the Ta-Lib was not installed. please check below steps

https://private-poc.madefortrade.in/t/learn-algo-trading-with-python-codes-youtube-series/32718/8?u=tradehull_imran

1 Like

@Tradehull_Imran Sir while running dhan_codebase usage.py
Data api subscribed for 499+gst

Microsoft Windows [Version 10.0.22631.4169]
(c) Microsoft Corporation. All rights reserved.

D:\dhan\3. Session3 - Codebase\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase>py “Dhan_codebase usage.py”
-----Logged into Dhan-----
reading existing file all_instrument 2024-10-19.csv
Got the instrument file
available_balance 19411.18
single positional indexer is out-of-bounds
single positional indexer is out-of-bounds
Traceback (most recent call last):
File “D:\dhan\3. Session3 - Codebase\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 394, in ATM_Strike_Selection
closest_index = ce_df[‘diff’].idxmin()
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\series.py”, line 2460, in idxmin
i = self.argmin(axis, skipna, *args, **kwargs) # type: ignore[arg-type]
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\base.py”, line 742, in argmin
return nanops.nanargmin( # type: ignore[return-value]
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\nanops.py”, line 96, in _f
return f(*args, **kwargs)
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\nanops.py”, line 1193, in nanargmin
result = values.argmin(axis) # type: ignore[var-annotated]
ValueError: attempt to get argmin of an empty sequence
— Logging error —
Traceback (most recent call last):
File “D:\dhan\3. Session3 - Codebase\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 394, in ATM_Strike_Selection
closest_index = ce_df[‘diff’].idxmin()
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\series.py”, line 2460, in idxmin
i = self.argmin(axis, skipna, *args, **kwargs) # type: ignore[arg-type]
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\base.py”, line 742, in argmin
return nanops.nanargmin( # type: ignore[return-value]
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\nanops.py”, line 96, in _f
return f(*args, **kwargs)
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\nanops.py”, line 1193, in nanargmin
result = values.argmin(axis) # type: ignore[var-annotated]
ValueError: attempt to get argmin of an empty sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\logging_init_.py”, line 1081, in emit
msg = self.format(record)
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\logging_init_.py”, line 925, in format
return fmt.format(record)
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\logging_init_.py”, line 664, in format
record.message = record.getMessage()
File “C:\Users\banka\AppData\Local\Programs\Python\Python38\lib\logging_init_.py”, line 369, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File “Dhan_codebase usage.py”, line 33, in
ce_name, pe_name, strike = tsl.ATM_Strike_Selection(‘NIFTY’,‘05-09-2024’)
File “D:\dhan\3. Session3 - Codebase\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 421, in ATM_Strike_Selection
self.logger.exception("Got exception in ce_pe_option_df ", e)
Message: 'Got exception in ce_pe_option_df ’
Arguments: (ValueError(‘attempt to get argmin of an empty sequence’),)
exception got in ce_pe_option_df attempt to get argmin of an empty sequence
Getting Error at OTM strike Selection as attempt to get argmin of an empty sequence
Getting Error at OTM strike Selection as attempt to get argmin of an empty sequence
single positional indexer is out-of-bounds
Traceback (most recent call last):
File “D:\dhan\3. Session3 - Codebase\3. Session3 - Codebase\3. Session3 - Codebase\Dhan codebase\Dhan_Tradehull.py”, line 251, in get_intraday_data
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\banka\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\banka\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\banka\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 “Dhan_codebase usage.py”, line 39, in
intraday_hist_data[‘rsi’] = talib.RSI(intraday_hist_data[‘close’], timeperiod=14)
TypeError: ‘NoneType’ object is not subscriptable


while running websocket getting authorization successfull

@Tanay_Banka
Please share the file content as well
without token
Hope you subscribed DATA API(which is payable) also

try to run it in live market

@Tanay_Banka these should be future expiry date

1 Like

@Tradehull_Imran Sir getting this error while practising Session 5. Please guide. How to rectify the error.

@Tradehull_Imran
Sir I followed all the steps mentioned in previous posts and still not getting LTPs in the excel.
This is what i am getting.