Calendar Spread

Strategy 2 — Calendar Spread EXECUTION DISABLED

Disabled as of April 2026. Budget 2026 raised futures STT to 0.05% on the sell side (up from 0.02%). A single round-trip (2 sell legs) costs ~₹1,591 in STT alone per lot at current NIFTY levels (~₹15.9L turnover per leg), vs a typical gross profit of ~₹500/lot at a 2σ entry. Break-even would require a 6.3σ event — essentially never. The scanner still runs and logs signals for monitoring, but execute_calendar_spread() is never called. Re-enable if STT is reduced or a viable entry threshold is identified.

How it works

Tracks the spread between NIFTY near-month and far-month futures. When the spread deviates significantly from its historical mean, the bot bets on mean reversion.

# Example reading
Near month futures  = 24,220
Far  month futures  = 24,351
Spread              = 131.50

# From last 20 samples
Mean   = 126.55
Std    = 6.36
Z-score = (131.50 − 126.55) / 6.36 = 0.78  → not enough, skip

# Entry threshold: |Z| > 2.0
if z_score > +2.0: SHORT spread (SELL far, BUY near)
if z_score < -2.0: LONG  spread (BUY far, SELL near)

# Exit threshold: |Z| ≤ 0.5
if abs(z_score) <= 0.5: close position, profit captured
Contract Roll On the last Thursday of each month, the near-month contract expires. _resolve_futures_ids() detects this via a changed near_id and clears spread history — old contract history is meaningless for the new pair. The scanner pauses for ~20 samples before resuming.