Learn Algo Trading with Python | Codes | Youtube Series

This one

Hi @Praveen_Shanbhog

Use this link,
Also we have upgraded from python 3.8 to python 3.12 files for which are in this link

Also do watch this video for the updated codebase usage

Hello Imran,

I am currently at the same video. However, to learn Python I previously installed Python 3.13.7 and brackets to write code. And I tried to install the required libraries from the drive link as the post said “We have updated our codebase to align with the latest dhanhq library. To use this version, Python 3.10 or higher is required.

However, the code is leading to the following error:

"Checking Python version: was

ERROR: Python version mismatch. This wheel requires Python 3.12.x

Waiting for 16 seconds, press a key to continue …"

How should I proceed from here? Can I use the current version and install libraries in a different way? Or should I uninstall and install accordingly to the drive links? I also tried to refer to the link “Dhan-Tradehull 3.2.1”, but dint know, how to proceed from here.

Also, so far, I have used brackets text editor for writing the python code for small projects, should I switch to Sublime Text?

Thank you.

Hi @vishnu_kolipaka ,

You can use Python 3.13.7 and install the required libraries accordingly.
Alternatively, refer to the provided link and install Python 3.12 using the .bat file available in the drive.

For writing Python code, you can use either Sublime Text or the Cursor app.

Thanks Imran,

I’m new to installing libraries. Could you share links/steps for required ones with Python 3.13.7?

Will it cause compatibility issues with the YouTube series code?

Hi @vishnu_kolipaka

Better is to uninstall python 3.13.7 as this verison does not support talib library which is necessary for creating indicators. Thus the ERROR: Python version mismatch. This wheel requires Python 3.12.x

Step1 : Uninstall python 3.13.7

Step2: Install python 3.12 with its libraries , for detailed steps see this link

Step3: For IDE with first preference use Cursor it has good AI support.

Let me know if this fixes it

1 Like

1 Like

Nifty Midcap Select

SYMBOL=MIDCPNIFTY
OPT_EXCHANGE=NFO
EXPIRY=MONTHLY
LOT_SIZE=120
SPOT_EXCHANGE=IDX_I

SPOT_SECURITY_ID= ?

MIDCPNIFTY SECURITY ID = ?

@dhanpy Read here.

1 Like

MIDCPNIFTY SECURITY ID = Not show

\Nifty_Midcap_v1>PY main.py2026-03-27 19:15:31,068 - TradingBot - ERROR - SPOT_SECURITY_ID not set in .env. Cannot fetch spot.2026-03-27 19:15:33,570 - TradingBot - INFO - Starting cycle

Serving Flask app ‘main’

Debug mode: offWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

Running on all addresses (0.0.0.0)

Running on http://127.0.0.1:5002Press CTRL+C to quit2026-03-27 19:15:34,738 - TradingBot - INFO - Bot started. Waiting for market open

@dhanpy Find the “token” id from the csv file and update your .env file with that.

import os
from dotenv import load_dotenv
from dhanhq import dhanhq

load_dotenv()
client = dhanhq(os.getenv(“DHAN_CLIENT_ID”), os.getenv(“DHAN_ACCESS_TOKEN”))

Fetch security list for index segment

try:
securities = client.fetch_security_list(“IDX_I”)

Print the first few to see structure

print(“Number of securities:”, len(securities))

Find MIDCPNIFTY

for sec in securities:
if sec.get(“SEM_TRADING_SYMBOL”) == “MIDCPNIFTY”:
print(“Found spot index:”, sec)
print(“Security ID:”, sec.get(“SEM_SMST_SECURITY_ID”))
break
except Exception as e:
print(“Error:”, e)

out put : \Dhan Institution Full System\Nifty_Midcap_v1>py test_option_chain.py
Expiries: {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘814’: ‘Invalid Request’}, ‘status’: ‘failed’}}