Iron Condor

Strategy 7 — Iron Condor Fallback (IC)

The Iron Condor is a fallback strategy for range-bound NIFTY weeks. It is deliberately lower priority than the calendar strategies: run_scan_cycle() scans IC only after DC, DCS, DCS_SKEW, and DDC have had their chance, and only if none of those strategies is open.

Go-live safety IC_DRY_RUN=True seeds the SQLite records only on first run. Runtime state is changed with /shadow IC, /promote IC, and /revert IC. Shadow/live IC entries buy hedge legs first, then sell short legs, and require available balance ≥ IC_MAX_MARGIN × 1.10.

Structure

SELL
Short PE
ATM - 300
credit leg
BUY
Long PE
ATM - 500
downside hedge
SELL
Short CE
ATM + 300
credit leg
BUY
Long CE
ATM + 500
upside hedge

Entry Filters

FilterDefaultReason
Fallback guardNo open DC, DCS, DCS_SKEW, or DDCIC is only a fallback when the primary dry-run options strategies are idle.
Duplicate guardNo open ICPrevents stacking identical fallback risk.
DTEIC_DTE_MIN=3 to IC_DTE_MAX=7Uses the near weekly expiry window.
ATM IVIC_MIN_IV=18% to IC_MAX_IV=26%Needs enough credit, but avoids high-event-vol regimes.
Realized rangeToday's range ≤ IC_MAX_RANGE_PCT × near ATM straddleOnly enter if observed intraday movement is narrow versus priced range.
Minimum creditNet credit ≥ IC_MIN_CREDIT_PCT × wing width × lotRejects thin credit where defined risk is not compensated.
Margin capMax loss ≤ IC_MAX_MARGINPer-lot capital guard before simulated entry is persisted.
Regime gate (OR)AI market_view permits OR same-cycle TA snapshot regime is RANGEIC sells range/vol — it enters when either confirmation is present. It is blocked only when a gate has an opinion and neither permits; with no AI view and no TA snapshot it fails open. The TA snapshot is refreshed before the IC scan each cycle (_refresh_cycle_ta_snapshot), so a strict AI veto (blocked_by_ai) can still be rescued by a confirmed RANGE regime.

Signal + Persistence

# Scanner signal
short_ce = ATM + IC_OTM_DISTANCE_PTS
long_ce  = short_ce + IC_WING_WIDTH_PTS
short_pe = ATM - IC_OTM_DISTANCE_PTS
long_pe  = short_pe - IC_WING_WIDTH_PTS

net_credit = (short_ce_ltp + short_pe_ltp - long_ce_ltp - long_pe_ltp) * lot_size
wing_width = IC_WING_WIDTH_PTS * lot_size
max_loss   = wing_width - net_credit

# Persisted open trade keys include all 4 ids/strikes, entry_credit, wing_width, max_loss, entry_time, lots.

Exit Rules

ConditionActionP&L Source
Credit captured ≥ IC_PROFIT_TARGET_PCT × entry creditClose all 4 legsLive LTP simulation
Current loss ≥ IC_STOP_LOSS_CREDIT_X × entry creditClose all 4 legsLive LTP simulation
Expiry day at/after 15:00 IST, or expiry already passedTime stopLive LTP if available, otherwise entry credit fallback
current_credit_value = (short_ce_ltp + short_pe_ltp - long_ce_ltp - long_pe_ltp) * lot_size
current_pnl          = entry_credit - current_credit_value

# Positive P&L means the IC credit spread has decayed since entry.