Agent Skillsstaskh/trading_skills › ib-portfolio

ib-portfolio

GitHub

从 Interactive Brokers 获取投资组合持仓信息。当用户询问持仓、头寸或持有股票时使用。需本地运行 TWS 或 IB Gateway,支持自动端口回退及纽约时区输出。

.claude/skills/ib-portfolio/SKILL.md staskh/trading_skills

触发场景

查询投资组合 查看持仓情况 询问持有的股票

安装

npx skills add staskh/trading_skills --skill ib-portfolio -g -y
更多选项

非标准路径

npx skills add https://github.com/staskh/trading_skills/tree/main/.claude/skills/ib-portfolio -g -y

不安装直接使用

npx skills use staskh/trading_skills@ib-portfolio

指定 Agent (Claude Code)

npx skills add staskh/trading_skills --skill ib-portfolio -a claude-code -g -y

安装 repo 全部 skill

npx skills add staskh/trading_skills --all -g -y

预览 repo 内 skill

npx skills add staskh/trading_skills --list

SKILL.md

Frontmatter
{
    "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

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.

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.

版本历史

  • cc30858 当前 2026-07-05 11:04

依赖关系

  • required trading-skills

同 Skill 集合

.claude/skills/earnings-calendar/SKILL.md
.claude/skills/fundamentals/SKILL.md
.claude/skills/greeks/SKILL.md
.claude/skills/ib-account/SKILL.md
.claude/skills/ib-collar/SKILL.md
.claude/skills/ib-create-consolidated-report/SKILL.md
.claude/skills/ib-find-short-roll/SKILL.md
.claude/skills/ib-option-chain/SKILL.md
.claude/skills/ib-pmcc-advisor/SKILL.md
.claude/skills/ib-portfolio-action-report/SKILL.md
.claude/skills/ib-report-delta-adjusted-notional-exposure/SKILL.md
.claude/skills/ib-stop-loss/SKILL.md
.claude/skills/ib-trades-history/SKILL.md
.claude/skills/ib-trailing-stop/SKILL.md
.claude/skills/insider-trading/SKILL.md
.claude/skills/markdown-to-pdf/SKILL.md
.claude/skills/news-sentiment/SKILL.md
.claude/skills/option-chain/SKILL.md
.claude/skills/price-history/SKILL.md
.claude/skills/report-stock/SKILL.md
.claude/skills/risk-assessment/SKILL.md
.claude/skills/scanner-bullish/SKILL.md
.claude/skills/scanner-pmcc/SKILL.md
.claude/skills/spread-analysis/SKILL.md
.claude/skills/stock-quote/SKILL.md
.claude/skills/technical-analysis/SKILL.md
.claude/skills/whale-hunting/SKILL.md

元信息

文件数
0
版本
cc30858
Hash
adcecf6f
收录时间
2026-07-05 11:04

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-14 23:08
浙ICP备14020137号-1 $访客地图$