Learn Advanced Algo Trading Series | Codes | Youtube

@DhanHQ @RahulDeshpande @Tradehull_Imran @Dhan

I truly appreciate the opportunity to learn backtesting. Dhan is the only Indian broker actively guiding its clients towards the future of algorithmic trading, and it’s inspiring to see such dedication.

As traders, we also have a responsibility to put in our best individual efforts to make this initiative successful.

My plan is to go through each session carefully, bringing in real-life scenarios, challenges, and practical problems for discussion. By sharing and engaging with others, we can make our learning experience truly meaningful and worthwhile.

This way, we can ensure our learning has lasting value!

4 Likes

Hi @Dhan , @Tradehull_Imran , @RahulDeshpande

Can you please guide me how can I backtest or replay historic option chain.
I am unable to find historic options related information in instruments file

Thanks!

4 Likes

Hello @Tradehull_Imran @Dhan I am getting error with below code.

option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="NSE", expiry=1, num_strikes=10)

-> option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="NSE", expiry=0, num_strikes=10)
(Pdb++) option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="NSE", expiry=1, num_strikes=10)
Getting Error at Option Chain as 'NIFTY'

hello sir ,mujhe apne algo ke liye ek sample code chahiye jo live market ka ohlc de nifty ka… jab chahe… like 12 baje tak ka ohlc…aaj ka(live market me)

Hi @Yogesh_Luhar ,

Refer the below code:

option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="INDEX", expiry=0, num_strikes=10)

hi @AJIT_KUDALE ,

You can click on Download anyway and download it.

Hi @Kuldeep_Khaladkar ,

The code seems to be right. You can use regular modify order format.
Refer the below link for more details:
Dhan-Tradehull · PyPI

Hi @Ganesh ,

You can get ohlc data using the below code:

historical_data = tsl.get_historical_data(Underlying='NIFTY', exchange='INDEX', timeframe='1')
  • timeframe (str): The timeframe for the data. It can be:
    • ‘1’ for 1-minute candles
    • ‘5’ for 5-minute candles
    • ‘15’ for 15-minute candles
    • ‘25’ for 25-minute candles
    • ‘60’ for 60-minute candles
    • ‘DAY’ for daily candles

Sir is se to ek din phle ka data aata h na… aaj ka nhn aata hai…

latest_data = tsl.get_historical_data(tradingsymbol=‘NIFTY’, exchange=‘INDEX’, timeframe=“DAY”)
last_candle = latest_data.iloc[-1]
print(last_candle)

output
reading existing file all_instrument 2025-04-21.csv
Got the instrument file
open 23401.85
high 23872.35
low 23298.55
close 23851.65
volume 0.0
timestamp 2025-04-17
Name: 246, dtype: object

aaj 21 april hai…

codebase bi update hua h kya sir g… apne pas Dhan_Tradehull_V2.py hai…aapne jo code share kiya h usme underlying keyword ko error bata rha hai…

@RahulDeshpande said that
Much more are coming :wink::smile:

Now I truly understand what you meant.
Genuinely, hats off to you — absolutely brilliant! @Dhan

Just we are missing you sir @Tradehull_Imran

same question

Hi so we no longer need the “Dhan_TradeHull_V2” file to be added by us manually to the codebase and imported? I dont see it anywhere in these files.
My tsl.cancel_all_orders function as per previous setup is not at all working so checked to upgrade the dhan_tradehull library and it latest but I see now the file “Dhan_TradeHull_V2” is not even there. PLease confirm asap.

Now ‘Dhan_TradeHull_V2’ is updated a new version, and seems the name remains as just ‘Dhan_TradeHull’.

Very Good Morning Sir, Can you please clarify the difference in data between NSE & Dhan, with regards to the OptionChain.
NSE Gives OI & Change in OI both for Call & Put Strikes.
But at Dhan, I have noticed that it gives OI & Change in OI% for Call & Put Strikes.

I am not able to correlate the Change in OI% (Dhan) with Change in OI (NSE), of course this is not % Based.

But even that Percentage Provided on Dhan Platform is not understandable.
Can you please clarify this sir.

VBR Prasad

Mr utpal can you plz confirm that to punch order we donot need to subscribe api data but for making algo and fetching live and historical data we need to subscribe.

hello imran sir, kisi video me apne scanner banana sikhya tha… like filter stock with rsi and ema …uska link chahiye. and sir g wo aap link ki charcha krte the na jispe indicators lagane ke methods define hai, us link ko bi menton kar dena… ya sir g sambhav ho to ek dummy code de dijiye stock filter ka like apne pas nifty ka sare stocks ki watchlist hai aur uske ltp pe filter lagana hai ki kaun jo daliye pe 20 ema se upar hai kaun niche and fir rsi kiska 70 ke upar hai aur 30 ke niche … aur fir jo result hai usko ek csv me save kar dena hai…

@Tradehull_Imran @RahulDeshpande

Respected Sir,
I have been trying to finalize and deploy my trading algorithm, but I’m facing difficulties specifically with understanding the trigger price and placing the appropriate orders (be it BO, normal entry, SL, or target orders). Despite watching your videos multiple times and raising queries here, I’m still unable to execute it correctly.

I was attempting to implement an HFT strategy on Nifty and its underlying options, but the concept of the trigger price and how it works with SL orders is confusing. When I try using the normal entry with SL and target orders, the SL order seems to act like a fresh sell order, which appears to require additional margins. I’m not entirely sure about the actual rules around this, even though I’ve tried following the NSE’s 0.05 rule.

Since I cannot place SL orders correctly, my system is not yet fully automated. I’m truly interested in learning and implementing this properly. If there’s any support service available, I’m willing to pay a nominal fee (similar to a YouTube membership, in the range of per query ₹150–₹200), but I’m currently unable to afford the full course fee of ₹70,000.