File size: 7,017 Bytes
5a168ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Options Scanner — MCP Server

[![Built with ML Intern](https://huggingface.co/datasets/huggingface/badges/resolve/main/built-with-ml-intern-sm.svg)](https://hf.co/chat?mode=ml-intern)

The [`options_scanner`](https://huggingface.co/datasets/Reckless88/options-scanner) engine
wrapped as a **modular MCP server**: any MCP client (Claude Desktop, Claude Code,
Hermes, etc.) can scan markets, build multi-leg options structures, and manage
positions with rolling mechanics through natural language.

**Read-only by design.** The server reads market data and computes structures.
It never places orders, touches a broker, or writes anywhere on disk.

---

## Tools (7)

| Tool | What it does |
|---|---|
| `scan_universe` | Run the full multi-strategy scanner over the auto universe (large caps + high-IV names + ETFs) or a custom symbol list. Returns ranked candidates with credit/debit, max profit/loss, POP, breakevens, legs. |
| `scan_symbol` | Build every eligible strategy on one ticker with full risk reports and gate reasons. |
| `build_strategy` | Build one named family on a symbol: `vertical`, `calendar`, `diagonal`, `butterfly`, `iron_condor`, `ratio_backspread`, `jade_lizard`, `double_diagonal`, `short_straddle`, `short_strangle`. |
| `chain_summary` | Quick read on a ticker: spot, 30-day ATM IV, front-expiry liquidity score, next earnings, quote count. |
| `check_position` | Position management with rolling mechanics: take-profit (50% of credit), stop (2× credit), roll out / out-and-down / out-and-up at 21 DTE or when a short strike's delta hits 0.40. |
| `list_strategies` | All 10 strategy families + default risk parameters and roll rules. |
| `list_watchlists` | Built-in watchlist pools and the auto universe. |

Every tool takes an optional `provider` argument (`tradier` | `alpaca` | `polygon` | `yfinance`); empty = auto-pick from environment keys.

## Install

```bash
git clone https://huggingface.co/datasets/Reckless88/options-scanner
cd options-scanner
pip install "mcp>=1.0" yfinance          # yfinance only needed for the fallback provider
export TRADIER_API_KEY=...               # optional; see providers below
python mcp_server.py                     # stdio transport — this is what clients launch
```

**Data providers** (auto-selected in this order):

| Env var(s) | Feed |
|---|---|
| `TRADIER_API_KEY` | Tradier real-time (verified: full chains, OI; greeks computed from quotes) |
| `ALPACA_KEY_ID` + `ALPACA_SECRET_KEY` | Alpaca real-time IEX (thin quotes, no OI) |
| `POLYGON_API_KEY` | Polygon real-time snapshot |
| none | Yahoo Finance, ~15-min delayed |

No keys? The server still works on the delayed yfinance feed.

---

## Import into Claude Desktop

1. Install the repo somewhere stable, e.g. `~/tools/options-scanner`, and put your key in the file (see security note).
2. Edit the config file:
   - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
   - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
3. Add:

```json
{
  "mcpServers": {
    "options-scanner": {
      "command": "python3",
      "args": ["/Users/YOU/tools/options-scanner/mcp_server.py"],
      "env": { "TRADIER_API_KEY": "your-key-here" }
    }
  }
}
```

4. Restart Claude Desktop. A tools icon appears; ask *"Scan SPY, QQQ and NVDA for defined-risk strategies"* or *"Build an iron condor on COIN"*.

**Claude Code** (CLI) — one command instead of the JSON:

```bash
claude mcp add options-scanner \
  --env TRADIER_API_KEY=your-key-here \
  -- python3 /Users/YOU/tools/options-scanner/mcp_server.py
```

---

## Import into Hermes

**Option A — one command:**

```bash
hermes mcp add options-scanner \
  --command python3 \
  --args /path/to/options-scanner/mcp_server.py \
  --env TRADIER_API_KEY=your-key-here
```

**Option B — edit `~/.hermes/config.yaml`:**

```yaml
mcp_servers:
  options-scanner:
    command: "python3"
    args: ["/path/to/options-scanner/mcp_server.py"]
    env:
      TRADIER_API_KEY: "your-key-here"
    enabled: true
    timeout: 120
```

Then start `hermes chat`. Hermes discovers the tools with an `mcp_options-scanner_*` prefix and you ask the same natural-language questions.

---

## Security notes

- API keys go in **client config env blocks**, never in the source. The repo contains no keys.
- The server is read-only: it has no broker credentials, no order paths, no disk writes.
- `allow_undefined_risk=True` unblocks naked straddles/strangles in *analysis only* — they are always flagged `UNDEFINED RISK` in the output.

---

## Evaluation of the underlying engine (honest assessment)

**Verified working** (tested against live Tradier and Alpaca feeds, Oct 27 2026):
- Full scan of 40 underlyings in ~40 s → 84 candidates across 13 strategy families, 0 feed errors.
- Payoff-grid risk metrics with back-month legs priced via Black-Scholes; max loss floored at the debit paid.
- POP by numeric integration of each structure's actual payoff over the lognormal distribution (catches debit-spread downside breakevens the naive short-strike method misses).
- Gates: per-leg liquidity, bid-ask vs mid, finite max loss, buying-power cap, earnings-window avoidance, strike proximity (refuses to fake structures on sparse feeds).
- MCP protocol end-to-end with the official `mcp` SDK 2.3.0: 7 tools discovered and called over stdio.

**Known limitations — read before trading anything it prints:**

1. **Pricing model is approximate.** Back-month legs are valued with flat entry IV — no vol skew, no term structure, no IV crush modeling. Calendar/diagonal max-loss figures are lower bounds on reality, not guarantees.
2. **POP is model POP.** Lognormal with ATM IV. Fat tails, realized-vs-implied gaps, and event risk are not in it.
3. **No backtest.** The 0–100 composite score (expectancy 45% / POP 25% / credit efficiency 20% / liquidity 10%) is a heuristic ranking, *not* validated expected performance.
4. **Fills at mid, zero slippage.** Real 4-leg structures fill worse than mid, especially outside regular hours.
5. **No early-assignment modeling** (ITM short puts/calls near ex-dividend dates) and no pin-risk discussion for short strikes at expiry.
6. **No persistence or scheduling.** Positions are passed per call; the server holds no state and runs nothing on a timer — automation loops live in the client or a cron job.
7. **Feed-dependent coverage.** Tradier's free tier returned no greeks (computed per-quote instead); Alpaca IEX lacks open interest and has thin quotes on some names (guards drop them). Earnings dates come from a yfinance fallback that intermittently 404s — the earnings gate can be blind.
8. **Curated universe, not all of Nasdaq/NYSE.** The auto pool is ~40 liquid names ranked by outcome; it is not a full-market sweep.

**Bottom line:** a solid idea-generation and risk-sizing tool for defined-risk options structures, with honest gating and verified real-time data plumbing. Treat every number as an estimate to be checked in your broker before ordering.