Backtest Multi-Leg Options Spreads (Iron Condor, Calendar, Diagonal) With AI Agents

Use the Quant agent to backtest iron condors, calendar spreads, diagonal spreads, and short straddles on NIFTY and BANKNIFTY weekly options.

optionsiron condorcalendar spreaddiagonalbankniftyai agentsoptions backtesting

Multi-leg options spreads are where backtesting frameworks usually break. Strike selection drifts, expiries roll, and the chain reconstruction has to be historically accurate. alphabench's Quant agent handles all of this through the backtest_spread tool, with full historical NFO chain data and per-leg expiry control.

This guide shows how to backtest the four most common spreads on NIFTY and BANKNIFTY.

1. Short iron condor on BANKNIFTY weeklies

"Backtest a short iron condor on BANKNIFTY weekly options. Sell ATM call and ATM put, buy 200 points OTM wings on each side. Enter at 9:30 every Tuesday morning, exit at 15:15 on Thursday expiry. Test the last 2 years."

The Quant agent compiles four legs, looks up actual NFO instruments via the database (no symbol guessing), forward-fills any short data gaps, and runs the backtest in RaptorBT. You'll get a per-trade table with realised P&L, max profit/loss, and net Greeks at entry.

2. Calendar spread on NIFTY

"Backtest a long calendar spread on NIFTY: sell weekly ATM call, buy monthly ATM call, roll weekly leg every Thursday. Test the last 12 months."

The agent supports per-leg expiry — weekly and monthly legs are tracked independently and the roll is handled automatically.

3. Diagonal spread

"Backtest a long diagonal: buy the weekly ATM put, sell next week's 100-point OTM put, on NIFTY for the last 6 months."

Diagonals combine calendar (different expiries) with vertical (different strikes) behaviour. The agent computes the net debit/credit at entry and tracks both legs to expiry.

4. ATM short straddle with adaptive switching

For the most common Indian options strategy — short ATM straddle — try the adaptive runner instead of the static one:

"Backtest an adaptive ATM straddle sell on BANKNIFTY weeklies. Switch to a 10%-OTM short strangle on days when implied volatility is in the top quartile."

The Quant agent routes this to backtest_adaptive_strategy, which can switch between spread structures day-by-day based on signals you specify.

5. Reading the results

Spread backtests return:

  • Per-trade P&L with each leg's contribution
  • Net Greeks at entry (delta, gamma, theta, vega) so you can audit the exposure
  • Max favourable / adverse excursion of the position
  • Realised volatility vs implied at entry when relevant
  • Breakeven points for each trade

6. Diagnose losing months

If the equity curve has a bad cluster, hand it to the Diagnostician:

"Diagnose the worst three losing trades from this iron condor backtest."

See Diagnose losing trades for the forensic workflow.