ib_0dte_ema_vix
Find (and optionally place) the best 0DTE credit spread via the EMA + VIX/VXN strategy.
Instructions
Find (and optionally place) the best 0DTE credit spread via the EMA + VIX/VXN strategy.
Reads 30-min IB bars + the live vol index, applies the vol gate, then auto-selects bull_put or bear_call from the EMA9/EMA21 cross before ranking spreads. NDX/QQQ are gated on VXN (Nasdaq-100 vol); all other symbols on VIX. Returns success=False with a reason when a gate blocks the trade (VIX-SKIP / no-cross / EMA-Dn-no-RR / missing-bars).
Default is a bare EMA cross runnable any time of day; enable the optional confirmation gates per call. Default is a dry run — pass execute=True to place a live combo order with the automatic OCA exit bracket. Requires TWS or IB Gateway running locally.
Args: symbol: Underlying (e.g. NDX, SPX, RUT, QQQ, SPY) budget: Max capital at risk in dollars (default 50000) port: IB port (7496 for live, 7497 for paper) vix_threshold: Skip if vol index >= this. Default is per-index: VXN 35 for NDX/QQQ, VIX 20 otherwise. target_delta: Short-leg delta target (default 0.12) rr_gate: Require red→red (9:30 + 10:00 ET bars both red) to confirm a Bear Call time_gate: Require today's 9:30 + 10:00 ET bars (run at 10:30 ET+) and anchor the EMA-cross lookback to the 10:00 ET bar max_width: Cap the strike width in dollars (NDX typically 100) gex: Compute the dealer gamma-exposure profile top: Number of candidates to return (default 5) account: IBKR account for execution (required with execute when >1 managed account) execute: Place the chosen spread as a live combo order (default False = dry run) pick: 1-based rank of the candidate to execute (default 1 = best) limit_frac: Walk between the marketable combo credit (0) and mid (1.0) at execution
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gex | No | ||
| top | No | ||
| pick | No | ||
| port | No | ||
| budget | No | ||
| symbol | Yes | ||
| account | No | ||
| execute | No | ||
| rr_gate | No | ||
| max_width | No | ||
| time_gate | No | ||
| limit_frac | No | ||
| target_delta | No | ||
| vix_threshold | No |