Skip to content

API Reference parrot_tools.ibkr.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.ibkr.models

View source

Pydantic data models for the IBKR Trading Toolkit.

Defines configuration, market data, order, position, and account models used throughout the IBKR toolkit. All monetary/price fields use Decimal for precision. Field descriptions serve as LLM tool parameter descriptions.

Class AccountSummary

Account summary information.

Fields:

Field Type Default Description
account_id str IBKR account ID.
net_liquidation Decimal Net liquidation value.
total_cash Decimal Total cash balance.
buying_power Decimal Available buying power.
gross_position_value Decimal Gross position value.
unrealized_pnl Decimal Total unrealized P&L.
realized_pnl Decimal Total realized P&L.

Class BarData

Historical OHLCV bar.

Fields:

Field Type Default Description
timestamp datetime Bar timestamp.
open Decimal Opening price.
high Decimal High price.
low Decimal Low price.
close Decimal Closing price.
volume int Bar volume.

Class ContractSpec

Unified contract specification for IBKR instruments.

Fields:

Field Type Default Description
symbol str Ticker symbol (e.g. AAPL, ES, BTC).
sec_type str Security type: STK, OPT, FUT, CASH, CRYPTO.
exchange str Exchange (e.g. SMART, NYSE, GLOBEX, CBOE).
currency str Currency.

Class IBKRConfig

Configuration for IBKR connection.

Fields:

Field Type Default Description
backend Literal['tws', 'portal'] Connection backend: 'tws' for TWS API, 'portal' for Client Portal REST API.
host str TWS/Gateway host address.
port int TWS port (7497=paper trading, 7496=live trading).
client_id int Client ID for TWS connection.
portal_url Optional[str] Client Portal Gateway URL (required for portal backend).
readonly bool Read-only mode — disables order placement and modification.

Class OrderRequest

Order placement request with validation.

Fields:

Field Type Default Description
symbol str Ticker symbol.
action Literal['BUY', 'SELL'] Order action: BUY or SELL.
quantity int Order quantity (must be > 0).
order_type Literal['MKT', 'LMT', 'STP', 'STP_LMT'] Order type: MKT, LMT, STP, or STP_LMT.
limit_price Optional[Decimal] Limit price (required for LMT and STP_LMT orders).
stop_price Optional[Decimal] Stop trigger price (required for STP and STP_LMT orders).
tif Literal['DAY', 'GTC', 'IOC', 'FOK'] Time in force: DAY, GTC, IOC, or FOK.

Class OrderStatus

Order status response from IBKR.

Fields:

Field Type Default Description
order_id int IBKR order ID.
symbol str Ticker symbol.
action str Order action (BUY/SELL).
quantity int Total order quantity.
filled int Quantity filled.
remaining int Quantity remaining.
avg_fill_price Optional[Decimal] Average fill price.
status str Order status (e.g. Submitted, Filled, Cancelled).
timestamp Optional[datetime] Status update timestamp.

Class Position

Account position for a single instrument.

Fields:

Field Type Default Description
symbol str Ticker symbol.
quantity int Position size (negative for short).
avg_cost Decimal Average cost basis per share.
market_value Optional[Decimal] Current market value.
unrealized_pnl Optional[Decimal] Unrealized P&L.
realized_pnl Optional[Decimal] Realized P&L.

Class Quote

Real-time quote data for a contract.

Fields:

Field Type Default Description
symbol str Ticker symbol.
last Optional[Decimal] Last traded price.
bid Optional[Decimal] Current bid price.
ask Optional[Decimal] Current ask price.
volume Optional[int] Trading volume.
timestamp Optional[datetime] Quote timestamp.

Class RiskConfig

Risk management guardrails for agent-driven trading.

Fields:

Field Type Default Description
max_order_qty int Maximum shares/contracts per single order.
max_order_value Decimal Maximum notional value per single order.
max_position_value Decimal Maximum total position value per symbol.
daily_loss_limit Decimal Maximum daily realized + unrealized loss before trading halt.
require_confirmation bool Require human confirmation callback before order execution.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally