APEX OPTIONS FLOW SCANNER
=========================
Step-by-Step Setup Guide
Coronet Berkley Code Library


WHAT IS THIS?
=============
This is a program that watches the options market for you.
It scans 18 stocks and ETFs every 30 seconds and tells you
when something unusual is happening with options trading.

It has two parts:
  Part 1: A Python program that runs on your computer
  Part 2: A thinkorswim indicator you add to your charts

You can use one or both. Part 1 is the main scanner.
Part 2 is a visual helper for your charts.


================================================================
PART 1: PYTHON SCANNER - SETUP
================================================================

STEP 1: INSTALL PYTHON
----------------------
If you don't already have Python on your computer:

  1. Go to https://www.python.org/downloads/
  2. Click the big yellow "Download Python" button
  3. Run the installer
  4. IMPORTANT: Check the box that says "Add Python to PATH"
  5. Click "Install Now"
  6. Wait for it to finish
  7. Click "Close"

To verify it worked:
  1. Open Command Prompt (Windows) or Terminal (Mac)
     - Windows: Press Windows key, type "cmd", press Enter
     - Mac: Press Cmd+Space, type "terminal", press Enter
  2. Type: python --version
  3. Press Enter
  4. You should see something like "Python 3.12.x"
  5. If you see an error, try: python3 --version


STEP 2: INSTALL REQUIRED PACKAGES
----------------------------------
Still in Command Prompt / Terminal, type these commands
one at a time. Press Enter after each one. Wait for each
to finish before typing the next.

  pip install schwab-py
  pip install python-dotenv
  pip install httpx

If "pip" doesn't work, try "pip3" instead:

  pip3 install schwab-py
  pip3 install python-dotenv
  pip3 install httpx

You should see "Successfully installed" messages.
If you see errors, try running Command Prompt as Administrator
(right-click Command Prompt > Run as Administrator).


