staskh avatar

Ib Trailing Stop

Places native IB TRAIL orders on your stocks and naked LEAPS so the broker auto-ratchets stops as price climbs. The reference price is max(current, cost basis) so you never start below entry, and existing orders are preserved by default since IB has been tracking the high since placement. Dry run mode shows what would happen before you commit. The forced flag lets you reset everything using current price as the new baseline, which makes sense after a drawdown when you want to re-arm protection. PMCC positions are intentionally skipped because a trailing stop on just the long leg would break the hedge at trigger. Requires TWS or Gateway running locally with API access.

GitHub stars
248
last updated
Jun 11, 2026

Install

$ npx -y skills add staskh/trading_skills --skill ib-trailing-stop --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/staskh/trading_skills
Categories
Backend & APIs, Finance & Trading
License
MIT
First seen
Jun 11, 2026

More from staskh/trading_skills

All 28
1telagod avatardefending-applicationstelagod/code-abyssApplication security defense knowledge for builders, not pentesters. Covers Web/API/GraphQL hardening (XSS/SQLi/SSRF/IDOR/BOLA/Mass Assignment/deserialization/u0skills.sh installs
2zhixiangluo avatardiscover-ui-surfacezhixiangluo/10xproductivityWalk through a UI flow once manually and capture a durable interaction map — which DOM elements to click, which network requests they trigger, and what field sh0skills.sh installs
3firebase avatarxcode-project-setupfirebase/agent-skillsSafely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Fireba137.9Kskills.sh installs
4better-auth avataremail-and-password-best-practicesbetter-auth/skillsEmail verification, password reset flows, and customizable password policies for Better Auth.49.9Kskills.sh installs
5firebase avatardeveloping-genkit-gofirebase/agent-skillsDevelop AI-powered applications using Genkit in Go. Use when the user asks to build AI features, agents, flows, or tools in Go using Genkit, or when working wit49.5Kskills.sh installs
6firebase avatarfirestore-security-rules-auditorfirebase/agent-skillsA skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely20.4Kskills.sh installs