IBKR Option Auto-Lock Bot Development

Замовник: AI | Опубліковано: 29.10.2025
Бюджет: 750 $

Title: Build an “Option Auto-Lock (Trailing Profit)” bot for IBKR (Python, ib-insync) + OneDrive CSV + Telegram alerts Goal: Automate trailing take-profit for equity options at IBKR. A 24/7 headless bot tracks mark price & P/L%, stores MAX, and if price/P&L retraces by a defined STEP or Price OFFset, it submits a closing order via API (SELL MKT/REL). It also logs to CSV (OneDrive) and sends Telegram alerts. My Power BI dashboard will consume the CSV. Stack & Environment: Broker: Interactive Brokers via IB Gateway (no GUI) API: Python 3.10+, ib-insync (async tick stream) Hosting: VPS (Hetzner/Contabo/AWS) Outputs: CSV on OneDrive path (e.g., D:/OneDrive/...) Functional requirements: Position discovery: Equity options only (symbol, expiry, strike, right, qty, entry price). Lock activation: when TargetLockPct (e.g., +45%) is reached, enable trailing. Trailing logic (OR of two branches): P/L branch: Close if current P/L% ≤ (Max P/L% − TrailingStepPct). Price branch: Close if markPrice ≤ (MaxPrice − PriceOffsetUSD). Execution: Submit SELL (MKT) (or REL with sane offset). Anti-double-fill: mark position closed=true after fill. Config: global config.yaml (+ optional per-trade overrides). Alerts: Telegram (lock activated / moved / closed with reason “TrailingHit”). Logging: CSV line on lock activation and on exit. Heartbeat & fail-safe: If no ticks for 30s → send alert and do not execute. Paper→Live toggle and tests on paper first. Config example: (same YAML as above) CSV schema (trades_log.csv): TimestampUTC, Account, Broker, Symbol, Expiry, Strike, Right, Qty, Side, EntryPrice, MaxPrice, MaxPLpct, LockStartPLpct, TrailingStepPct, PriceOffsetUSD, ExitTrigger, ExitPrice, ExitPLpct, DurationSec, OrderId, OrderRef, Session Workflow: I enter trades manually in TWS/Mobile. Optional per-trade overrides in OrderRef (e.g., RG TP=60 STEP=3 OFF=0.10). Bot runs on VPS, manages exits, logs to CSV, sends Telegram alerts. Acceptance criteria: 100% working trailing on paper (demo with QQQ/TSLA). Decision latency ≤ 1s. Robust (no duplicate SELLs, handles IB Gateway reconnects). Clean code (README, .env, systemd/pm2 service, deployment steps). Nice-to-have: Mini web panel (Flask/FastAPI) to view open positions and active locks. Tastytrade API support in the same architecture (same CSV schema).