ib-portfolio — Claude Code skill: what it does, how to install
ib-portfolio — a skill for Claude Code fetches open positions and holdings from Interactive Brokers. The agent invokes it when asked about current stocks, portfolio value, or account assets.
MIT 107 installs ★ 417 updated 2026-10-21
npx skills add staskh/trading_skills --skill ib-portfolio -a claude-codeWhat ib-portfolio does
The tool retrieves brokerage account positions by running scripts/portfolio.py. It returns a JSON object containing ticker symbols, share counts, average purchase costs, market values, and unrealized profit or loss. Output timestamps use the America/New_York timezone.
Execution requires a local instance of TWS or IB Gateway with API access turned on, plus the ib-async library. The script targets port 7497 for paper trading by default and falls back to port 7496 for live trading upon failure. Connection fails completely if neither gateway instance is running locally.
What it helps with
- fetch open stock positions from Interactive Brokers
- inspect unrealized PnL and average cost per holding
- query a specific portfolio using the --account parameter
Example prompts for the agent
- Show my current positions in Interactive Brokers
- What stocks do I own and what is my unrealized PnL?
- Check my portfolio holdings on port 7496
How to install ib-portfolio
1Skills CLI (Vercel)
npx skills add staskh/trading_skills --skill ib-portfolio -a claude-code2Manually: put the files in place
~/.claude/skills/ib-portfolio/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/ib-portfolio/
1Skills CLI (Vercel)
npx skills add staskh/trading_skills --skill ib-portfolio -a codex2Manually: put the files in place
.agents/skills/ib-portfolio/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add staskh/trading_skills --skill ib-portfolio -a cursor2Manually: put the files in place
.cursor/skills/ib-portfolio/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install staskh/trading_skills .claude/skills/ib-portfolio2Manually: put the files in place
.github/skills/ib-portfolio/SKILL.md1Skills CLI (Vercel)
npx skills add staskh/trading_skills --skill ib-portfolio -a gemini-cli2Platform CLI
gemini skills install https://github.com/staskh/trading_skills --path .claude/skills/ib-portfolioManually: put the files in place
.devin/skills/ib-portfolio/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add staskh/trading_skills --skill ib-portfolio -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about ib-portfolio
How to install ib-portfolio in Claude Code?
Run npx skills add staskh/trading_skills --skill ib-portfolio -a claude-code. The skill definition file is placed at ~/.claude/skills/ib-portfolio/SKILL.md.
What does ib-portfolio do?
It connects to your local trading gateway and pulls asset quantities, prices, valuations, and unrealized PnL into JSON for the agent.
What is required to run ib-portfolio?
You need a local TWS or IB Gateway running with API connections enabled, the ib-async package, and Python or uv.
Source text
SKILL.md · MIT
--- name: ib-portfolio description: Get portfolio positions from Interactive Brokers. Use when user asks about their portfolio, positions, holdings, or what stocks they own. Requires TWS or IB Gateway running locally. dependencies: ["trading-skills"] --- # IB Portfolio Fetch current portfolio positions 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. ## Instructions > **Note:** If `uv` is not installed or `pyproject.toml` is not found, replace `uv run python` with `python` in all commands below. ```bash uv run python scripts/portfolio.py [--port PORT] ``` ## Arguments - `--port` - IB port (default: 7497 for paper trading) - `--account` - Specific IB account ID (optional, defaults to first account) ## Output Returns JSON with: - `connected` - Whether connection succeeded - `positions` - Array of positions with symbol, quantity, avg_cost, market_value, unrealized_pnl If not connected, explain that TWS/Gateway needs to be running. ## Dependencies - `ib-async` ## Timezone All timestamps and time-based calculations must use the `America/New_York` timezone. All JSON output must include `generated_at` (NY time string) and `data_delay` fields.
© staskh · MIT · staskh/trading_skills