Agent skill

Ib Trades History

by staskh in staskh/trading_skills

Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol.

MITAuto-check: notesBusiness, Finance & HR

Install Ib Trades History

skills CLI
$ npx skills add staskh/trading_skills --skill ib-trades-history -a claude-code

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

GitHub CLI
$ gh skill install staskh/trading_skills ib-trades-history --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-trades-history .claude/skills/ib-trades-history && 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-trades-history
GitHub stars
376
Token cost
~1.9k tokens
SKILL.md length
766 words
Files
2 (incl. scripts)
Skills in repo
28
Repo updated
First seen
Licence
MIT

At a glance

Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol.

  • User asks about their trades
  • SKILL.md covers IB Connection, Instructions, Arguments and Data Sources, plus 3 more sections
  • Runs Python scripts from its folder; calls uv; needs IB_FLEX_TOKEN
  • Transaction history

What it does

Ib Trades History is an agent skill from staskh/trading_skills. Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol. Supports live API (~7 days history) and FlexReport (full history). Use when user asks about their trades, executions, or transaction history. Requires TWS or IB Gateway running locally.

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

It sits in Business, Finance & HR. The repository describes itself as: Claude powered advisor system for option traders. The licence is MIT.

When your agent uses it

  • User asks about their trades
  • Transaction history

Example prompts

  • “/ib-trades-history”

Requirements

  • Python 3
  • A credential in YOUR_TOKEN
  • A credential in IB_FLEX_TOKEN

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 these keys or tokens, usually read from environment variables:

    • IB_FLEX_TOKEN

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

Context cost

Ib Trades History loads about 1.9k tokens when it runs. Until then it costs about 74 tokens; SKILL.md has 766 words of instructions outside code blocks.

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

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:16
    lt-in default. Set it in the shell or a `.env` file.
  • NoteMentions a .env fileSKILL.md:71
    are set in the environment or `.env` (see `env.template`). Flags win over env vars.

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). 766 words, ~1,877 tokens.

Download SKILL.mdSave it as .claude/skills/ib-trades-history/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
ib-trades-history
description
Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol. Supports live API (~7 days history) and FlexReport (full history). Use when user asks about their trades, executions, or transaction history. Requires TWS or IB Gateway running locally.
dependencies
trading-skills

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.

bash
# Recent trades (last ~7 days via API)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts

# Filter by symbol
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --symbol AAPL

# Full history via FlexReport
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --flex-token YOUR_TOKEN --flex-query-id YOUR_QUERY_ID

# Custom date range (FlexReport)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --flex-token TOKEN --flex-query-id QID --start-date 2025-01-01 --end-date 2025-12-31

# Multiple queries (e.g., one per year to exceed 365-day limit)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --flex-token TOKEN --flex-query-id QID_2025 --flex-query-id QID_2026 --start-date 2025-01-01 --end-date 2026-12-31

# From local FlexReport XML files (no TWS/Gateway needed)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --file trades_2024.xml --file trades_2025.xml --symbol TSLA

# Mix files with date filtering
uv run python .claude/skills/ib-trades-history/scripts/trades.py --file exports/2025.xml --start-date 2025-06-01 --end-date 2025-12-31

# Group option fills into vertical spreads (credit, width, max risk, capture %, RoR)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --file exports/2026.xml --symbol NDX --group-spreads

Arguments

  • --port - IB port (default: 7497 for paper trading)
  • --account - Specific account ID to filter
  • --all-accounts - Fetch trades for all managed accounts
  • --symbol - Filter trades by symbol (e.g., AAPL)
  • --start-date - Start date in YYYY-MM-DD format (default: Jan 1 of current year)
  • --end-date - End date in YYYY-MM-DD format (default: today)
  • --flex-token - FlexReport token (enables extended history)
  • --flex-query-id - FlexReport query ID (repeatable — pass multiple to merge queries spanning different periods)
  • --file - Local FlexReport XML file path (repeatable — pass multiple to merge files). No TWS/Gateway needed
  • --group-spreads - Consolidate fills into legs and pair them into vertical spreads. FlexReport sources only

