Learn Algo Trading with Python | Codes | Youtube Series

Hi @Prabodh_Negi ,

Do run the command on the cmd terminal -

pip install dhanhq==2.2.0
pip install Dhan-Tradehull==3.2.2

Hello Dhan team and @Tradehull_Imran,

I am extensively using Dhan for investing and trading.

It is a great initiative from Dhan, Imran sir and the API team.

I am referring following playlist for learning algotrading using python “Algo Trading with Python FREE Masterclass”

As the playlist is dated 4 Oct 2024, there might be upgrades in the versions of python as well as the libraries referred in Episode-2.

Currently the version of python installed on my Laptop is 3.13.2. Is this version ok or I have to install another version?

Please guide me from where I can install the latest version of all the softwares libraries for learning.

Hi @anjalik ,

Refer this video for the updated version of that old playlists -

Hello imran sir , I am getting error in dhan cloud

I am using same code of your ai algo master classes so code haven’t any issues

But env variables & depencies has issue

Can you give me that both part properly like this

Dependencies:

Tradehull ==1.xx.xx

Dhanhq ==1.xx.xx

(Give me all like this like scipy photo etc….. give in == format not >= format)

Env variables:

(Tell we write client id , access token, totp , pin direct or in ““ )

CLIENT_ID : “1234XXXXX" OR 1234XXXX

ACCESS _TOKEN : “ABCDXYSXXXX” OR ABCXYZXXXXX

TOTP : “XYZ……A.” OR XYZ…….A

( Tell me this part plz )

Hi @Harshil_Jariwala ,

Refer this link to setup the DHan Tradehull codebase -

Dhan Cloud Tradehull Codebase Setup

@Tradehull_Imran

गुरुदेव के चरणों में सादर प्रणाम।

सर हमने एडवांस्ड रिस्क एंड रिटर्न मेट्रिक्स को ऐड किया है जिसका कुछ ऐसा रिजल्ट आया है

https://claude.ai/public/artifacts/92c119f0-c706-4de9-8ad4-d559ea55f2e1

https://claude.ai/public/artifacts/92c119f0-c706-4de9-8ad4-d559ea55f2e1

1 Like

@Tradehull_Imran Hello Sir,

Watched your recent video with Dhan, can you please tell how or from where to download Grillme Skill & PonyTail Skills?

Hi @Yash_Thakkar ,

Refer the following steps and try to use it -

1. Open Cursor’s terminal

In Cursor:

Terminal → New Terminal

2. Install GrillMe globally for Cursor

Run:

npx skills@latest add mattpocock/skills --skill grill-me --agent cursor --global --copy --yes

3. Install Ponytail globally for Cursor

Run:

npx skills@latest add DietrichGebert/ponytail --skill "*" --agent cursor --global --copy --yes

Hi MadeForTrade Team,

I would like to request the original Pine Script source code for your Volatility Index indicator.

My intention is to integrate the indicator’s logic with the Dhan API for automated trading. Since Dhan API requires implementing the indicator logic externally, having access to the original Pine Script would help me accurately replicate the calculations and use the signals in my trading system.

If sharing the complete source code isn’t possible, could you please provide the calculation logic or an official TradingView Pine Script version?

Thank you for your consideration.

Getting this error when running in server:
[2026-07-26 18:59:54 IST] ==================== SCRIPT OUTPUT START ====================

[2026-07-26 18:59:55 IST] Codebase Version 3.3.1

[2026-07-26 18:59:55 IST] Traceback (most recent call last):

[2026-07-26 18:59:55 IST] File “/tmp/script.py”, line 13, in

[2026-07-26 18:59:55 IST] tsl = Tradehull(ClientCode=client_code, mode=“pin_totp”, pin=pin, totp_secret=totp_secret)

[2026-07-26 18:59:55 IST] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[2026-07-26 18:59:55 IST] File “/tmp/pip/lib/python3.11/site-packages/Dhan_Tradehull/Dhan_Tradehull.py”, line 47, in _init_

[2026-07-26 18:59:55 IST] os.makedirs(‘Dependencies/log_files’)

[2026-07-26 18:59:55 IST] File “”, line 215, in makedirs

