Skip to main content
Glama
nadavgb-atom

ib-async-mcp

by nadavgb-atom

what_if_order

Analyze margin requirements before executing trades to assess financial impact and manage risk effectively.

Instructions

Check margin impact without placing order.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contract_typeYes
symbolYes
exchangeNoSMART
currencyNoUSD
actionYes
quantityYes
order_typeNomarket
limit_priceNo

Implementation Reference

  • The implementation of the what_if_order tool logic. It processes the input arguments, creates a contract and order, and calls ib.whatIfOrderAsync to retrieve the result.
    if name == "what_if_order":
        contract = create_contract(
            args["contract_type"],
            symbol=args["symbol"],
            exchange=args.get("exchange", "SMART"),
            currency=args.get("currency", "USD"),
        )
        await ib.qualifyContractsAsync(contract)
        
        order_type = args.get("order_type", "market").lower()
        if order_type == "limit":
            order = LimitOrder(args["action"], args["quantity"], args["limit_price"])
        else:
            order = MarketOrder(args["action"], args["quantity"])
        
        state = await ib.whatIfOrderAsync(contract, order)
        return serialize_object(state)
  • The registration of the what_if_order tool with its schema definition, defining input parameters like contract_type, symbol, action, and quantity.
    Tool(
        name="what_if_order",
        description="Check margin impact without placing order.",
        inputSchema={
            "type": "object",
            "properties": {
                "contract_type": {"type": "string"},
                "symbol": {"type": "string"},
                "exchange": {"type": "string", "default": "SMART"},
                "currency": {"type": "string", "default": "USD"},
                "action": {"type": "string"},
                "quantity": {"type": "number"},
                "order_type": {"type": "string", "default": "market"},
                "limit_price": {"type": "number"},
            },

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