create_contract
Create trading contracts for stocks, options, futures, forex, indices, CFDs, cryptocurrencies, and bonds by specifying contract type and symbol.
Instructions
Create a contract for trading. Types: stock, option, future, forex, index, cfd, crypto, bond.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contract_type | Yes | Contract type | |
| symbol | Yes | Symbol (e.g., AAPL, EURUSD) | |
| exchange | No | Exchange | SMART |
| currency | No | Currency | USD |
| expiry | No | Expiry date for options/futures (YYYYMMDD) | |
| strike | No | Strike price for options | |
| right | No | Option right: C (call) or P (put) | |
| multiplier | No | Contract multiplier |
Implementation Reference
- src/ib_async_mcp/server.py:42-55 (handler)The create_contract function acts as a factory method to instantiate appropriate Contract objects based on the provided contract_type.
def create_contract(contract_type: str, **kwargs) -> Contract: """Create a contract based on type.""" contract_map = { 'stock': Stock, 'option': Option, 'future': Future, 'forex': Forex, 'index': Index, 'cfd': CFD, 'crypto': Crypto, 'bond': Bond, } contract_class = contract_map.get(contract_type.lower(), Contract) return contract_class(**kwargs) - src/ib_async_mcp/server.py:147-155 (registration)The tool 'create_contract' is registered in the list_tools() function, providing its schema and description.
Tool( name="create_contract", description="Create a contract for trading. Types: stock, option, future, forex, index, cfd, crypto, bond.", inputSchema={ "type": "object", "properties": { "contract_type": {"type": "string", "description": "Contract type"}, "symbol": {"type": "string", "description": "Symbol (e.g., AAPL, EURUSD)"}, "exchange": {"type": "string", "default": "SMART", "description": "Exchange"},