Agent skill

Ib Trailing Stop

by staskh in staskh/trading_skills

Server-side trailing stop management for stocks and naked LEAPS in IB.

MITAuto-check: notesBackend & APIs

Install Ib Trailing Stop

skills CLI
$ npx skills add staskh/trading_skills --skill ib-trailing-stop -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install staskh/trading_skills ib-trailing-stop --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/staskh/trading_skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/ib-trailing-stop .claude/skills/ib-trailing-stop && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ib-trailing-stop
GitHub stars
374
Token cost
~1.6k tokens
SKILL.md length
663 words
Files
2 (incl. scripts)
Skills in repo
28
Repo updated
First seen
Licence
MIT

At a glance

Server-side trailing stop management for stocks and naked LEAPS in IB.

  • Works in 3 steps: Run the script → Format the report → Report to user
  • Tasks that involve Backend development
  • SKILL.md covers IB Connection, Instructions, Arguments and JSON Output Structure, plus 3 more sections
  • Runs Python scripts from its folder; calls uv

What it does

Ib Trailing Stop is an agent skill from staskh/trading_skills. Server-side trailing stop management for stocks and naked LEAPS in IB. Places native TRAIL orders that auto-ratchet the stop as price climbs. Dry-run by default. Requires TWS or IB Gateway running locally.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including scripts (for example `scripts/trailing_stop.py`).

It sits in Backend & APIs, covering Backend development. The repository describes itself as: Claude powered advisor system for option traders. The licence is MIT.

When your agent uses it

  • Tasks that involve Backend development

Example prompts

  • “/ib-trailing-stop”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Run the script
  2. Format the report
  3. Report to user

What it can do on your machine

Read from SKILL.md and the folder at commit b71a74f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • uv

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Ib Trailing Stop loads about 1.6k tokens when it runs. Until then it costs about 56 tokens; SKILL.md has 663 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~56
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:22
    lt-in default. Set it in the shell or a `.env` file.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from staskh/trading_skills at commit b71a74f, republished under its MIT licence (© staskh). 663 words, ~1,613 tokens.

Download SKILL.mdSave it as .claude/skills/ib-trailing-stop/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
ib-trailing-stop
description
Server-side trailing stop management for stocks and naked LEAPS in IB. Places native TRAIL orders that auto-ratchet the stop as price climbs. Dry-run by default. Requires TWS or IB Gateway running locally.
dependencies
trading-skills

IB Trailing Stop Manager

Places IB native TRAIL orders against stocks and naked LEAPS in the portfolio. IB auto-adjusts the stop trigger as the price climbs and locks it as price falls.

PMCC positions are intentionally excluded — use ib-stop-loss for those (a standalone trailing stop on the PMCC long leg would break the hedge at trigger).

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_PORT env var — default port when --port is omitted (e.g. IB_PORT=4001 for a Gateway container). Precedence: --port flag > IB_PORT > built-in default. Set it in the shell or a .env file.

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):

bash
uv run python .claude/skills/ib-trailing-stop/scripts/trailing_stop.py --symbols JOBY --trail-pct 20

Execute (cancel orphan TS_ orders + place new TS_ TRAIL orders):

bash
uv run python .claude/skills/ib-trailing-stop/scripts/trailing_stop.py --symbols JOBY --trail-pct 20 --execute

Execute forced (cancel + replace existing TS_ orders with current parameters):

bash
uv run python .claude/skills/ib-trailing-stop/scripts/trailing_stop.py --execute --forced
Step 2: Format the report

Format JSON output as a markdown report with three sections:

Section 1: Existing TRAIL Orders

Show all_trail_orders.module (TS_ orders) and all_trail_orders.manual (manually placed). If orphan_orders is non-empty, warn that these were cancelled (execute mode) or need manual cancellation (dry-run).

Section 2: Positions

For each entry in positions, show a table:

FieldValue
SymbolJOBY — stock (1000 shares)
Spot$7.50
Reference$7.50 (max of current $7.50, avg cost $5.00)
Trail params20% (initial stop $6.00) → action: place_new
Existing trailnone

For LEAPS rows, also show the option leg (strike/expiry) and current option mark.

action values:

  • place_new — no existing TS_ order; one will be created in execute mode
  • preserve_existing — TS_ already in place; left alone (IB has been tracking the high)
  • overwrite — --forced is on; existing TS_ will be cancelled and replaced
Section 3: Order Results (execute mode only)

Per-position result with order_id and order_ref.

Step 3: Report to user
  • State dry-run vs execute mode prominently.
  • Lead with positions that have action: place_new (these are about to get a new TRAIL).
  • Call out preserve_existing separately so user knows nothing changed.
  • Show existing trail details (current trail_stop_price) so user knows where IB has trailed to.
