Skip to content

API Reference parrot_tools.ibkr

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

parrot_tools.ibkr

View source

IBKR Trading Toolkit for AI-Parrot agents.

Provides a unified toolkit for market data, order management, account info, and portfolio operations through Interactive Brokers. Supports both TWS API and Client Portal REST API backends with built-in risk management.

Alias AccountSummary

Re-exported from parrot_tools.ibkr.models.AccountSummary.

Alias BarData

Re-exported from parrot_tools.ibkr.models.BarData.

Alias ContractSpec

Re-exported from parrot_tools.ibkr.models.ContractSpec.

Alias IBKRBackend

Re-exported from parrot_tools.ibkr.backend.IBKRBackend.

Alias IBKRConfig

Re-exported from parrot_tools.ibkr.models.IBKRConfig.

Class IBKRToolkit

Interactive Brokers trading toolkit for market data, orders, and portfolio management.

Wraps both TWS API and Client Portal REST backends behind a unified interface. All order operations are gated by a RiskManager.

Parameter Type Default Description
config Optional[IBKRConfig] None IBKR connection configuration.
risk_config Optional[RiskConfig] None Risk management guardrails.
confirmation_callback None Optional async callback for order confirmation.
**kwargs {}

Method IBKRToolkit.connect

Connect to IBKR backend.

connect() -> None

Method IBKRToolkit.disconnect

Disconnect from IBKR backend.

disconnect() -> None

Method IBKRToolkit.get_tools

Return toolkit tools, excluding order tools when in readonly mode.

get_tools() -> List[ToolkitTool]

Returns: List[ToolkitTool]

Method IBKRToolkit.get_quote

Get real-time quote snapshot for a symbol.

get_quote(symbol: str, sec_type: str = 'STK', exchange: str = 'SMART', currency: str = 'USD') -> dict

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

Returns: dict — Quote with last, bid, ask, volume.

Method IBKRToolkit.get_historical_bars

Get historical OHLCV bars for a symbol.

get_historical_bars(symbol: str, duration: str = '1 D', bar_size: str = '1 hour', sec_type: str = 'STK', exchange: str = 'SMART', currency: str = 'USD') -> list[dict]

Parameter Type Default Description
symbol str Ticker symbol.
duration str '1 D' Time duration (e.g. '1 D', '1 W', '1 M').
bar_size str '1 hour' Bar size (e.g. '1 min', '5 mins', '1 hour', '1 day').
sec_type str 'STK' Security type.
exchange str 'SMART' Exchange.
currency str 'USD' Currency.

Returns: list[dict] — List of OHLCV bars.

Method IBKRToolkit.get_options_chain

Get options chain for an underlying symbol.

get_options_chain(symbol: str, expiry: Optional[str] = None) -> list[dict]

Parameter Type Default Description
symbol str Underlying ticker symbol.
expiry Optional[str] None Optional expiration date filter (YYYYMMDD).

Returns: list[dict] — Options chain data.

Method IBKRToolkit.search_contracts

Search for contracts matching a pattern.

search_contracts(pattern: str, sec_type: str = 'STK') -> list[dict]

Parameter Type Default Description
pattern str Symbol or name search pattern.
sec_type str 'STK' Security type filter.

Returns: list[dict] — List of matching contracts.

Method IBKRToolkit.run_scanner

Run an IBKR market scanner.

run_scanner(scan_code: str, num_results: int = 25) -> list[dict]

Parameter Type Default Description
scan_code str Scanner code (e.g. TOP_PERC_GAIN, HOT_BY_PRICE).
num_results int 25 Number of results to return.

Returns: list[dict] — Scanner results.

Method IBKRToolkit.place_order

Place a new order (subject to risk checks).

place_order(symbol: str, action: str, quantity: int, order_type: str = 'LMT', limit_price: Optional[float] = None, stop_price: Optional[float] = None, tif: str = 'DAY') -> dict

Parameter Type Default Description
symbol str Ticker symbol.
action str BUY or SELL.
quantity int Order quantity.
order_type str 'LMT' Order type: MKT, LMT, STP, or STP_LMT.
limit_price Optional[float] None Limit price (required for LMT and STP_LMT).
stop_price Optional[float] None Stop price (required for STP and STP_LMT).
tif str 'DAY' Time in force: DAY, GTC, IOC, or FOK.

Returns: dict — Order status with order_id.

Method IBKRToolkit.modify_order

Modify an existing open order (subject to risk checks).

modify_order(order_id: int, quantity: Optional[int] = None, limit_price: Optional[float] = None, stop_price: Optional[float] = None) -> dict

Parameter Type Default Description
order_id int The order ID to modify.
quantity Optional[int] None New quantity (optional).
limit_price Optional[float] None New limit price (optional).
stop_price Optional[float] None New stop price (optional).

Returns: dict — Updated order status.

Method IBKRToolkit.cancel_order

Cancel an open order.

cancel_order(order_id: int) -> dict

Parameter Type Default Description
order_id int The order ID to cancel.

Returns: dict — Cancellation result.

Method IBKRToolkit.get_open_orders

Get all currently open orders.

get_open_orders() -> list[dict]

Returns: list[dict] — List of open order statuses.

Method IBKRToolkit.get_account_summary

Get account summary information.

get_account_summary() -> dict

Returns: dict — Account summary with net liquidation, cash, buying power, P&L.

Method IBKRToolkit.get_positions

Get all current positions.

get_positions() -> list[dict]

Returns: list[dict] — List of positions with symbol, quantity, cost, P&L.

Method IBKRToolkit.get_pnl

Get daily P&L breakdown.

get_pnl() -> dict

Returns: dict — Daily, unrealized, and realized P&L.

Method IBKRToolkit.get_trades

Get recent trade executions.

get_trades(days: int = 1) -> list[dict]

Parameter Type Default Description
days int 1 Number of days to look back.

Returns: list[dict] — List of recent trades.

Method IBKRToolkit.get_news

Get market news, optionally filtered by symbol.

get_news(symbol: Optional[str] = None, num_articles: int = 5) -> list[dict]

Parameter Type Default Description
symbol Optional[str] None Optional symbol to filter news.
num_articles int 5 Number of articles to retrieve.

Returns: list[dict] — List of news articles.

Method IBKRToolkit.get_fundamentals

Get fundamental data for a symbol.

get_fundamentals(symbol: str) -> dict

Parameter Type Default Description
symbol str Ticker symbol.

Returns: dict — Fundamental data including financials.

Alias OrderRequest

Re-exported from parrot_tools.ibkr.models.OrderRequest.

Alias OrderStatus

Re-exported from parrot_tools.ibkr.models.OrderStatus.

Alias PortalBackend

Re-exported from parrot_tools.ibkr.portal_backend.PortalBackend.

Alias Position

Re-exported from parrot_tools.ibkr.models.Position.

Alias Quote

Re-exported from parrot_tools.ibkr.models.Quote.

Alias RiskCheckResult

Re-exported from parrot_tools.ibkr.risk.RiskCheckResult.

Alias RiskConfig

Re-exported from parrot_tools.ibkr.models.RiskConfig.

Alias RiskManager

Re-exported from parrot_tools.ibkr.risk.RiskManager.

Alias TWSBackend

Re-exported from parrot_tools.ibkr.tws_backend.TWSBackend.

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