IBKR 0-DTE Options Engine
A multi-process 0-DTE index-options day-trading system for Interactive Brokers — from pattern detection to a flattened book, fully hands-free.
Client engagement — source code stays private. Shown: architecture, flows and UI.
Built for Interactive Brokers, this engine day-trades zero- and one-day-to-expiry index options completely hands-free. It generates its own signals: live tick data is resampled into candles, and when a configurable run of same-direction candles holds the right body levels, the system fades the move — buying puts into strength, calls into weakness — on SPY, QQQ, SPX, NDX and more. A parallel build trades options on futures across eleven products, from ES and NQ to crude and gold.
The strategy layer goes far beyond one pattern. EMA-alignment and RSI gates filter entries per side, an early-entry mode takes a partial position mid-candle when the move oversizes, VWAP standard-deviation bands trigger their own entries, and a directional variant trades with the trend instead of against it. Roughly 160 parameters per preset make every rule — bull and bear independently — tunable without touching code.
Architecturally it's a small distributed system on one machine: a desktop control center launches one shared market-data node per symbol and one isolated process per strategy. Tick streams fan out to every bot over authenticated local IPC, so any number of strategies run off a single data subscription — sidestepping broker market-data limits entirely.
Exits are layered: four laddered take-profit levels with partial sells, a trailing stop that arms after the first target, hard, timeout and rejection stops, optional averaging-in, a daily profit circuit breaker, and a forced flatten at 15:59 ET. A bundled backtester replays the exact same strategy modules over historical option chains, so what was tested is — line for line — what trades.
System architecture
The modules that make it up, and how data flows between them.
PyQt5 desktop · launches & supervises
Same modules · historical chains
1 / symbol · 500k-tick ring buffer · IPC
1 process / strategy · own broker session
Singleton · daily CSV journals
Hover a module to trace what it feeds.
Trade flow
One session, end to end — from launch to the end-of-day flatten.
- 1
Launch
A preset is loaded and paper or live selected; a data node spins up per symbol and one worker process per strategy, start-staggered to avoid broker pacing collisions.
- 2
Session bootstrap
Each worker qualifies its contracts, pulls ten days of history to warm up indicators, loads the option chains, snapshots the account balance and precomputes the day's strike ladders.
- 3
Live bars
The tick stream is resampled into candles at the configured timeframe; VWAP, EMAs and RSI are computed only when their rules are switched on.
- 4
Signal scan on every candle close
Pattern fadeA run of same-direction candles holds the body-percentage rule and the EMA / RSI gates pass — trade against the move.
DirectionalThe next candle opens beyond the prior body level — trade with the trend, under its own targets and stops.
Early entryAn oversized live candle or a VWAP-band cross triggers a partial position ahead of confirmation, merged in once the full pattern completes.
- 5
Risk sizing
Quantity comes from account balance times the current half-hour allocation — thirteen time-slot buckets per side — and the trade is skipped if the daily profit target is already hit or the clock is outside the trade window.
- 6
Contract selection
Same-day expiry before 12:30 ET, next-day after; nearest strike plus a configurable offset, with an at-the-money fallback when no match exists.
- 7
Smart execution
Limit order at bid or ask with a timed wait; partial fills are cancelled — with the fill-during-cancel race handled — and chased with IBKR's Adaptive Algo at a capped price, recording a weighted-average entry.
- 8
Position management
Every tick: averaging-in checks, hard stop on premium, timeout stop on time-in-trade, a trailing stop that arms after the first target, and a rejection stop if price re-crosses the trigger level.
- 9
Laddered exits
Four retracement-based take-profit levels sell off configured slices of the position; early-entry legs at other strikes are unwound proportionally alongside.
- 10
End of day
At 15:59 ET everything is flattened, P&L is computed multiplier- and commission-aware, and the trade ships to the logger's daily journal.
Engineering highlights
The details that keep it alive with real money on the line.
Shared data-node pattern
One market-data subscription per symbol fans out to any number of strategy processes over authenticated IPC — index-based incremental reads mean no bot ever misses or duplicates a tick.
Index feed synthesis
Cash indices don't stream trades, so the data node synthesizes a tick stream from bid/ask midpoints — the strategy code never knows the difference.
Partial-fill recovery
Cancel with race handling, then an Adaptive-Algo chase order with capped aggression — entries resolve to a clean weighted-average price instead of dangling.
Backtest / live parity
The identical condition modules drive the live engine and the historical backtester — strategy changes are tested and deployed as the same code.
Time-of-day risk
Thirteen half-hour sizing buckets per side, a daily profit circuit breaker and a forced end-of-day flatten — exposure follows the clock, not just the signal.
Event-driven broker layer
Raw TWS API with explicit timeouts on every request, a clientId allocation scheme across bots and data nodes, and staggered startup to stay clear of pacing violations.
Under the hood
The stack, and the system in numbers.