Get the FREE Ultimate OpenClaw Setup Guide →

ib-account

Scanned
npx machina-cli add skill staskh/trading_skills/ib-account --openclaw
Files (1)
SKILL.md
1.3 KB

IB Account

Fetch account summary from Interactive Brokers.

Prerequisites

User must have TWS or IB Gateway running locally with API enabled:

  • Paper trading: port 7497
  • Live trading: port 7496

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/account.py [--port PORT] [--account ACCOUNT_ID] [--all-accounts]

Arguments

  • --port - IB port (default: 7496 for live trading)
  • --account - Specific account ID to fetch
  • --all-accounts - Fetch summaries for all managed accounts

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

Output

Returns JSON with:

  • connected - Whether connection succeeded
  • accounts - List of account summaries, each with account ID, net liquidation, cash, buying power, etc.

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

Dependencies

  • ib-async

Source

git clone https://github.com/staskh/trading_skills/blob/main/.claude/skills/ib-account/SKILL.mdView on GitHub

Overview

This skill retrieves Interactive Brokers account summaries by connecting to a locally running TWS or IB Gateway via the API. It returns key metrics such as cash balance, buying power, and net liquidation value, for one or all accounts. Use it to quickly answer questions about available cash and overall account value.

How This Skill Works

It connects to Interactive Brokers using a locally running TWS or IB Gateway via the API and runs scripts/account.py. If uv is available, commands use 'uv run python'; otherwise you can use plain 'python'. You can pass --port, --account, or --all-accounts to control which accounts are queried, with the default being the first managed account. The output is a JSON object with a 'connected' flag and an 'accounts' array of summaries.

When to Use It

  • User asks for current cash balance or buying power
  • User asks for account value or net liquidation across accounts
  • User wants to connect to a locally running TWS/IB Gateway
  • User needs summaries for all managed accounts rather than a single one
  • User wants to specify a particular account ID or port for the query

Quick Start

  1. Step 1: Start TWS or IB Gateway and enable the API access (paper: port 7497, live: port 7496)
  2. Step 2: Run the query (uv run python scripts/account.py --port PORT [--account ACCOUNT_ID] [--all-accounts])
  3. Step 3: Read the JSON output; check 'connected' and review 'accounts' for cash, buying power, and value

Best Practices

  • Ensure TWS or IB Gateway is running and API access is enabled
  • Use --all-accounts for a complete cross-account view unless a specific account is requested
  • Match the port to your environment: 7497 for paper trading, 7496 for live trading
  • Handle the 'connected' flag to gracefully manage misconfigurations
  • Validate the returned account IDs before integrating into workflows

Example Use Cases

  • Show my cash balance for account U1234567
  • Fetch buying power for all my IB accounts
  • Retrieve net liquidation value for the primary trading account
  • List account summaries for every managed account
  • Check connection status to TWS/Gateway before placing orders

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers ↗