Case study · Algorithmic Trading Systems
0DTE Options Automation Bot
Automated options execution robot specifically optimized for 0DTE index options on Interactive Brokers. Features multi-leg order execution, dynamic delta hedging, auto-trailing stops, and portfolio margin calculations.
- Primary Tech
- Python / RxPy
- API Integration
- IBKR TWS API
- Target Platform
- Interactive Brokers
Client work under NDA. Client names, trading data, performance figures and live screens are not shown. This page describes the problem, what we built and the technology used.
The client
A trading group trading same-day-expiry (0DTE) index options on Interactive Brokers.
The problem
A trading group wanted to automate complex 0DTE options strategies on Interactive Brokers with dynamic risk scaling.
- 0DTE positions move fast, and entering multi-leg spreads by hand was too slow.
- Legs entered one at a time left the group exposed while the other legs filled.
- Partial fills and hedging needed constant attention through the session.
- There was no check on margin before a new position was opened.
Our approach
We built an event-driven Python bot on the IBKR TWS API that enters spreads as one order, manages hedges and exits automatically, and checks margin before every trade.
How we built it
- 1
Multi-leg execution
Spreads are sent as Interactive Brokers combo orders, so the legs fill together. Partial fills are tracked and handled automatically.
- 2
Reactive core
Prices, Greeks and order updates are handled as RxPy streams, so each rule reacts the moment its inputs change.
- 3
Dynamic delta hedging
The bot watches the position's delta and hedges with the underlying when delta moves outside a set band.
- 4
Trailing stops and time exits
Stops trail the value of the spread, and every position is closed before a set cut-off time on expiry day.
- 5
Portfolio margin guard
Before each entry, the bot asks Interactive Brokers for the margin impact of the order and blocks any trade that would exceed the group's limit.
How we tested it
- Interactive Brokers paper trading account through full sessions.
- Replay of recorded option sessions with Pandas.
- Disconnection and restart tests, since TWS restarts daily.
What we delivered
- The bot deployed on the group's server, connected to their TWS or IB Gateway.
- Documentation for configuring strategies, bands and limits.
- Support after launch.
The result
The group trades its 0DTE strategies with spreads entered as one order, hedges and exits handled automatically, and a margin check before every position.
Features
- Multi-leg execution
- Dynamic delta hedging
- Trailing stop automations
- Portfolio margin guard
Technology
- Python
- IBKR TWS API
- Pandas
- RxPy
Start here