Show full SKILL.md (247 more words)Show less

Arguments

FlagDefaultDescription
--port7497IB Gateway/TWS port
--accountallSpecific account ID
--symbolsallAnalyze only these symbols
--trail-pct20Trail amount as percentage of reference
--trail-amt—Trail amount in dollars (mutually exclusive with --trail-pct)
--price-modemidOption pricing: mid or last (LEAPS only)
--executeoffCancel orphans + place TS_ TRAIL orders
--forcedoffCancel and replace existing TS_ orders (requires --execute)

JSON Output Structure

json
{
  "generated_at": "2026-05-29 10:00 ET",
  "data_delay": "real-time",
  "dry_run": true,
  "forced": false,
  "trail_pct": 20.0,
  "trail_amt": null,
  "accounts": ["U1234567"],
  "symbols_filter": ["JOBY"],
  "all_trail_orders": {"module": [], "manual": []},
  "orphan_orders": [],
  "positions": [
    {
      "symbol": "JOBY",
      "type": "stock",
      "account": "U1234567",
      "qty": 1000,
      "underlying_price": 7.50,
      "stock": {
        "avg_cost": 5.00,
        "current_price": 7.50
      },
      "trail_stop": {
        "trail_pct": 20.0,
        "trail_amt": null,
        "reference": 7.50,
        "initial_stop_price": 6.00,
        "action": "place_new",
        "existing_trail": null
      }
    }
  ]
}

Key Behaviors

  • Reference price = max(current_price, avg_cost) — locks in profit when above cost, never starts below entry.
  • Forced mode uses current_price as the reference (can place an initial stop below entry, useful when re-arming after a drawdown).
  • Existing TS_ orders are preserved by default because IB has been ratcheting the trail since placement — replacing would reset that tracked high. Use --forced to deliberately reset.
  • Scope: stocks + naked LEAPS only. PMCC positions are excluded; use ib-stop-loss for those.