Default behavior (no flags): fetches trades for the first managed account from the live API. Always use --all-accounts unless the user asks for a specific account.

--flex-token / --flex-query-id may be omitted when IB_FLEX_TOKEN / IB_FLEX_QUERY_ID are set in the environment or .env (see env.template). Flags win over env vars.

Data Sources

ScenarioSourceDate Range
No flex argsreqExecutionsAsyncCurrent session only
--flex-token + --flex-query-idFlexReport (web)As configured in query
--filefile (local XML)Full file contents

When using the live API, a data_limitation warning is included in the output.

The live API returns only the current TWS session, despite the "~7 days" the API docs imply — it yields 0 executions on a weekend or for any prior-day lookback, which looks identical to "no trades." Setting ExecutionFilter.time does not widen it. For anything beyond today, use FlexReport. The web service is also aggressively rate-limited ("Statement could not be generated at this time" = throttled, roughly one generation per query per 10–15 min); for large lookbacks prefer a manual XML export via --file.

Show full SKILL.md (326 more words)Show less

Spread Grouping (--group-spreads)

Turns raw fills into the trade-level view: a 10-lot order routed across five exchanges is one leg, and its opening and closing legs are one spread.

Requires the openCloseIndicator field, which only FlexReport sources provide. On the live API path the output carries spread_grouping.supported = false with a reason rather than guessing which fills opened versus closed.

Legs are keyed on (account, symbol, expiry, right) — deliberately not trade date, so a spread opened one session and settled the next keeps its closing legs.

Anything that is not an unambiguous two-strike vertical is left in ungrouped_legs with a reason in spread_grouping.warnings, never force-fit into a bogus spread: rolls, ratio spreads, multiple verticals on one expiry/right, single legs, positions still open, and closes whose open predates the window.

spread_grouping.reconciled asserts that spread P&L plus ungrouped P&L equals the raw execution P&L — check it before trusting a report.

Output

Returns JSON with:

  • connected - Whether connection succeeded
  • source - Data source used (reqExecutionsAsync or FlexReport)
  • filters - Applied filters (dates, symbol, account)
  • data_limitation - Warning about API date limits (only when using live API)
  • execution_count - Total number of executions returned
  • executions - List of individual trade executions
  • summary - Aggregated stats per symbol (bought, sold, commission, realized P&L)

With --group-spreads, also:

  • legs / leg_count - Partial fills consolidated into orders
  • spreads / spread_count - Paired verticals, each with type (Bear call / Bull put / Bull call / Bear put), short_strike, long_strike, width, lots, credit, max_credit, max_risk, entry_date/entry_time, exit_date/exit_time, realizedPnL, commission, netPnL, capture_pct, return_on_risk_pct, settled_at_expiry, same_day
  • ungrouped_legs - Legs that are not a clean vertical (only when non-empty)
  • spread_grouping - supported, warnings, ungrouped_leg_count, and the reconciled / execution_pnl / spread_pnl / ungrouped_pnl check

max_risk assumes a defined-risk vertical: (width − credit) × lots × multiplier. capture_pct is realized P&L as a share of max credit; return_on_risk_pct is realized P&L over max risk. On an iron condor the two wings are separate spreads — summing their max_risk overstates true exposure, since only one side can lose at expiry.

If not connected, explain that TWS/Gateway needs to be running.

Dependencies

  • ib-async

© 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-trades-history of staskh/trading_skills.

  • SKILL.md
  • scripts/trades.py

Open the folder on GitHubat commit b71a74f

Compare with similar skills

Ib Trades History 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 Trades History compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ib Trades History this skillstaskh/trading_skills376—~1.9kAutomated safety check: NotesMIT
Technical Analysttradermonty/claude-trading-skills3k4 repos~4.6kAutomated safety check: PassMIT
Theme Detectortradermonty/claude-trading-skills3k2 repos~4.9kAutomated safety check: PassMIT
Creating Financial ModelsChen-zexi/open-ptc-agent7293 repos~1.3kAutomated safety check: PassMIT
Stock APIzhangxiangliang/stock-api2k—~507Automated safety check: PassMIT
Itr Walakaranb192/itr-wala871—~3.6kAutomated safety check: PassMIT

