ib-stop-loss
Downside stop-loss management for PMCC, naked LEAPS, and stock positions in IB. Computes stop prices, detects alerts, and places conditional combo orders. Dry-run by default. Requires TWS or IB Gateway running locally.
Install / Use
npx skills add staskh/trading_skills --skill ib-stop-lossInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of ib-stop-loss
ib-stop-loss scores 89/100 on our quality scale, 1729th of 4,716 Development & Engineering skills we index (top 37%).
Its SKILL.md is 6.7 KB long, well organised into 15 sections with 4 code examples: a thorough specification that gives an agent plenty to work with.
It has 369 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so ib-stop-loss is actively maintained.
- Our last check on 2026-10-31 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit β read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-05. Automated pattern scan on 2026-10-05. It catches known dangerous patterns, not every risk β read a skill before letting an agent act on it.
ib-stop-loss compared with similar skills
All 4 of these similar skills score higher than ib-stop-loss; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| ib-stop-loss (this skill)by staskh | 89 | 369 | 2mo ago | SKILL.md |
| taste-skillby Leonxlnx | 100 | 118.9k | 11d ago | CLAUDE.md |
| hyperframesby heygen-com | 100 | 87.1k | today | CLAUDE.md |
| ai-job-searchby ai-job-search-dev | 100 | 72.6k | today | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 47.5k | 5d ago | CLAUDE.md |
Frequently asked questions
- How do I install ib-stop-loss?
- Run
npx skills add staskh/trading_skills --skill ib-stop-loss. The install tabs above show the steps for each supported agent. - Which AI agents does ib-stop-loss work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is ib-stop-loss safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is ib-stop-loss still maintained?
- The repository was last updated about 2 months ago, so ib-stop-loss is actively maintained.
Skill content
View source on GitHubname: ib-stop-loss description: Downside stop-loss management for PMCC, naked LEAPS, and stock positions in IB. Computes stop prices, detects alerts, and places conditional combo orders. Dry-run by default. Requires TWS or IB Gateway running locally. dependencies: ["trading-skills"]
IB Stop-Loss Manager
Analyzes PMCC (diagonal call spread), naked LEAPS, and stock positions in the IB portfolio and manages conditional stop-loss orders.
Default mode is dry-run β no orders are placed unless --execute is in the request.
IB Connection
TWS or IB Gateway must be running locally with API enabled:
- Paper trading β port 7497
- Live trading β port 7496
IB_PORTenv var β default port when--portis omitted (e.g.IB_PORT=4001for a Gateway container). Precedence:--portflag >IB_PORT> built-in default. Set it in the shell or a.envfile.
Port fallback: If the configured port fails, automatically retry on the other port. If the retry succeeds, save to memory which account type worked (live/paper) and reuse it for all IB skill calls in this and future sessions β until the user explicitly asks for the other account. If both ports fail, ask the user to verify that TWS or IB Gateway is running with API access enabled.
Instructions
Step 1: Run the script
Dry-run (default β no orders placed):
uv run python .claude/skills/ib-stop-loss/scripts/stop_loss.py
Execute (cancel orphan orders + place SL_ conditional orders):
uv run python .claude/skills/ib-stop-loss/scripts/stop_loss.py --execute
Execute forced (basis = current mid price, can lower existing stops):
uv run python .claude/skills/ib-stop-loss/scripts/stop_loss.py --execute --forced
Step 2: Format the report
Format JSON output as a markdown report with four sections:
Section 1: Alert Soon
List symbols in alert_soon prominently β these are past the early-warning threshold.
Section 2: Existing Conditional Orders
Show all_conditional_orders.module (SL_ orders) and all_conditional_orders.manual (manually placed).
If orphan_orders is non-empty, warn that these were cancelled (execute mode) or need manual cancellation (dry-run).
Section 3: Positions
For each entry in positions, show a table:
| Field | Value | |---|---| | Symbol | NVDA β pmcc (3 contracts) | | Spot | $219.05 | | LEAPS | 200C 20270115 Β· avg cost $44.27 Β· current $44.23 Β· basis $44.27 | | Stop price | $22.14 (40% stop) β action: place_new | | LEAPS loss | 0.1% | | Shorts | 235C 20260515 Β· received $0.61 Β· current $0.56 Β· 9.5% decayed |
Show preserve_existing when a more-protective stop already exists.
Show overwrite (red) when forced=true lowers an existing stop.
Section 4: Alerts
Group alerts by symbol. Types:
| Type | Meaning |
|---|---|
| leaps_early_warning | LEAPS down β₯ stop_pct/2% from basis |
| short_premium_decay | 90%+ of short premium captured β close or roll |
| short_near_strike | Spot at/above or within X% of short strike |
Step 3: Report to user
- State dry-run vs execute mode prominently.
- Lead with
alert_soonsymbols. - For each position: show stop action and current loss %.
- Show alerts section last.
Arguments
| Flag | Default | Description |
|------|---------|-------------|
| --port | 7497 | IB Gateway/TWS port |
| --account | all | Specific account ID |
| --symbols | all | Analyze only these symbols |
| --legs | none | Specific option legs: SYMBOL:STRIKE[C\|P]:EXPIRY (e.g. IBKR:70C:20270115 IBKR:100C:20260918). Right defaults to C. Takes precedence over --symbols. Use when multiple PMCC/LEAPS coexist on the same symbol and only one pairing should get a stop. |
| --stop-pct | 40 | Loss % that triggers exit |
| --short-near-strike-pct | 5 | Near-strike alert threshold |
| --price-mode | mid | Option pricing: mid or last |
| --execute | off | Cancel orphans + place SL_ orders |
| --forced | off | Use current mid as basis (requires --execute) |
JSON Output Structure
{
"generated_at": "2026-05-12 10:00 ET",
"dry_run": true,
"forced": false,
"stop_pct": 40.0,
"short_near_strike_pct": 5.0,
"accounts": ["U1234567"],
"symbols_filter": null,
"all_conditional_orders": {"module": [], "manual": []},
"orphan_orders": [],
"alert_soon": ["PFE"],
"positions": [
{
"symbol": "NVDA",
"type": "pmcc",
"account": "U1234567",
"qty": 3,
"underlying_price": 219.05,
"leaps": {
"strike": 200.0, "expiry": "20270115", "avg_cost": 44.27,
"current_price": 44.23, "stop_basis": 44.27,
"stop_price": 22.14, "loss_pct": 0.1
},
"shorts": [
{"strike": 235.0, "expiry": "20260515",
"premium_received": 0.61, "current_price": 0.56, "decay_pct": 9.5}
],
"stop_loss": {"stop_price": 22.14, "action": "place_new", "existing_stop": null},
"alert_soon": false,
"alerts": []
},
{
"symbol": "AAPL",
"type": "stock",
"account": "U1234567",
"qty": 100,
"underlying_price": 189.50,
"stock": {
"avg_cost": 175.00, "stop_basis": 189.50,
"stop_price": 94.75, "loss_pct": 0.0
},
"stop_loss": {"stop_price": 94.75, "action": "place_new", "existing_stop": null},
"alert_soon": false,
"alerts": []
}
]
}
Key Fields
alert_soonβ top-level list of symbols where loss β₯ stop_pct/2%position.typeβpmcc|leaps|stockstop_loss.actionβplace_new|preserve_existing|overwritestop_loss.existing_stopβ price of the existing SL_FALL_ order if present- For PMCC: stop order is a single combo (BAG) order closing LEAPS + all shorts atomically
- In execute mode: orphan SL_ orders (no matching position) are cancelled first
Order Identification
SL_FALL_{SYM}_{STRIKE}_{EXPIRY}β options (PMCC or naked LEAPS)SL_FALL_{SYM}_STKβ stock positions
Architecture
All analytics live in src/trading_skills/broker/stop_loss.py:
Analytics (no IBKR β testable in isolation):
calc_stop_basisβ max(mid, avg_cost) normally; current_mid if forcedcalc_stop_priceβ basis Γ (1 - stop_pct/100)calc_short_premium_decay_pctβ % of short premium capturedidentify_positionsβ classify normalized positions into pmcc/leaps/stockbuild_position_analysisβ full per-position output dictdetect_orphan_ordersβ SL_FALL_ orders for gone positionssummarize_all_conditional_ordersβ splits IB orders into module vs manual
Data layer (IBKR):
get_stop_loss_dataβ main entry point_cancel_orphan_ordersβ cancel stale SL_ orders_place_combo_stop_orderβ BAG order for PMCC (atomic LEAPS + shorts)_place_simple_stop_orderβ single order for naked LEAPS or stock_execute_position_stopβ dispatch per position type
Related Skills
taste-skill
118.9kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
hyperframes
87.1kAI video you can actually edit. HyperFrames is a free, open-source AI video editor. Describe any video and get a real project you can change down to the frame.
ai-job-search
72.6kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
47.5kA visual, example-driven guide to Claude Code β from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit β see the Safety scan above for what the skill file itself contains.
