get_market_data
Retrieve real-time market data snapshots for financial contracts to monitor current prices and market conditions.
Instructions
Get real-time market data snapshot for a contract.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contract_type | Yes | ||
| symbol | Yes | ||
| exchange | No | SMART | |
| currency | No | USD |
Implementation Reference
- src/ib_async_mcp/server.py:555-577 (handler)Handler for 'get_market_data' tool which requests market data for a contract using ib_async and returns a dictionary of ticker values.
if name == "get_market_data": contract = create_contract( args["contract_type"], symbol=args["symbol"], exchange=args.get("exchange", "SMART"), currency=args.get("currency", "USD"), ) await ib.qualifyContractsAsync(contract) tickers = await ib.reqTickersAsync(contract) if tickers: t = tickers[0] return { "symbol": contract.symbol, "bid": t.bid, "ask": t.ask, "last": t.last, "volume": t.volume, "open": t.open, "high": t.high, "low": t.low, "close": t.close, } return {"error": "No data available"} - src/ib_async_mcp/server.py:205-218 (schema)Definition and input schema for the 'get_market_data' tool.
Tool( name="get_market_data", description="Get real-time market data snapshot for a contract.", inputSchema={ "type": "object", "properties": { "contract_type": {"type": "string"}, "symbol": {"type": "string"}, "exchange": {"type": "string", "default": "SMART"}, "currency": {"type": "string", "default": "USD"}, }, "required": ["contract_type", "symbol"], }, ),