[2026-07-26 18:59:55 IST] File “”, line 225, in makedirs

[2026-07-26 18:59:55 IST] PermissionError: [Errno 13] Permission denied: ‘Dependencies’

[2026-07-26 18:59:55 IST] ==================== SCRIPT OUTPUT END ====================

[2026-07-26 18:59:55 IST] Execution failed with exit code: 1

**›**Execution completed.
Dependencies:
pandas>=2.2.0
dhanhq>=2.2.0
Dhan-Tradehull>=3.3.2
pyotp==2.9.0
rich
TA-Lib

Also scipy is not getting added to the requirements due to some validation error.

Hi @Sushanth_SV ,

Refer this link to setup the DHan Tradehull codebase -

Dhan Cloud Tradehull Codebase Setup

1 Like

Hi Sir,

This is my question:

Code is:

from Dhan_Tradehull import Tradehull
import pandas as pd
import talib
from rich import print
import time

client_code  = ""
pin          = ""
totp_secret  = ""
tsl          = Tradehull(ClientCode=client_code, mode="pin_totp", pin=pin, totp_secret=totp_secret)

watchlist    = ["BEL", "TATACONSUM", "BAJAJ-AUTO", "NESTLEIND", "BAJFINANCE", "HINDALCO", "NTPC", "HDFCLIFE", "SBILIFE", "HINDUNILVR", "MARUTI", "ITC", "TMPV", "ADANIPORTS", "DRREDDY", "WIPRO", "ONGC", "SBIN", "EICHERMOT", "COALINDIA", "BAJAJFINSV", "MAXHEALTH", "KOTAKBANK", "APOLLOHOSP", "CIPLA", "JSWSTEEL", "HCLTECH", "TCS", "INDIGO", "BHARTIARTL", "ETERNAL", "LT", "SHRIRAMFIN", "GRASIM", "AXISBANK", "POWERGRID", "ADANIENT", "TECHM", "ICICIBANK", "JIOFIN", "TATASTEEL", "TITAN", "INFY", "TRENT", "ASIANPAINT", "ULTRACEMCO", "HDFCBANK", "RELIANCE", "M&M", "SUNPHARMA"]


print(tsl.get_ohlc_data(names=watchlist))

Error is:

File “C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py”, line 106, in extract_access_token
raise Exception(f"Access token not found in response: {resp}")
Exception: Access token not found in response: {‘message’: ‘Invalid TOTP’, ‘status’: ‘error’}Login failed. Please retry with valid credentials.
Traceback (most recent call last):
File “C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\Dhan_Tradehull\Dhan_Tradehull.py”, line 61, in init
raise Exception(“Login failed. Please retry with valid credentials.”)
Exception: Login failed. Please retry with valid credentials.
Exception at calling OHLC as ‘Tradehull’ object has no attribute ‘instrument_df’
{}

please help

Hi @Abhishek_Sharma ,

The issue appears to be caused by invalid credentials. Kindly verify the Client ID, PIN, and TOTP, and then run the code again. It should work without any errors once the correct credentials are provided.

Thank You Sir for the Reply, I will try it today.

1 Like

Hi Sir,

While deploying the code in Dhan developer and adding the dependency, system not allowing to save the version, showing the below error.

Security violation in requirements.txt: line 2: invalid package specifier ‘scipy >=1.13.0’

If I have removing the line scipy .it is allowing to save.

Hi @Manisha_Tripathy ,

Certain libraries and package versions may not be supported in Dhan Cloud due to security restrictions. Therefore, dependencies that do not meet the platform’s security requirements may be restricted during saving.

sir can provide this code?

Thank you for your response, i have checked ‘spicy=1.10.1” is allowed and saved successfully.

while running it says Codebase Version 3.3.1

Traceback (most recent call last):

File “/tmp/script.py”, line 8, in

totp_secret = {{TOTP_SECRET}}

                 ^^^^^^^^^^^

NameError: name ‘TOTP_SECRET’ is not defined

where to change, pls suggest me

Hi @Manisha_Tripathy ,

Refer this link to setup the DHan Tradehull codebase -

Dhan Cloud Tradehull Codebase Setup