Advanced Algo Trading 2026 | Codes | Youtube

Hi everyone,

We’re grateful for the overwhelming response to our previous algo trading series :raising_hands:
Continuing the same momentum, we’ve now created the 2026 version of the Advanced Algo Trading series.

Below are the code files that were created during Advanced Algo Trading 2026. We’ll keep updating the codes and scripts as new videos are released. You can also use this thread to post any questions or queries related to the videos.

Happy learning and building :rocket:

Build an Option Chain Algo Using Dhan API -:
Code link - https://drive.google.com/file/d/16FBIN4pGRsefYMb53mvxLnCBh9yuB5RJ/view?usp=sharing

Expired Option Data -:
Code link - https://drive.google.com/file/d/1iqm8tVgAmXqzYdyo7ZKmvzAmyCpUXTKq/view?usp=sharing

Full Market Depth -:
Code link -https://drive.google.com/file/d/1r-26bzpiu7eK5X4Oq4RJ9jP0Ww7j9Gbi/view?usp=drivesdk

Live Algo Options part 1 -:
Code link - https://drive.google.com/file/d/1aLscDn9xYj8QocLiywaMMD0HtTW5jsvP/view?usp=drivesdk

Live Algo Options part 2 -:
Code link -

Multi-Timeframe Strategy -:
Code link - https://drive.google.com/file/d/1gfCoFkHE7kjW3mfzBoqXm94OhYJzUBZT/view?usp=sharing

2 Likes

Can I find the ohlc data of all sensex strike ???

Thank you sir. We look forward to learn through rest of Clips in this series very eagerly.

Dear Sir, I am getting the following Error. Please Resolve it sir.

C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\1. Option Chain\1. Option Chain>py “Working with Option chain.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2026-01-20.csv
Got the instrument file
Exception at getting Expiry list as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘808’: ‘Authentication Failed - Client ID or Token invalid’}, ‘status’: ‘failed’}}
Unable to find the correct Expiry for NIFTY
Traceback (most recent call last):
File “C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\1. Option Chain\1. Option Chain\Working with Option chain.py”, line 9, in
atm, option_chain = tsl.get_option_chain(Underlying=“NIFTY”, exchange=“INDEX”, expiry=1, num_strikes=10)
^^^^^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable NoneType object

Hi @Vasili_Prasad ,

The error seems to be of Authentication failed. Make sure your client ID is correct and regenerate your access token and re run the program.

Hi @Prince_Kumar2 ,

Yes we can, change the underlying to SENSEX and try.

Very Good Day sir. Thank you for your guidance. I will comeback to you after retrying the same. VBR Prasad

Good Evening sir Imran Sir. I have tried with correct credentials just now sir. I think same error is reflected now also. Please resolve sir.

ERROR: C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\1. Option Chain\1. Option Chain>py “Working with Option chain.py”
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2026-01-20.csv
Got the instrument file
Exception at getting Expiry list as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘806’: ‘Data APIs not Subscribed’}, ‘status’: ‘failed’}}
Unable to find the correct Expiry for NIFTY
Traceback (most recent call last):
File “C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\1. Option Chain\1. Option Chain\Working with Option chain.py”, line 9, in
atm, option_chain = tsl.get_option_chain(Underlying=“NIFTY”, exchange=“INDEX”, expiry=0, num_strikes=10)
^^^^^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable NoneType object

Hi @Vasili_Prasad ,

Itseems you have not subscribed to Data APIs, subscribe and retry.
Exception at getting Expiry list as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘806’: ‘Data APIs not Subscribed’}, ‘status’: ‘failed’}}

Sir ji I need data nifty future data with oi how should use code right now I’m using tsl.get intraday _data but oi data is not available please help

Hi @mukesh_malviya ,

We are working on updating our codebase for the same. We will release it soon.

@Imran Sir,

I ama also getting same error since 3 days while 2 of our login credentials are correct and DATA api will expire next months.

I have also post same error, pleae guide us.

Thanks and Regards
Krishna

Hi @Krushna_Rout ,

Do share what error are you getting . If it is regarding ‘Data APIs not Subscribed’ share the screenshot of web terminal where Data API’s have been subscribed.

