BKR-powered options chain scanner and multi-timeframe decision-support engine with Discord alerts. Manual trading only.
IBKR Options Chain Scanner - Setup Guide
๐ What You Need
- Interactive Brokers Account (Paper or Live)
- IB Gateway installed and running
- Python 3.8+ installed
- Discord Webhook URL (for alerts)
๐ Quick Start (5 Steps)
Step 1: Install Python Dependencies
Open your terminal/command prompt and run:
pip install ib_insync requests
What this does: Installs the libraries needed to connect to IBKR and send Discord messages.
Step 2: Setup IB Gateway
- Download IB Gateway from Interactive Brokers website
- Login to IB Gateway with your credentials
- Important Settings:
Screenshot reference: The settings should look like this:
[โ] Enable ActiveX and Socket Clients [โ] Read-Only API Socket port: 4002 [โ] Allow connections from localhost only
Step 3: Create Discord Webhook
- Open Discord and go to your server
- Right-click the channel where you want alerts
- Click "Edit Channel" โ "Integrations" โ "Webhooks"
- Click "New Webhook"
- Name it (e.g., "IBKR Scanner")
- Copy the Webhook URL (looks like:
https://discord.com/api/webhooks/...)
Step 4: Configure the Script
- Open
phase1chainscanner.pyin any text editor - Find the configuration section at the top (around line 20)
- Edit these values:
# REQUIRED: Add your Discord webhook URL
DISCORDWEBHOOKURL = 'https://discord.com/api/webhooks/YOURACTUALURL_HERE'
REQUIRED: Set correct IB Gateway port
IB_PORT = 4002 # Use 4002 for paper trading, 4001 for live
OPTIONAL: Adjust filters if needed
DELTA_MIN = 0.35 # Keep options with delta between 0.35-0.55
DELTA_MAX = 0.55
MAXSPREADPERCENT = 7.0 # Reject if bid-ask spread > 7%
MIN_VOLUME = 10 # Minimum daily volume
MINOPENINTEREST = 50 # Minimum open interest
SCANINTERVALSECONDS = 60 # Scan every 60 seconds
- Save the file
Step 5: Run the Scanner
- Make sure IB Gateway is running and logged in
- Open terminal in the folder containing
phase1chainscanner.py - Run:
python phase1chainscanner.py
You should see:
๐ Starting IBKR Options Scanner ๐ Symbol: SHOP ๐ฏ Delta range: 0.35 - 0.55 ๐ฐ Max spread: 7.0% ๐ Min volume: 10, Min OI: 50 โฑ๏ธ Scan interval: 60 seconds ====================================================================== ๐ Connecting to IB Gateway at 127.0.0.1:4002... โ
Connected to IBKR successfully! ๐ Starting scan for SHOP...
๐ What the Scanner Does
Real-Time Process:
- Connects to your IB Gateway (read-only, safe)
- Fetches all SHOP option contracts (calls and puts)
- Gets live market data:
- Filters options using your criteria:
- Sends qualifying options to Discord
- Repeats every 60 seconds
๐ง Configuration Explained
Delta Filter
DELTA_MIN = 0.35
DELTA_MAX = 0.55
- Delta measures how much option price moves with $1 stock move
- 0.35-0.55 is the "sweet spot" for balanced risk/reward
- Lower delta (0.35) = cheaper, further OTM
- Higher delta (0.55) = more expensive, closer to ATM
Spread Filter
MAXSPREADPERCENT = 7.0
- Spread = difference between bid and ask price
- 7% means you reject options with wide spreads
- Tight spreads = easier to enter/exit positions
- If spread > 7%, the option is rejected (not liquid enough)
Liquidity Filters
MIN_VOLUME = 10
MINOPENINTEREST = 50
- Volume = contracts traded today
- Open Interest = total open contracts
- Higher values = more liquid (easier to buy/sell)
Scan Interval
SCANINTERVALSECONDS = 60
- How often the script scans for new options
- 60 seconds = once per minute (balanced)
- Lower = more frequent updates (more API calls)
- Higher = less frequent (lighter on resources)
๐ฑ Discord Alert Format
When an option passes all filters, you'll get:
๐ฏ New Option Alert
Stock: SHOP Type: CALL Expiry: 20250221 Strike: $85.00
Pricing: โข Bid: $2.45 โข Ask: $2.60 โข Spread: 5.77%
Greeks & Volume: โข Delta: 0.452 โข Volume: 125 โข Open Interest: 450
Scanned at 2026-02-01 14:30:15
โ ๏ธ Common Issues & Solutions
Issue 1: "Failed to connect to IBKR"
Solutions:
- โ IB Gateway is running and logged in
- โ Port number matches (4002 for paper, 4001 for live)
- โ "Enable ActiveX and Socket Clients" is checked in IB settings
- โ "Read-Only API" is enabled
- Try restarting IB Gateway
Issue 2: "No option chains found for SHOP"
Solutions:
- Market might be closed (options trade 9:30 AM - 4:00 PM ET)
- Check if SHOP symbol is correct
- IB Gateway might not have data permissions for options
- Try with a different symbol (e.g., SPY, AAPL)
Issue 3: "Discord webhook failed"
Solutions:
- โ Webhook URL is correct (copied fully)
- โ Discord channel still exists
- โ Webhook wasn't deleted in Discord settings
- Test webhook manually: Visit https://discord.com/developers/docs/resources/webhook
Issue 4: Script crashes or stops
Solutions:
- Check IB Gateway didn't log out automatically
- Look at error message in terminal
- Run with debug mode: Change
LOG_LEVEL = logging.DEBUGin config - The script has auto-reconnect, but if Gateway restarts you may need to restart script
Issue 5: No alerts being sent
Possible reasons:
- No options currently meet all filter criteria (delta + spread + volume + OI)
- Options were already sent (duplicate detection working)
- Market is closed or low activity period
- Try loosening filters temporarily to test:
DELTA_MIN = 0.20 DELTA_MAX = 0.80 MAXSPREADPERCENT = 15.0 MIN_VOLUME = 5 MINOPENINTEREST = 10
๐ How to Stop the Scanner
Press Ctrl+C (or Cmd+C on Mac) in the terminal.
You'll see:
โ ๏ธ Shutdown requested by user ๐ Disconnected from IBKR ๐ Scanner stopped
๐ Performance Tips
For Better Results:
- Run during market hours (9:30 AM - 4:00 PM ET)
- Start with looser filters if testing
- Adjust scan interval based on needs
- Monitor the logs
๐ Safety Features Built-In
โ Read-only connection - Cannot place trades โ Auto-reconnect - Recovers from connection drops โ Error handling - Won't crash on bad data โ Duplicate prevention - Won't spam same option โ Rate limiting - Won't overwhelm Discord โ Market data validation - Skips incomplete data
๐ What This Script Does NOT Do
โ No trading or order placement โ No AI or machine learning โ No trading signals or recommendations โ No position management โ No P&L tracking
This is purely a data scanner and filter.
๐ฏ Next Steps (After You're Comfortable)
- Try different symbols - Edit
SYMBOL = 'SHOP'to 'SPY', 'AAPL', etc. - Adjust filters - Tune delta range, spread limits based on what you see
- Multiple instances - Run multiple scripts for different symbols
- Save to file - Modify to log results to CSV for analysis
๐ Need Help?
If something isn't working:
- Check the logs - The script prints detailed info
- Enable debug mode - Set
LOG_LEVEL = logging.DEBUG - Test IB connection - Make sure IB Gateway shows "Connected" status
- Verify Discord webhook - Send a test message using an online tool
๐ Additional Resources
- IB API Documentation: https://interactivebrokers.github.io/tws-api/
- ib_insync Documentation: https://ib-insync.readthedocs.io/
- Discord Webhooks Guide: https://discord.com/developers/docs/resources/webhook
- Interactive Brokers Gateway: https://www.interactivebrokers.com/en/trading/ibgateway-stable.php
Happy Scanning! ๐