staskh avatar

Ib Trades History

Pulls your Interactive Brokers trade executions with flexible filtering by account, symbol, and date range. The live API gives you about seven days of history, which is fine for recent activity, but if you need older trades you'll use FlexReport queries or local XML exports. Smart design here is the ability to chain multiple queries or files to get around IB's 365-day limit per query. Requires TWS or IB Gateway running locally unless you're working from exported files. Returns structured JSON with both individual executions and aggregated summaries per symbol, including commissions and realized P&L. If you're building trading analysis tools or just need to answer "what did I actually pay for those AAPL shares last month," this handles the IBKR connectivity pain for you.

GitHub stars
248
last updated
Jun 11, 2026

Install

$ npx -y skills add staskh/trading_skills --skill ib-trades-history --agent claude-code

Installs into .claude/skills of the current project.

Files

IB Trades History

Fetch trade executions from Interactive Brokers.

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.

For full trade history beyond ~7 days, the user needs a Flex Web Service token and a pre-configured Trade query in IBKR Account Management.

Instructions

Note: If uv is not installed or pyproject.toml is not found, replace uv run python with python in all commands below.

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
1staskh avatarib-trailing-stopstaskh/trading_skillsServer-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 default0skills.sh installs
2telagod 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
3zhixiangluo 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
4firebase 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
5better-auth avataremail-and-password-best-practicesbetter-auth/skillsEmail verification, password reset flows, and customizable password policies for Better Auth.49.9Kskills.sh installs
6firebase 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