Similar skills

  • Technical Analyst

    tradermonty/claude-trading-skills

    This skill should be used when analyzing weekly price charts for stocks, stock indices, cryptocurrencies, or forex pairs.

    3k GitHub starsUsed in 4 repos~4.6k tokens
    Business, Finance & HRAuto-check passed
  • Theme Detector

    tradermonty/claude-trading-skills

    Detect and analyze trending market themes across sectors. An agent skill from tradermonty/claude-trading-skills.

    3k GitHub starsUsed in 2 repos~4.9k tokens
    Business, Finance & HRAuto-check passed
  • Creating Financial Models

    Chen-zexi/open-ptc-agent

    This skill provides an advanced financial modeling suite with DCF analysis, sensitivity testing, Monte Carlo simulations, and scenario planning for investment decisions

    729 GitHub starsUsed in 3 repos~1.3k tokens
    Business, Finance & HRAuto-check passed
  • Stock API

    zhangxiangliang/stock-api

    Fetch real-time stock quotes, K-line (candlestick) history, and search symbols for China A-shares, Hong Kong, and US markets.

    2k GitHub stars~507 tokensUpdated yesterday
    Business, Finance & HRAuto-check passed
  • Itr Wala

    karanb192/itr-wala

    File Indian income tax returns (ITR) for FY 2025-26 / AY 2026-27.

    871 GitHub stars~3.6k tokensUpdated 7 days ago
    Business, Finance & HRAuto-check passed
  • Tushare Data

    zillionare/zillionare

    面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。

    322 GitHub starsUsed in 2 repos~2.3k tokens
    Business, Finance & HRAuto-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.

    376 GitHub stars~836 tokensUpdated 12 days ago
    Auto-check passed
  • Greeks

    staskh/trading_skills

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

    376 GitHub stars~539 tokensUpdated 12 days ago
    Auto-check passed
  • Ib Account

    staskh/trading_skills

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

    376 GitHub stars~535 tokensUpdated 12 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.

    376 GitHub stars~1.2k tokensUpdated 12 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.

    376 GitHub stars~873 tokensUpdated 12 days ago
    Auto-check: notes
  • Ib Portfolio

    staskh/trading_skills

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

    376 GitHub stars~471 tokensUpdated 12 days ago
    Auto-check: notes

Questions about Ib Trades History

What does Ib Trades History do?

Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol. Ib Trades History is an agent skill from staskh/trading_skills. Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol.

When should I use Ib Trades History?

Ib Trades History fits situations like: user asks about their trades; transaction history.

How do I install Ib Trades History in Claude Code?

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

How do I install Ib Trades History in Codex?

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

Can I use Ib Trades History 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-trades-history -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-trades-history, .gemini/skills/ib-trades-history, .github/skills/ib-trades-history and .opencode/skills/ib-trades-history in your project.

What does Ib Trades History need to run?

Going by SKILL.md and its folder, Ib Trades History needs Python for the scripts in its folder, the command-line tools its instructions call (uv) and credentials named IB_FLEX_TOKEN. Our summary lists: Python 3; A credential in YOUR_TOKEN; A credential in IB_FLEX_TOKEN.

Does Ib Trades History 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 Trades History 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 Trades History use?

Ib Trades History 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 Trades History use?

About 1.9k tokens (SKILL.md is roughly 7.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 Trades History?

Skills that share tags, products or a category with Ib Trades History: Technical Analyst (tradermonty/claude-trading-skills, 3k stars), Theme Detector (tradermonty/claude-trading-skills, 3k stars), Creating Financial Models (Chen-zexi/open-ptc-agent, 729 stars) and Stock API (zhangxiangliang/stock-api, 2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ib Trades History?

staskh (a GitHub user) maintains it in staskh/trading_skills, which has 376 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.