// case study · Automation · Python · Zerodha
Algo Trading Bot: a Python bot that places orders on two hedged Zerodha accounts automatically
A Python bot that trades Nifty and VIX-based setups through the Zerodha API on two hedged accounts.
The problem
Placing the same trades by hand every morning, then watching them and reacting when one goes against you, is slow and easy to get wrong under pressure. I wanted the routine, and the hedge that follows a losing trade, to happen by rule instead of by reflex.
What I built
The bot is a Python service built on FastAPI that talks to the Zerodha Kite Connect API:
- Morning orders. It places the day’s buy or sell order on the first account for Nifty and VIX-based setups.
- Automatic hedge. When the first account’s trade goes into loss, it places the matching order on the second account without anyone clicking.
- Guard rails. Order checks, logging of every action and clear stop conditions, so it never acts on a stale or half-failed state.
The same pattern, a schedule plus rules plus an API, is what I build for clients who want repetitive work automated.
Tech stack
- Python
- FastAPI
- Zerodha Kite Connect
- Scheduling
- Risk rules
The result
The routine now runs by rule. I treat it as an automation case study: it shows how I wire a broker API, a scheduler and risk rules together. Automated trading carries real risk and none of this is financial advice or a promise of returns.