Order Identification

  • TS_{SYM}_{STRIKE}_{EXPIRY}_{RIGHT} — naked LEAPS TRAIL orders (right is C or P so calls and puts on the same strike/expiry don't collide)
  • TS_{SYM}_STK — stock TRAIL orders

Architecture

All analytics live in src/trading_skills/broker/trailing_stop.py:

Analytics (no IBKR — testable in isolation):

  • calc_trail_reference — max(current_price, avg_cost) normally; current_price if forced
  • calc_initial_trail_stop_price — reference × (1 − trail_pct/100) or reference − trail_amt
  • identify_trailable_positions — stocks + naked LEAPS; PMCC excluded
  • build_trail_analysis — full per-position output dict
  • detect_orphan_trail_orders — TS_ TRAIL orders for gone positions
  • summarize_all_trail_orders — splits IB TRAIL orders into module vs manual

Data layer (IBKR):

  • get_trailing_stop_data — main entry point
  • _cancel_orphan_orders — cancel stale TS_ orders
  • _place_simple_trail_order — native TRAIL order on stock or option
  • _execute_position_trail — dispatch per position type

© staskh, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (scripts) in .claude/skills/ib-trailing-stop of staskh/trading_skills.

  • SKILL.md
  • scripts/trailing_stop.py

Open the folder on GitHubat commit b71a74f

Compare with similar skills

Ib Trailing Stop next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Ib Trailing Stop compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ib Trailing Stop this skillstaskh/trading_skills374—~1.6kAutomated safety check: NotesMIT
Lerdliberusoftware/real-estate-laravel112—~7.8kAutomated safety check: WarnMIT
Deepstream SopNVIDIA/skills3.5k—~4.7kAutomated safety check: NotesApache-2.0
Configuring Horizoncoollabsio/coolify63k4 repos~898Automated safety check: PassMIT
Fortify Developmentcoollabsio/coolify63k4 repos~1.9kAutomated safety check: PassMIT
Node Backend Development Guidelinesdiet103/claude-code-infrastructure-showcase10k2 repos~2kAutomated safety check: PassMIT

Similar skills

  • Lerd

    liberusoftware/real-estate-laravel

    Manage the lerd local PHP development environment via MCP tools: run framework console commands (artisan, bin/console, etc.), manage services, start/stop queue workers, run composer, manage Node.js…

    112 GitHub stars~7.8k tokensUpdated 2 days ago
    Backend & APIsAuto-check: warnings
  • Deepstream Sop

    NVIDIA/skills

    Official

    A skill your agent uses when building, deploying, evaluating, debugging, or measuring latency for the DeepStream SOP Inference Microservice — a GPU-accelerated FastAPI service that detects whether…

    3.5k GitHub stars~4.7k tokensUpdated today
    Backend & APIsAuto-check: notes
  • Configuring Horizon

    coollabsio/coolify

    A skill your agent uses whenever the user mentions Horizon by name in a Laravel context.

    63k GitHub starsUsed in 4 repos~898 tokens
    Backend & APIsAuto-check passed
  • Fortify Development

    coollabsio/coolify

    ACTIVATE when the user works on authentication in Laravel. An agent skill from coollabsio/coolify.

    63k GitHub starsUsed in 4 repos~1.9k tokens
    Backend & APIsAuto-check passed
  • Node Backend Development Guidelines

    diet103/claude-code-infrastructure-showcase

    Sets layered architecture and coding rules for Node.js, Express and TypeScript microservices, covering routes, controllers, services, repositories, Prisma, Sentry and Zod.

    10k GitHub starsUsed in 2 repos~2k tokens
    Backend & APIsAuto-check passed
  • Laravel Best Practices

    anonaddy/anonaddy

    Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code.

    4.9k GitHub starsUsed in 13 repos~1.2k tokens
    Backend & APIsAuto-check passed

More from staskh/trading_skills

All 28 skills in this repo
  • Fundamentals

    staskh/trading_skills

    Get fundamental financial data including financials, earnings, and key metrics.

    374 GitHub stars~836 tokensUpdated 8 days ago
    Auto-check passed
  • Greeks

    staskh/trading_skills

    Calculate option Greeks (delta, gamma, theta, vega) and implied volatility for specific options.

    374 GitHub stars~539 tokensUpdated 8 days ago
    Auto-check passed
  • Ib Account

    staskh/trading_skills

    Get account summary from Interactive Brokers including cash balance, buying power, and account value.

    374 GitHub stars~535 tokensUpdated 8 days ago
    Auto-check: notes
  • Ib Find Short Roll

    staskh/trading_skills

    Find roll options for existing short positions OR find best covered call/put to open against long stock.

    374 GitHub stars~1.2k tokensUpdated 8 days ago
    Auto-check: notes
  • Ib Option Chain

    staskh/trading_skills

    Get option chain data from Interactive Brokers for equities, ETFs, and futures (FOP), including calls and puts with strikes, bids, asks, volume, implied volatility, and model Greeks.

    374 GitHub stars~873 tokensUpdated 8 days ago
    Auto-check: notes
  • Ib Portfolio

    staskh/trading_skills

    Get portfolio positions from Interactive Brokers. An agent skill from staskh/trading_skills.

    374 GitHub stars~471 tokensUpdated 8 days ago
    Auto-check: notes

Questions about Ib Trailing Stop

What does Ib Trailing Stop do?

Server-side trailing stop management for stocks and naked LEAPS in IB. Ib Trailing Stop is an agent skill from staskh/trading_skills. Server-side trailing stop management for stocks and naked LEAPS in IB.

When should I use Ib Trailing Stop?

Ib Trailing Stop fits situations like: tasks that involve Backend development.

How do I install Ib Trailing Stop in Claude Code?

Run `npx skills add staskh/trading_skills --skill ib-trailing-stop -a claude-code`. Or copy the skill folder (.claude/skills/ib-trailing-stop in staskh/trading_skills) into .claude/skills/ib-trailing-stop in your project. Claude Code loads it when a task matches its description.

How do I install Ib Trailing Stop in Codex?

Run `npx skills add staskh/trading_skills --skill ib-trailing-stop -a codex`. Or copy the skill folder (.claude/skills/ib-trailing-stop in staskh/trading_skills) into .agents/skills/ib-trailing-stop in your project. Codex loads it when a task matches its description.

Can I use Ib Trailing Stop in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add staskh/trading_skills --skill ib-trailing-stop -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ib-trailing-stop, .gemini/skills/ib-trailing-stop, .github/skills/ib-trailing-stop and .opencode/skills/ib-trailing-stop in your project.

What does Ib Trailing Stop need to run?

Going by SKILL.md and its folder, Ib Trailing Stop needs Python for the scripts in its folder and the command-line tools its instructions call (uv). Our summary lists: Python 3.

Does Ib Trailing Stop access the network?

SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Ib Trailing Stop safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Ib Trailing Stop use?

Ib Trailing Stop is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Ib Trailing Stop use?

About 1.6k tokens (SKILL.md is roughly 6.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Ib Trailing Stop?

Skills that share tags, products or a category with Ib Trailing Stop: Lerd (liberusoftware/real-estate-laravel, 112 stars), Deepstream Sop (NVIDIA/skills, 3.5k stars), Configuring Horizon (coollabsio/coolify, 63k stars) and Fortify Development (coollabsio/coolify, 63k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ib Trailing Stop?

staskh (a GitHub user) maintains it in staskh/trading_skills, which has 374 GitHub stars. The repository holds 28 skills in this directory. The repository was last updated on September 28, 2026.

Source: staskh/trading_skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.