STEP 3: GET YOUR SCHWAB API CREDENTIALS
-----------------------------------------
You need two things from Schwab: an App Key and an App Secret.
Here's how to get them:

  1. Go to https://developer.schwab.com
  2. Click "Create Account" (this is separate from your
     regular Schwab brokerage account)
  3. Fill in your information and create the account
  4. Verify your email address
  5. Log in to the Developer Portal
  6. Click "Dashboard" in the top menu
  7. Click "Create App"
  8. Fill in:
     - App Name: "APEX Scanner" (or whatever you want)
     - API Products: Check "Market Data Production"
     - Callback URL: https://127.0.0.1
  9. Accept the terms
  10. Click Submit
  11. Wait 1-3 business days for Schwab to approve your app
  12. Once approved, go back to Dashboard
  13. Click on your app name
  14. You will see your App Key and App Secret
  15. Copy both of these somewhere safe (you'll need them next)


STEP 4: SET UP THE SCANNER FILES
---------------------------------
  1. Find the folder where you unzipped the download
  2. You should see these files:
     - config.env
     - flow_auth.py
     - flow_fetcher.py
     - flow_detector.py
     - flow_logger.py
     - flow_scanner.py
     - APEX_FlowOverlay.ts
     - README.txt (this file)

  3. Open config.env in Notepad (right-click > Open with > Notepad)

  4. Find these two lines near the top:
     SCHWAB_APP_KEY=YOUR_APP_KEY_HERE
     SCHWAB_APP_SECRET=YOUR_APP_SECRET_HERE

  5. Replace YOUR_APP_KEY_HERE with your actual App Key
     Replace YOUR_APP_SECRET_HERE with your actual App Secret

     Example (these are fake keys):
     SCHWAB_APP_KEY=abc123def456
     SCHWAB_APP_SECRET=xyz789ghi012

  6. Save the file (Ctrl+S)
  7. Close Notepad

  DO NOT share your App Key or App Secret with anyone.
  DO NOT post them online or in screenshots.


STEP 5: RUN THE SCANNER FOR THE FIRST TIME
--------------------------------------------
  1. Open Command Prompt / Terminal

  2. Navigate to the folder where your scanner files are.
     For example, if you put them on your Desktop:
     
     Windows:
       cd Desktop\apex-options-flow-scanner
     
     Mac:
       cd ~/Desktop/apex-options-flow-scanner

  3. Type this command and press Enter:
     
     python flow_scanner.py --once

  4. THE FIRST TIME ONLY: A browser window will open.
     - Log in with your regular Schwab brokerage credentials
       (NOT your Developer Portal credentials)
     - Select which brokerage account to give API access to
     - You'll be redirected to a page that says "can't be reached"
     - THIS IS NORMAL. Don't close it.
     - Copy the ENTIRE URL from your browser's address bar
     - Go back to Command Prompt / Terminal
     - Paste the URL and press Enter

  5. The scanner will authenticate and start scanning.
     You should see colorful output showing:
     - Which symbols are being scanned
     - Any unusual options activity detected
     - Premium flow summaries
     - IV analysis

  6. After the scan completes, it will say "Single scan complete."
     Your results are also saved in a folder called "scan_logs"


STEP 6: RUN THE SCANNER CONTINUOUSLY
--------------------------------------
Once you've done the first-time authentication (Step 5),
future runs are simpler:

  1. Open Command Prompt / Terminal
  2. Navigate to your scanner folder (same as Step 5)
  3. Type: python flow_scanner.py
  4. Press Enter
  5. The scanner will run every 30 seconds during market hours
     (9:30 AM - 4:00 PM Eastern)
  6. To stop the scanner: Press Ctrl+C

Other ways to run it:

  See more detail:
    python flow_scanner.py --verbose

  Run one scan and stop:
    python flow_scanner.py --once

  Run one scan with extra detail:
    python flow_scanner.py --once --verbose


STEP 7: CUSTOMIZE YOUR WATCHLIST (OPTIONAL)
---------------------------------------------
The default watchlist scans these 18 symbols:
  SPY, QQQ, AAPL, MSFT, NVDA, AMZN, TSLA, META,
  GOOGL, AMD, XOM, CVX, GLD, SLV, USO, TLT, IWM, DIA

To change the watchlist:
  1. Open config.env in Notepad
  2. Find the WATCHLIST line
  3. Change the symbols (comma-separated, no spaces)
     Example: WATCHLIST=SPY,AAPL,TSLA,XOM
  4. Save the file

Other things you can customize in config.env:
  - VOLUME_OI_THRESHOLD: How high Vol/OI must be to flag
    (default 2.0, higher = fewer but stronger signals)
  - MIN_VOLUME: Minimum contracts traded to qualify
    (default 500, higher = filters out small trades)
  - MAX_DTE: Maximum days to expiration to scan
    (default 60, lower = focus on near-term only)
  - SCAN_INTERVAL: Seconds between scans
    (default 30, don't go below 15)


================================================================
PART 2: THINKSCRIPT INDICATOR - SETUP
================================================================

This adds options flow information directly to your
thinkorswim charts.

STEP 1: OPEN THINKORSWIM
  1. Open the thinkorswim application
  2. Go to the Charts tab

STEP 2: CREATE THE STUDY
  1. Click the beaker icon (Studies) near the top of the chart
  2. Click "Edit Studies"
  3. In the bottom left, click "Create"
  4. A code editor opens
  5. Select ALL the default code and DELETE it
  6. Open the file APEX_FlowOverlay.ts in Notepad
  7. Select ALL the code (Ctrl+A)
  8. Copy it (Ctrl+C)
  9. Go back to thinkorswim and PASTE (Ctrl+V)
  10. In the "Name" field at the top, type: APEX_FlowOverlay
  11. Click OK

STEP 3: ADD TO YOUR CHART
  1. Click the beaker icon again
  2. In the search box, type "APEX"
  3. You should see "APEX_FlowOverlay" in the list
  4. Double-click it to add it to your chart
  5. Click Apply
  6. Click OK

STEP 4: WHAT YOU'LL SEE
  Labels will appear at the top of your chart:
  - IV%: Shows where current implied volatility ranks
    in its 1-year history (higher = options are expensive)
  - IV: Current implied volatility as a percentage
  - IV Trend: Whether IV is rising or falling
  - P/C: Put/Call volume ratio for the day
  - Opt/Stk Vol: How active options are vs stock trading
  - OPTIONS FLOW: Overall status (NORMAL / ACTIVE / ELEVATED)

  Background shading:
  - Faint RED background: IV is in the top 30% of its range
  - Faint GREEN background: IV is in the bottom 30% of its range


================================================================
UNDERSTANDING THE SCANNER OUTPUT
================================================================

FLOW SCORES
  Each symbol gets a score from 0-10+
  0-2:  Normal. Nothing unusual happening.
  3-4:  Elevated. Worth keeping an eye on.
  5-7:  Significant. Multiple signals firing.
  8+:   Exceptional. Very unusual activity.

UNUSUAL VOLUME
  Shows individual option contracts where today's
  trading volume is much higher than the number of
  existing contracts (open interest). This suggests
  new positions are being opened, not old ones closed.

PREMIUM FLOW
  Shows the total dollar amount being spent on calls
  vs puts for each symbol.
  - Net positive (BULLISH): More money on calls
  - Net negative (BEARISH): More money on puts
  NOTE: Put buying can also be hedging, not bearish bets.

IV ANOMALIES
  - SKEW INVERTED: Calls are more expensive than puts
    (unusual; normally puts are more expensive)
  - TERM INVERTED: Near-term options are more expensive
    than far-term (suggests an expected catalyst soon)


================================================================
TROUBLESHOOTING
================================================================

"schwab-py not found" or "No module named schwab"
  Run: pip install schwab-py
  If that doesn't work: pip3 install schwab-py

"Authentication failed"
  - Make sure your App Key and App Secret are correct
  - Make sure your app is in "Approved" status (not "Pending")
  - Make sure your callback URL in config.env matches exactly
    what you entered in the Developer Portal

"No data returned"
  - The market might be closed (scanner only works 9:30-4:00 ET)
  - Your API access might not be active yet
  - Try: python flow_scanner.py --once --verbose for more detail

Scanner seems slow
  - Each scan fetches data for all watchlist symbols
  - 18 symbols takes about 10-15 seconds
  - Reduce your watchlist to scan faster

Token expired (after 7 days)
  - Delete the file called "token.json" in your scanner folder
  - Run the scanner again
  - It will open the browser for re-authentication
  - Follow the same steps as the first-time setup (Step 5)


================================================================
IMPORTANT DISCLAIMER
================================================================

This scanner is for EDUCATIONAL PURPOSES ONLY.

Unusual options activity does NOT guarantee a stock will move.
It does NOT tell you which direction a stock will move.
It does NOT constitute investment advice.

Institutional options flow can represent:
  - Hedging against existing positions
  - Portfolio rebalancing
  - Complex multi-leg strategies you can't see from chain data
  - Market-making activity

Do NOT treat flow signals as buy or sell recommendations.
Do NOT risk money you cannot afford to lose.

Coronet Berkley does not provide investment advice,
recommend specific securities, or manage client funds.

(c) 2026 Coronet Berkley. All rights reserved.
