Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add staskh/trading_skills --skill ib-portfolio -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/ib-portfolio/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/ib-portfolio/

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

Similar skills

All skills for Finance and business →

From the same set12

The whole set →
stock-quote stock-quote is a Claude Code skill that fetches current price, volume, change, and 52-week range for any ticker. CX Codex +1 138installs greeks Skill computes option Greeks (delta, gamma, theta, vega) and implied volatility using the Black-Scholes model. Use it to understand how your position reacts to price changes, time decay, and shifts in volatility. CX Codex +1 137installs report-stock report-stock builds stock research reports in Markdown or PDF covering market trends, PMCC viability, and company fundamentals. CX Codex +1 123installs option-chain Skill pulls option chain data from Yahoo Finance: calls and puts with strike prices, bids, asks, volumes, and implied volatility. Use it to check option quotes for a specific expiration date. CX Codex +1 117installs risk-assessment risk-assessment calculates risk metrics for stocks and positions: volatility, beta, Value at Risk, and maximum drawdown. Use it to assess position risk and determine sizing. CX Codex +1 113installs spread-analysis The spread-analysis skill performs quantitative analysis of multi-leg option strategies for Claude Code. It triggers on requests concerning vertical spreads, iron condors, straddles, or strangle strategies. CX Codex +1 105installs ib-account The ib-account Claude Code skill fetches an Interactive Brokers account summary. It activates for questions about balances, buying power, or available cash. CX Codex +1 103installs price-history The price-history Claude Code skill fetches historical OHLCV data for a stock. It activates for requests about past prices or data for chart analysis. CX Codex +1 102installs

Project sponsors

Companies that keep this analytics open