get_portfolio
Retrieve portfolio positions with current market values from Interactive Brokers accounts to monitor investment performance and asset allocation.
Instructions
Get portfolio positions with market values.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | No | Account ID (optional) |
Implementation Reference
- src/ib_async_mcp/server.py:487-499 (handler)The handler logic for the 'get_portfolio' tool, which fetches portfolio items from the IB interface and returns them formatted as a list of dictionaries.
if name == "get_portfolio": items = ib.portfolio(args.get("account", "")) return [{ "symbol": p.contract.symbol, "sec_type": p.contract.secType, "position": p.position, "market_price": p.marketPrice, "market_value": p.marketValue, "average_cost": p.averageCost, "unrealized_pnl": p.unrealizedPNL, "realized_pnl": p.realizedPNL, "account": p.account, } for p in items] - src/ib_async_mcp/server.py:116-125 (registration)Registration of the 'get_portfolio' tool definition, including its name, description, and input schema.
Tool( name="get_portfolio", description="Get portfolio positions with market values.", inputSchema={ "type": "object", "properties": { "account": {"type": "string", "description": "Account ID (optional)"}, }, }, ),