Query Interactive Brokers Gateway for stock quotes and options chains via CLI.
Use when the user asks to:
- Get current stock quotes from Interactive Brokers
- Query options chains (puts/calls) for a specific stock
- Filter options by delta, volume, open interest, or moneyness
- Find option opportunities matching specific criteria
- Check real-time market data via IB Gateway
- IB Gateway running and accessible (local, k8s, or remote)
- Python 3.10+ with
ib_insyncinstalled - Network access to IB Gateway (default port: 4001 for paper, 4002 for live)
See INSTALL.md for detailed setup instructions.
The tool can be installed as:
- System-wide CLI:
ib-options - Direct Python script:
python3 ib-options.py - Wrapper with venv: Custom wrapper script (recommended)
# Stock quote
ib-options SYMBOL --quote
# Options chain
ib-options SYMBOL --chain --right [P|C]
# Combined
ib-options SYMBOL --quote --chain --right P--host HOST # IB Gateway host (default: localhost or check user's setup)
--port PORT # Port: 4001=paper, 4002=live (default: 4001)
--client-id ID # Client ID (default: random to avoid conflicts)Note: Check the user's environment for the actual gateway host and port. Common setups:
- Local:
localhostor127.0.0.1 - Kubernetes: Service IP or DNS name
- Remote: Specific IP address
--right [P|C] # P=Put, C=Call (default: P)
--expiration DATE # Specific expiration (YYYYMMDD format)
--min-delta FLOAT # Minimum delta (absolute value)
--max-delta FLOAT # Maximum delta (absolute value)
--min-volume INT # Minimum daily volume
--min-oi INT # Minimum open interest
--otm-only # Only out-of-the-money options
--itm-only # Only in-the-money optionsib-options MSFT --quote# OTM puts with delta 0.20-0.35, decent volume
ib-options MSFT --chain --right P \
--min-delta 0.20 --max-delta 0.35 \
--otm-only --min-volume 100 --min-oi 500# March 20, 2026 puts
ib-options AAPL --chain --right P --expiration 20260320for ticker in MSFT AAPL NVDA AMZN; do
echo "=== $ticker ==="
ib-options $ticker --chain --right P --min-delta 0.25 --otm-only
done- Paper account (port 4001): Limited options data, many strikes unavailable
- Live account (port 4002): Full options data, requires active session + 2FA
Gateway management depends on the user's setup:
Kubernetes (k8s):
kubectl get pods -l app=ib-gateway # Check status
kubectl scale deployment ib-gateway --replicas=1 # StartSystemd (Linux service):
systemctl status ib-gateway # Check status
systemctl start ib-gateway # Start serviceDocker:
docker ps | grep ib-gateway # Check status
docker start ib-gateway # Start containerManual: Check if IB Gateway application is running on the system.
The tool uses random client IDs by default. If you get "client id already in use" errors, the tool will auto-retry with a different ID.
📊 MSFT Quote
Last: $401.88
Bid: $401.80
Ask: $402.14
Close: $401.84
Volume: 567
Exp DTE Strike Type Money% Bid Ask Last Vol OI Delta IV
--------------------------------------------------------------------------------------------------------------
20260320 45 $385.00 P -6.00% $5.70 $5.85 $5.78 1,899 7,391 -0.3486 42.02%
20260320 45 $380.00 P -7.50% $4.40 $4.60 $4.50 1,143 2,524 -0.2233 41.50%
❌ Failed to connect to IB Gateway at 192.168.11.206:4001
Fix: Check gateway is running and port is correct.
Cause: Paper trading account has limited options data. Fix: Use live account (port 4002) or reduce filters.
Cause: Strike/expiration combination doesn't exist or isn't available. Fix: Use broader search or check available expirations.
Use this tool to:
- Validate opportunities from external screeners (Barchart, ThinkorSwim, etc.)
- Get real-time Greeks and pricing before trades
- Check actual bid-ask spreads to assess liquidity
- Monitor existing positions
- Compare options across different symbols or expirations
Check the user's environment for actual file locations. Common patterns:
- Main script:
ib-options.py(in project/trading directory) - CLI wrapper: System PATH or
~/bin/directory - Python venv: Isolated in project directory (recommended)
- Skill docs: In skills directory or alongside script
Consult INSTALL.md for the specific installation used.
- Check if IB Gateway is running (method depends on user's setup: k8s, systemd, manual)
- Verify connection details (host, port) from user's environment
- Paper trading (4001) has limited options data - suggest live (4002) for comprehensive chains
- Use filters to narrow results (delta, volume, OI) - makes output more useful
- Suggest specific expirations when user mentions dates or timeframes
- For options sellers: filter by OTM and appropriate delta ranges
- For options buyers: filter by ITM or specific strikes
- Options Selling: Query OTM puts/calls with conservative delta (0.20-0.35)
- Options Buying: Query specific strikes and expirations
- Market Analysis: Scan multiple tickers for comparison
- Pre-trade Validation: Check real-time pricing before executing
- Connection failures → Check gateway status
- No options found → May need live connection or broader filters
- "Security definition not found" → Strike/expiration doesn't exist or unavailable
User: "Check MSFT options for selling puts"
AI Actions:
1. Verify gateway is running (method depends on setup)
2. Get current price: ib-options MSFT --quote
3. Query put chain with filters:
ib-options MSFT --chain --right P --min-delta 0.20 --max-delta 0.35 --otm-only
4. Present results with analysis
User: "What about the March 20 expiration specifically?"
AI Action:
ib-options MSFT --chain --right P --expiration 20260320 --min-delta 0.20 --max-delta 0.35
User: "Show me AAPL call options for next month"
AI Actions:
1. Get current price: ib-options AAPL --quote
2. Query call chain:
ib-options AAPL --chain --right C --min-volume 100
3. Filter and explain key strikes
User: "What's the $240 strike look like?"
AI Action: Filter output for $240 strike from previous results or re-query with expiration
User: "Compare put opportunities across MSFT, AAPL, GOOGL"
AI Action: Loop through symbols with consistent filters:
for ticker in MSFT AAPL GOOGL; do
ib-options $ticker --chain --right P --min-delta 0.25 --otm-only
done
The venv and dependencies are isolated in ~/clawd/trading/. To update:
cd ~/clawd/trading
source venv/bin/activate
pip install --upgrade ib_insync- Read-only connection to IB Gateway
- No order placement capability
- Unique client IDs prevent conflicts
- Connection automatically disconnects after query