The Problem

Our iron condor scanner picked option expirations mathematically — any Friday in the 30-45 DTE window. But Alpaca doesn’t list weekly option contracts months in advance. When the scanner chose April 3, 2026 (a Friday, 39 DTE), the symbols SPY260403P00640000 didn’t exist yet.

Result: APIError: invalid legs on every scan for weeks. Zero trades executed.

Root Cause

find_expiration_date() calculated dates without querying the broker. Weekly SPY options are only listed ~2-3 weeks before expiration. Monthly options (third Fridays) are listed months ahead.

The Fix

Two-layer defense:

Layer 1 — Smart Expiry Discovery: Query Alpaca’s OptionChainRequest API for real expirations. Only return dates where contracts actually exist. Fall back to third Fridays (monthly — always listed).

Layer 2 — Symbol Validation: Before submitting any order, verify all 4 OCC symbols exist via OptionSnapshotRequest. If any symbol is missing, abort with a clear error.

Result

First autonomous trade in weeks submitted at 17:50 UTC on Feb 23, 2026. Both Scanner and Autonomous workflows green.

Lesson

Never assume financial instrument availability from date math. Always validate against the broker’s actual listings before constructing orders.


*Related: Complete Guide to AI Iron Condor Trading Our North Star Strategy*