NadirAliOfficial
optipulse-ibkr-discord-engine
Python

BKR-powered options chain scanner and multi-timeframe decision-support engine with Discord alerts. Manual trading only.

Last updated Jul 1, 2026
13
Stars
1
Forks
0
Issues
0
Stars/day
Attention Score
48
Language breakdown
Python 100.0%
โ–ธ Files click to expand
README

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:
- Go to Configure โ†’ Settings โ†’ API โ†’ Settings - โœ… Enable "Enable ActiveX and Socket Clients" - โœ… Check "Read-Only API" - Set Socket Port: - 4002 for Paper Trading (recommended for testing) - 4001 for Live Trading - โœ… Check "Allow connections from localhost only" - Click OK and restart IB Gateway

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.py in 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:
- Bid/Ask prices - Delta values - Volume & Open Interest
  • Filters options using your criteria:
- โœ… Delta between 0.35-0.55 - โœ… Spread < 7% - โœ… Volume โ‰ฅ 10 - โœ… Open Interest โ‰ฅ 50
  • 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.DEBUG in 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)
- Options have the most activity during this time - More likely to find options meeting liquidity filters
  • Start with looser filters if testing
- Lower MINVOLUME and MINOPEN_INTEREST - Increase MAXSPREADPERCENT - Once you see alerts flowing, tighten them
  • Adjust scan interval based on needs
- 30 seconds = more real-time (higher load) - 60 seconds = balanced (recommended) - 120 seconds = lighter, slower updates
  • Monitor the logs
- Green โœ… = success - Yellow โš ๏ธ = warning (non-critical) - Red โŒ = error (needs attention)

๐Ÿ”’ 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! ๐Ÿš€

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท NadirAliOfficial/optipulse-ibkr-discord-engine ยท Updated daily from GitHub