
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-codeInstalls 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_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.
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
uvis not installed orpyproject.tomlis not found, replaceuv run pythonwithpythonin 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- Ib Trailing Stop
- Insider Trading
- Markdown To Pdf
- Price History
- Scanner Bullish
- Scanner Pmcc
- Spread Analysis
- Whale Hunting
- Technical Analysis598
- News Sentiment246
- Fundamentals182
- Stock Quote131
- Greeks128
- Report Stock117
- Option Chain111
- Risk Assessment105
- Earnings Calendar
- Ib Account
- Ib Collar
- Ib Create Consolidated Report
- Ib Find Short Roll
- Ib Option Chain
- Ib Pmcc Advisor
- Ib Portfolio