ib_stop_loss
Manage downside stop-loss orders for PMCC, LEAPS, and stock positions. Use dry-run or execute conditional stops via IB Gateway, with configurable stop percentage and price mode.
Instructions
Analyze and manage downside stop-loss orders for PMCC, naked LEAPS, and stock positions.
Default mode is dry-run — no orders are placed unless execute=True. Stop price = basis × (1 - stop_pct/100). Basis is max(current_mid, avg_cost) normally; current_mid only when forced=True (can lower existing stops). In execute mode: orphan SL_FALL_ orders are cancelled, then new conditional stop orders are placed. PMCC stops use combo BAG orders (atomic LEAPS + shorts). Requires TWS or IB Gateway running locally.
Args: port: IB port (7496 for live, 7497 for paper) account: Specific account ID (optional) symbols: Comma-separated symbols to filter (optional, e.g. 'NVDA,QQQ') stop_pct: Loss % that triggers exit (default 40) short_near_strike_pct: Alert when spot is within this % of short strike (default 5) price_mode: Option pricing — 'mid' (bid+ask)/2 or 'last' execute: Place conditional stop-loss orders (default False = dry-run) forced: Use current mid as basis, can lower existing stops (requires execute=True)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | No | ||
| forced | No | ||
| account | No | ||
| execute | No | ||
| symbols | No | ||
| stop_pct | No | ||
| price_mode | No | mid | |
| short_near_strike_pct | No |