Learn Algo Trading with Python | Codes | Youtube Series

Hi @Akshay_Bawane ,

Could you let us know which version of the Dhan-Tradehull package you’re using? Run the following command in your terminal and send us a screenshot:

pip show Dhan-Tradehull

Hi @Qaisar ,

Could you let us know which version of the Dhan-Tradehull package you’re using? Run the following command in your terminal and send us a screenshot:

pip show Dhan-Tradehull

Hi @Rajashekhar_Rangappa ,

Could you let us know which version of the Dhan-Tradehull package you’re using? Run the following command in your terminal and send us a screenshot:

pip show Dhan-Tradehull

Getting
WARNING: Package(s) not found: Dhan-Tradehull
:thinking:

Hi @rohit2312 ,

There seems to be no indentation error, rather file not found error is present.
Make sure Websocket.xlsx file is present within the same folder. Also do update to our latest codebase version 3.0.6:

  • Open Command Prompt: Press Win, type cmd, and press Enter.
  • Install Dhan-Tradehull: Run pip install Dhan-Tradehull
  • Confirm the installation by running pip show Dhan-Tradehull

Hi @anandc ,

The issue here is clearly indicated by the exchange error:

EXCH:16283: The order price is not multiple of the tick size

Use this logic to correctly determine the tick size:

df = tsl.instrument_df[
    (tsl.instrument_df['SEM_CUSTOM_SYMBOL'] == option_symbol) |
    (tsl.instrument_df['SEM_TRADING_SYMBOL'] == option_symbol)
]

if not df.empty:
    tick_size = df.iloc[-1]['SEM_TICK_SIZE']

    # Correct rounding logic
    price = round((sl_price - 0.5) / tick_size) * tick_size
    trigger_price = round(sl_price / tick_size) * tick_size

If you are still not able to understand about tick size, please kindly search using Google.

Important Update:

We noticed your dhan-tradehull version is currently 2.8. We have released version 3.0.6. Please update to the latest version to avoid encountering unwanted bugs.

Use the following command to upgrade the dhan

pip install --upgrade Dhan-Tradehull

We believe this upgrade will enhance your experience.

1 Like

Hi @Rajashekhar_Rangappa ,

Which means you have not installed our latest codebase version 3.0.6.

Do update to our latest codebase version 3.0.6:

  • Open Command Prompt: Press Win, type cmd, and press Enter.
  • Install Dhan-Tradehull: Run pip install Dhan-Tradehull
  • Confirm the installation by running pip show Dhan-Tradehull

Guide to use the updated codebase:
Video reference :

Refer the below pypi link for more details:
https://pypi.org/project/Dhan-Tradehull/

1 Like

Sure. thanks.
Is there any ALGO change required? Hope its backward compatible :sunglasses:

one more, I didn’t see the issue today coz

NIFTY 03 APR 23650 PUT got executed w/o any issue :man_shrugging:

I guess, its independent of the version.

Hi @Tradehull_Imran sir,

Mine is latest one. Yesterday, only, updated it t 3.0.6

Hi @Tradehull_Imran sir,

Thanks a lot.

1 Like

I am using Dhan Tradehull version 3.0.6…

Hi @Tradehull_Imran
Any update on this plz…

Hi @Tradehull_Imran sir,
I am trying to made a scanner. Please check my code. Indicators have been placed but i am getting the error. Please look into this

import pdb
import time
import datetime
import traceback
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
import pprint
import talib
import pandas_ta as pta
import pandas_ta as ta

client_code = “”
token_id = "
tsl = Tradehull(client_code,token_id)

watchlist = [‘ADANIPORTS’, ‘ADANIENT’, ‘SBIN’, ‘TATASTEEL’, ‘BAJAJFINSV’, ‘RELIANCE’, ‘TCS’, ‘JSWSTEEL’, ‘HCLTECH’, ‘TECHM’, ‘NTPC’]

for name in watchlist:
current_time = datetime.datetime.now()
chart = tsl.get_historical_data(tradingsymbol= name, exchange=‘NSE’, timeframe=“5”)

# pdb.set_trace()


# Calculate EMAs - 3-period EMA and 21-period EMA
chart['EMA_5'] = ta.ema(chart['close'], length=5)
chart['EMA_20'] = ta.ema(chart['close'], length=20)

# make inicators rsi
chart['rsi'] = talib.RSI(chart['close'], timeperiod=14)

# CCI Indicator
chart['CCI'] = talib.CCI(chart['high'], chart['low'], chart['close'], timeperiod=14)
# pdb.set_trace()

# completed_candle
cc = chart.iloc[-2]

# buy entry conditions
bc1 = cc['EMA_5'] > cc['EMA_20']
bc2 = cc['rsi'] > 60
bc3 = cc['CCI'] > 100

# sell entry conditions
sc1 = cc['EMA_5'] < cc['EMA_20']
sc2 = cc['rsi'] < 40
sc3 = cc['CCI'] <-100

if bc1 and bc2 and bc3:
	print("buy ", name)


if sc1 and sc2 and sc3:
	print("sell ", name)

Thank you Sir

As advised, I am able run two algo at a time.

Kindly advise, how to avoid using naked source code?

Is there any way to protect or package it.

Hi @Ganesh_Surwase,

You can protect your naked code by-

  1. Code compilation- where you can convert your python code into bytecode… so that nobody can read so no one can edit or know the logic.
  2. code obfuscation- there are libraries like pyarmor, pyobfuscate which can obfuscate or encrypt your code .
  3. You can convert it to exe.
  4. you can execute your code from secure (Cloud) server …
  5. You can also use pyarmor for hardware binding…

Just google it

HTH
Regards

1 Like

non working day it doe not work. It give this error. Try during opne market.

Hi @Tradehull_Imran or @Dhan

I have upgraded codebase to 3.0.6.
But unable to pull the ltp. PFA.

tsl         = Tradehull(client_code,token_id)

pdb.set_trace()

ltp = tsl.get_ltp_data(names = ['NIFTY 24 APR 23000 CALL', 'NIFTY 24 APR 23000 PUT', "ACC", "CIPLA"])


all_ltp_data   = tsl.get_ltp_data(names = ['NIFTY 24 APR 23000 CALL', 'NIFTY 24 APR 23000 PUT', "ACC", "CIPLA"])
acc_ltp = all_ltp_data['ACC']
pe_ltp  = all_ltp_data['NIFTY 24 APR 24000 PUT']

Another try @Tradehull_Imran

py "How to use updated codebase.py"
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-03-30.csv
Got the instrument file
[0] > d:\project\dhan\session3.1 codebase upgrade\3.1 codebase upgrade\how to use updated codebase.py(22)<module>()
-> ltp = tsl.get_ltp_data(names = ['NIFTY 24 APR 23000 CALL', 'NIFTY 24 APR 23000 PUT', "ACC", "CIPLA"])
(Pdb++) ACC
*** NameError: name 'ACC' is not defined
(Pdb++)                                                                                                                                            

Eid Mubarak Our respected @Tradehull_Imran Sir.

2 Likes