Summary
Private research and trading bot. Fits an Ornstein-Uhlenbeck process on log-prices, generates z-score signals around an estimated equilibrium, sizes positions by capital tier under regime and drawdown constraints, and routes orders through Angel One SmartAPI. Identical signal logic powers backtests and live execution: what you backtest is what trades.
The problem
Most retail “systems” either over-fit on a single sample or have wildly different backtest vs live behaviour. OU-MRS treats the signal as a single function shared by backtest, walk-forward, and live execution — with risk armor that cannot be bypassed at runtime.
Architecture
- OU calibration on log-prices: drift, mean-reversion speed (theta), volatility (sigma).
- Signal: z-score around estimated equilibrium, gated by ADX regime filter.
- Sizing: capital tier (SEED → QUANT_ELITE) tunes risk-per-trade, concurrency, stop width, entry threshold.
- Execution: Angel One SmartAPI with paper-side STOP enforcement and breakeven ratchet.
- Validation: vectorised backtest, walk-forward, Monte Carlo, tearsheet metrics.
Highlights
- Symbols: BANKNIFTY, NIFTY, MIDCPNIFTY futures via Angel One SmartAPI.
- Five-layer risk armor: notional leverage cap (3.0x), dual-cap max-lots, daily loss kill switch, tight Z-stops (2.5), paper-side STOP enforcement with breakeven ratchet.
- Validation: vectorized backtest engine, walk-forward, Monte Carlo, tearsheet metrics.
- Capital tiers (SEED to QUANT_ELITE): as capital grows, risk-per-trade shrinks, concurrency grows, stops widen, entry threshold lowers (LLN smooths variance).
- Realistic Indian F&O cost model: brokerage, STT, exchange transaction, SEBI, GST, stamp duty.
What I learned
- A single signal function shared across backtest and live is non-negotiable. Two implementations always diverge.
- The kill switch should fire on un-realised P&L, not realised — by the time a realised drawdown lands, you already lost.
- Walk-forward beats a single in-sample sharpe by a wide margin. Trust the WF curve, not the headline number.
What I would do differently
- Build the cost model first. It changes which signals are even tradable in Indian F&O.
- Tier the capital ladder more finely. The jump from SEED to GROWTH was too aggressive on stop widths.