Skip to main content
Glama
nadavgb-atom

ib-async-mcp

by nadavgb-atom

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
NameRequiredDescriptionDefault
accountNoAccount ID (optional)

Implementation Reference

  • 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]
  • 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)"},
            },
        },
    ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nadavgb-atom/ib-async-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server