Skip to main content
Glama
nadavgb-atom

ib-async-mcp

by nadavgb-atom

get_historical_data

Retrieve historical market data for financial instruments by specifying contract details, time periods, and bar sizes to analyze past performance.

Instructions

Get historical bar data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contract_typeYes
symbolYes
exchangeNoSMART
currencyNoUSD
durationNoDuration (e.g., '1 D', '1 W', '1 M', '1 Y')1 D
bar_sizeNoBar size (e.g., '1 min', '5 mins', '1 hour', '1 day')1 hour
what_to_showNoData type: TRADES, MIDPOINT, BID, ASKTRADES
use_rthNoRegular trading hours only

Implementation Reference

  • The handler implementation for the "get_historical_data" tool, which creates a contract, qualifies it, and requests historical bar data from the IB gateway.
    if name == "get_historical_data":
        contract = create_contract(
            args["contract_type"],
            symbol=args["symbol"],
            exchange=args.get("exchange", "SMART"),
            currency=args.get("currency", "USD"),
        )
        await ib.qualifyContractsAsync(contract)
        bars = await ib.reqHistoricalDataAsync(
            contract,
            endDateTime="",
            durationStr=args.get("duration", "1 D"),
            barSizeSetting=args.get("bar_size", "1 hour"),
            whatToShow=args.get("what_to_show", "TRADES"),
            useRTH=args.get("use_rth", True),
        )
        return [{
            "date": b.date.isoformat() if hasattr(b.date, 'isoformat') else str(b.date),
            "open": b.open,
            "high": b.high,
            "low": b.low,
            "close": b.close,
            "volume": b.volume,
        } for b in bars]
  • Registration of the "get_historical_data" tool in the list_tools() function.
        name="get_historical_data",
        description="Get historical bar data.",
        inputSchema={
            "type": "object",
            "properties": {
                "contract_type": {"type": "string"},
                "symbol": {"type": "string"},
                "exchange": {"type": "string", "default": "SMART"},
                "currency": {"type": "string", "default": "USD"},
                "duration": {"type": "string", "default": "1 D", "description": "Duration (e.g., '1 D', '1 W', '1 M', '1 Y')"},
                "bar_size": {"type": "string", "default": "1 hour", "description": "Bar size (e.g., '1 min', '5 mins', '1 hour', '1 day')"},
                "what_to_show": {"type": "string", "default": "TRADES", "description": "Data type: TRADES, MIDPOINT, BID, ASK"},
                "use_rth": {"type": "boolean", "default": True, "description": "Regular trading hours only"},
            },
            "required": ["contract_type", "symbol"],
        },
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only minimally indicates this is a read operation ('Get') and historical in nature. It fails to disclose data source limitations, rate limiting, what happens if historical data is unavailable, or the structure of the return value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely brief (4 words) and front-loaded, but given the tool's complexity (8 parameters, no annotations, no output schema), this brevity results in under-specification. The sentence doesn't earn its place given the information gaps.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 8-parameter financial data tool with no annotations and no output schema, the description is woefully incomplete. It doesn't explain output format, parameter relationships (e.g., that SMART is Interactive Brokers' routing destination), or data granularity constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50% (4 of 8 parameters documented). The description mentions no parameters whatsoever, failing to compensate for the undocumented contract_type, symbol, exchange, and currency parameters. It adds zero semantic value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool retrieves 'historical bar data' (OHLCV candles), which is specific enough to distinguish from siblings like get_historical_news or get_market_data. However, it lacks domain context for financial trading and doesn't clarify the distinction from get_head_timestamp.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like get_market_data (likely real-time) or get_head_timestamp, nor does it mention prerequisites like requiring a valid contract or connection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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