Very Good Morning sir. I have subscribed for ‘Data APIs’. Today just now, I have tried with the file ‘full_market_depth.py’ file after getting the access token and inserted into the code. In line no.15 & 21, I have modified the code to 23rd Jan’26 date and tried. It failed then I have tried with the code to the original 09 dec 25900 and tried. Unfortunately I am getting the similar error both the times. ERROR is: C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\3. Full Market Depth\3. Full market Depth>py full_market_depth.py
Codebase Version 3.1.0
-----Logged into Dhan-----
This BOT Is Picking New File From Dhan
Got the instrument file

Exception in get_market_depth_client: Check the Tradingsymbol or Exchange.
Failed to start depth for NIFTY 23 JAN 25050 CALL (NFO)
Traceback (most recent call last):
File “C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\3. Full Market Depth\3. Full market Depth\full_market_depth.py”, line 21, in
bid_df, ask_df = tsl.get_market_depth_df(depth_data[‘NIFTY 23 JAN 25050 CALL|NFO’])
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: ‘NIFTY 23 JAN 25050 CALL|NFO’

C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\3. Full Market Depth\3. Full market Depth>py full_market_depth.py
Codebase Version 3.1.0
-----Logged into Dhan-----
reading existing file all_instrument 2026-01-25.csv
Got the instrument file

Exception in get_market_depth_client: Check the Tradingsymbol or Exchange.
Failed to start depth for NIFTY 09 DEC 25900 CALL (NFO)
Traceback (most recent call last):
File “C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\3. Full Market Depth\3. Full market Depth\full_market_depth.py”, line 21, in
bid_df, ask_df = tsl.get_market_depth_df(depth_data[‘NIFTY 09 DEC 25900 CALL|NFO’])
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: ‘NIFTY 09 DEC 25900 CALL|NFO’

Please guide me sir. Thank you very much.

Just now I’ve tried once again my luck with ‘Working with Option chain.py’ file, after updating the access token. Here also I am getting the error as given here. ERROR: C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\1. Option Chain\1. Option Chain>py “Working with Option chain.py”
Codebase Version 3.1.0
-----Logged into Dhan-----
This BOT Is Picking New File From Dhan
Got the instrument file
Traceback (most recent call last):
File “C:\Users\Admin\Desktop\TRADES\Dhan Algo\11-01-2026-Option Chain-Algo Adv Stratgy\1. Option Chain\1. Option Chain\Working with Option chain.py”, line 24, in
required_strike = option_chain.loc[option_chain[‘CE LTP’] < 10, ‘Strike Price’].iloc[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File “C:\Users\Admin\AppData\Local\Programs\Python\Python314\Lib\site-packages\pandas\core\indexing.py”, line 1192, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Admin\AppData\Local\Programs\Python\Python314\Lib\site-packages\pandas\core\indexing.py”, line 1753, in _getitem_axis
self._validate_integer(key, axis)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File “C:\Users\Admin\AppData\Local\Programs\Python\Python314\Lib\site-packages\pandas\core\indexing.py”, line 1686, in _validate_integer
raise IndexError(“single positional indexer is out-of-bounds”)
IndexError: single positional indexer is out-of-bounds.

Please guide me sir. Thank you.

Sir, Thank you very much. Just now I have tried with ‘Expired Options data.py’ file. It’s very much functional sir. I am extremely Happy sir. Thank you very much once again.

Hi @Vasili_Prasad ,

Full market depth data is available only for active, valid contracts during market hours and is not available for expired contracts.

Hi Imran,
I’m backtesting a LEAPS option strategy and facing a data limitation.

On 23 Dec 2022, with NIFTY around 17,900, I wanted to short a March 2023 monthly expiry OTM Call (premium ~300–400). However, using the get_expired_option_data API, I’m not able to fetch data for such long-dated contracts. It seems the API only provides data for options within ~30–60 days to expiry.
Would really appreciate your guidance on this. Thanks!

Hi @Polimera_Sai ,

tagging @Hardik for the same.

1 Like

Hi sir, Only file in the folder “IR Backtesting.txt” is empty. Please check it sir.

Hi @Vasili_Prasad ,

Refer this below link-