Systematic Execution on DhanHQ API: Managing Decoupled Stop-Losses & VPS Latency for Nifty Options

Hi everyone :waving_hand:

Wanted to share some architectural notes on building automated execution for Nifty option selling using DhanHQ API v2 on a Linux VPS.

One of the biggest challenges retail traders face is order execution drag and mutual leg stops:

  1. Decoupled Leg Stops: If one option leg hits a stop-loss during sudden volatility, squaring off the entire basket often cuts winners prematurely. Decoupling the short leg and letting the opposite leg + protective hedge run keeps positive expectancy.
  2. Risk Floors: Rather than static targets, locking in a guaranteed profit floor (+4 pts after hitting +10 pts) prevents winning sessions from turning into losses.
  3. Execution Latency: Running an async Python bridge directly on an isolated Linux VPS keeps order dispatch under 30ms with zero reliance on local laptop internet or browser tabs.

Curious to know how others here on Dhan are structuring their multi-leg option stops and VPS watchdog daemons. Happy to discuss and share code patterns!

1 Like

Hi @AlgoBridge
These are nice notes, Thanks for sharing

Thanks Imran! Appreciate the feedback. Big fan of the educational work you do with Tradehull and Dhan for the algo community.

Handling execution latency and risk automation on Python bridges has been a great learning curve. Looking forward to exchanging more notes with the community here!

1 Like

Here is the live terminal monitor showing October’s 7-session execution ledger (+₹43,875 on 4 lots) with automated risk floors running on our VPS.

algobridge_live_terminal

1 Like