Python API

The Python surface mirrors the Rust API and is generated from the same source on every release.

Python API Reference (v0.5.1)

Auto-generated from source — do not edit.

Table of Contents

Connection

new

Create a new EClient (or EWrapper) instance.

def new(wrapper))
ParameterTypeDescription
wrapperPy<PyAny>Wrapper callback receiver for synchronous delivery.

connect

Connect to IB and start the engine. Live logins (paper=False) enter a second-factor approval window and block until the factor is approved (mobile push) or the deadline fires (ib_key_timeout_secs, default ~18 min). This is a human approval gate, not a hang. To bound or avoid it: use paper=True, pass a smaller ib_key_timeout_secs, or run connect() on a worker thread with your own timeout. Paper logins skip the gate entirely. Set RUST_LOG=info to see a log line when the wait begins. Multiple EClient instances can run concurrently in one process; each owns its own state, sockets, and engine thread, and connect() does not serialize across instances. If you pin engines via core_id, give each a distinct value. See ibx#203 / ibx#207.

def connect(host="cdc1.ibllc.com".to_string(), port=0, client_id=0, username="".to_string(), password="".to_string(), paper=true, core_id=None, ib_key_timeout_secs=None, ib_key_token_sub_type=None))
ParameterTypeDescription
hoststrServer hostname.
portintPort number (unused — ibx connects directly).
client_idintClient ID (unused — single-client engine).
usernamestrAccount username.
passwordstrAccount password.
paperboolIf true, connect to paper trading. If false, connect blocks on the live second-factor approval window (see method note).
core_idusize or NoneCPU core affinity for the hot loop thread. Use a distinct value per engine when running several in one process.
ib_key_timeout_secsint or NoneLive second-factor approval timeout in seconds (default ~18 min). Lower it to fail fast on unattended live logins; ignored for paper.
ib_key_token_sub_typestr or NoneAccount-specific second-factor token sub-type (default "2a"); ignored for paper.

disconnect

Disconnect from IB.

def disconnect()

is_connected

Check if connected.

def is_connected()

run

Run the event loop.

def run()

get_account_id

Get the account ID.

def get_account_id()

Account & Portfolio

req_pnl

Request P&L updates for the account.

def req_pnl(req_id, account, model_code=""))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
model_codestrModel portfolio code (empty for default).

cancel_pnl

Cancel P&L subscription.

def cancel_pnl(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_pnl_single

Request P&L for a single position.

def req_pnl_single(req_id, account, model_code, con_id))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
model_codestrModel portfolio code (empty for default).
con_idintContract ID. Unique per instrument.

cancel_pnl_single

Cancel single-position P&L subscription.

def cancel_pnl_single(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_account_summary

Request account summary.

def req_account_summary(req_id, group_name, tags))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
group_namestrAccount group name (e.g. "All").
tagsstrComma-separated account tags: "NetLiquidation,BuyingPower,...".

cancel_account_summary

Cancel account summary.

def cancel_account_summary(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_positions

Request all positions.

def req_positions()

cancel_positions

Cancel positions.

def cancel_positions()

req_account_updates

Request account updates.

def req_account_updates(subscribe, _acct_code=""))
ParameterTypeDescription
subscribebooltrue to start updates, false to stop.
acct_codestrAccount code (e.g. "DU1234567").

req_managed_accts

Request managed accounts list.

def req_managed_accts()

req_account_updates_multi

Request account updates for multiple accounts/models.

def req_account_updates_multi(req_id, account, model_code, ledger_and_nlv=false))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
model_codestrModel portfolio code (empty for default).
ledger_and_nlvboolIf true, include ledger and NLV data.

cancel_account_updates_multi

Cancel multi-account updates.

def cancel_account_updates_multi(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_positions_multi

Request positions across multiple accounts/models.

def req_positions_multi(req_id, account, model_code))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
model_codestrModel portfolio code (empty for default).

cancel_positions_multi

Cancel multi-account positions.

def cancel_positions_multi(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

account_snapshot

Read account state snapshot. Returns a dict with all account values.

def account_snapshot()

Orders

place_order

Place an order.

def place_order(order_id, contract, order)
ParameterTypeDescription
order_idintOrder identifier. Must be unique per session.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
orderOrderOrder parameters (action, quantity, type, price, TIF, etc.).

cancel_order

Cancel an order.

def cancel_order(order_id, manual_order_cancel_time=""))
ParameterTypeDescription
order_idintOrder identifier. Must be unique per session.
manual_order_cancel_timestrManual cancel time (empty for immediate).

req_global_cancel

Cancel all orders globally.

def req_global_cancel()

req_ids

Request next valid order ID.

def req_ids(num_ids=1))
ParameterTypeDescription
num_idsintNumber of IDs to reserve (unused).

next_order_id

Get the next order ID (local counter, auto-increments).

def next_order_id()

req_open_orders

Request all open orders for this client.

def req_open_orders()

req_all_open_orders

Request all open orders across all clients.

def req_all_open_orders()

req_auto_open_orders

Automatically bind future orders to this client.

def req_auto_open_orders(b_auto_bind))
ParameterTypeDescription
b_auto_bindboolIf true, auto-bind future orders to this client.

req_executions

Request execution reports.

def req_executions(req_id, exec_filter=None))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
exec_filterPy<PyAny> or None

req_completed_orders

Request completed orders.

def req_completed_orders(api_only=false))
ParameterTypeDescription
api_onlybool

Market Data

set_news_providers

Set news provider codes for per-contract news ticks (e.g. "BRFG*BRFUPDN").

def set_news_providers(providers))
ParameterTypeDescription
providersstrNews provider list.

req_mkt_data

Request market data for a contract.

def req_mkt_data(req_id, contract, generic_tick_list="", snapshot=false, regulatory_snapshot=false, mkt_data_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
generic_tick_liststrComma-separated generic tick IDs (e.g. "233" for RT volume).
snapshotboolIf true, delivers one quote then auto-cancels.
regulatory_snapshotboolIf true, request a regulatory snapshot (additional fees may apply).
mkt_data_optionslist

cancel_mkt_data

Cancel market data subscription.

def cancel_mkt_data(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_tick_by_tick_data

Request tick-by-tick data.

def req_tick_by_tick_data(req_id, contract, tick_type, number_of_ticks=0, ignore_size=false))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
tick_typestrTick type ID or tick-by-tick type string.
number_of_ticksintMaximum number of ticks to return.
ignore_sizeboolIf true, ignore size in tick-by-tick data.

cancel_tick_by_tick_data

Cancel tick-by-tick data.

def cancel_tick_by_tick_data(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_market_data_type

Set market data type (1=live, 2=frozen, 3=delayed, 4=delayed-frozen).

def req_market_data_type(market_data_type)
ParameterTypeDescription
market_data_typeint1=live, 2=frozen, 3=delayed, 4=delayed-frozen.

req_mkt_depth

Request market depth (L2 order book).

def req_mkt_depth(req_id, contract, num_rows=5, is_smart_depth=false, mkt_depth_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
num_rowsintNumber of order book rows to subscribe to.
is_smart_depthboolIf true, aggregate depth from multiple exchanges via SMART.
mkt_depth_optionslist

cancel_mkt_depth

Cancel market depth.

def cancel_mkt_depth(req_id, is_smart_depth=false))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
is_smart_depthboolIf true, aggregate depth from multiple exchanges via SMART.

req_real_time_bars

Request real-time 5-second bars.

def req_real_time_bars(req_id, contract, bar_size=5, what_to_show="TRADES", use_rth=0, real_time_bars_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
bar_sizeintBar size: "1 min", "5 mins", "1 hour", "1 day", etc.
what_to_showstrData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthintIf true, only return data from Regular Trading Hours.
real_time_bars_optionslist

cancel_real_time_bars

Cancel real-time bars.

def cancel_real_time_bars(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

quote

Zero-copy SeqLock quote read by req_id. Returns a dict with bid, ask, last, bid_size, ask_size, last_size, volume, high, low, open, close, or None if the req_id is not mapped.

def quote(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

quote_by_instrument

Zero-copy SeqLock quote read by InstrumentId. Returns a dict with bid, ask, last, bid_size, ask_size, last_size, volume, high, low, open, close, or None if not connected.

def quote_by_instrument(instrument)
ParameterTypeDescription
instrumentintInstrument type for scanner (e.g. "STK", "FUT").

Reference Data

req_historical_data

Request historical bar data.

def req_historical_data(req_id, contract, end_date_time, duration_str, bar_size_setting, what_to_show, use_rth, format_date=1, keep_up_to_date=false, chart_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
end_date_timestrEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
duration_strstrDuration string, e.g. "1 D", "1 W", "1 M", "1 Y".
bar_size_settingstrBar size: "1 min", "5 mins", "1 hour", "1 day", etc.
what_to_showstrData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthintIf true, only return data from Regular Trading Hours.
format_dateintDate format: 1="YYYYMMDD HH:MM:SS", 2=Unix seconds.
keep_up_to_dateboolIf true, continue receiving updates after initial history.
chart_optionslist

cancel_historical_data

Cancel historical data.

def cancel_historical_data(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_head_time_stamp

Request head timestamp.

def req_head_time_stamp(req_id, contract, what_to_show, use_rth, format_date=1))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
what_to_showstrData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthintIf true, only return data from Regular Trading Hours.
format_dateintDate format: 1="YYYYMMDD HH:MM:SS", 2=Unix seconds.

cancel_head_time_stamp

Cancel head timestamp request.

def cancel_head_time_stamp(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_contract_details

Request contract details.

def req_contract_details(req_id, contract)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).

req_mkt_depth_exchanges

Request available exchanges for market depth.

def req_mkt_depth_exchanges()

req_matching_symbols

Search for matching symbols.

def req_matching_symbols(req_id, pattern)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
patternstrSymbol search pattern.

req_scanner_subscription

Request scanner subscription.

def req_scanner_subscription(req_id, subscription, scanner_subscription_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
subscriptionPy<PyAny>Scanner subscription parameters.
scanner_subscription_optionslist

cancel_scanner_subscription

Cancel scanner subscription.

def cancel_scanner_subscription(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_scanner_parameters

Request scanner parameters XML.

def req_scanner_parameters()

req_news_article

Request a news article.

def req_news_article(req_id, provider_code, article_id, news_article_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
provider_codestrNews provider code (e.g. "BRFG").
article_idstrNews article identifier.
news_article_optionslist

req_historical_news

Request historical news.

def req_historical_news(req_id, con_id, provider_codes, start_date_time, end_date_time, total_results, historical_news_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
con_idintContract ID. Unique per instrument.
provider_codesstrPipe-separated news provider codes.
start_date_timestrStart date/time for tick query.
end_date_timestrEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
total_resultsintMaximum number of news results.
historical_news_optionslist

req_fundamental_data

Request fundamental data.

def req_fundamental_data(req_id, contract, report_type, fundamental_data_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
report_typestrReport type: "ReportSnapshot", "ReportsFinSummary", "RESC", etc.
fundamental_data_optionslist

cancel_fundamental_data

Cancel fundamental data.

def cancel_fundamental_data(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_historical_ticks

Request historical tick data.

def req_historical_ticks(req_id, contract, start_date_time="", end_date_time="", number_of_ticks=1000, what_to_show="TRADES", use_rth=1, ignore_size=false, misc_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
start_date_timestrStart date/time for tick query.
end_date_timestrEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
number_of_ticksintMaximum number of ticks to return.
what_to_showstrData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthintIf true, only return data from Regular Trading Hours.
ignore_sizeboolIf true, ignore size in tick-by-tick data.
misc_optionslist

req_market_rule

Request market rule details.

def req_market_rule(market_rule_id)
ParameterTypeDescription
market_rule_idintMarket rule ID.

req_histogram_data

Request histogram data.

def req_histogram_data(req_id, contract, use_rth, time_period))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
use_rthboolIf true, only return data from Regular Trading Hours.
time_periodstrHistogram time period.

cancel_histogram_data

Cancel histogram data.

def cancel_histogram_data(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_historical_schedule

Request historical trading schedule.

def req_historical_schedule(req_id, contract, end_date_time="", duration_str="1 M", use_rth=true))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
end_date_timestrEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
duration_strstrDuration string, e.g. "1 D", "1 W", "1 M", "1 Y".
use_rthboolIf true, only return data from Regular Trading Hours.

Gateway-Local & Stubs

calculate_implied_volatility

Calculate option implied volatility. Not yet implemented.

def calculate_implied_volatility(req_id, contract, option_price, under_price, implied_vol_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
option_pricefloatOption market price.
under_pricefloatUnderlying asset price.
implied_vol_optionslist

calculate_option_price

Calculate option theoretical price. Not yet implemented.

def calculate_option_price(req_id, contract, volatility, under_price, opt_prc_options=Vec::new()))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
volatilityfloatImplied volatility.
under_pricefloatUnderlying asset price.
opt_prc_optionslist

cancel_calculate_implied_volatility

Cancel implied volatility calculation.

def cancel_calculate_implied_volatility(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

cancel_calculate_option_price

Cancel option price calculation.

def cancel_calculate_option_price(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

exercise_options

Exercise options. Not yet implemented.

def exercise_options(req_id, contract, exercise_action, exercise_quantity, account, _override))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractContractContract specification (symbol, secType, exchange, currency, etc.).
exercise_actionint1=exercise, 2=lapse.
exercise_quantityintNumber of contracts to exercise.
accountstrAccount ID.
overrideintOverride flag for exercise.

req_sec_def_opt_params

Request option chain parameters. Not yet implemented.

def req_sec_def_opt_params(req_id, underlying_symbol, fut_fop_exchange="", underlying_sec_type="STK", underlying_con_id=0))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
underlying_symbolstrUnderlying symbol (e.g. "AAPL").
fut_fop_exchangestrExchange for futures/FOP options.
underlying_sec_typestrUnderlying security type (e.g. "STK").
underlying_con_idintUnderlying contract ID.

req_news_bulletins

Subscribe to news bulletins.

def req_news_bulletins(all_msgs=true))
ParameterTypeDescription
all_msgsboolIf true, receive all existing bulletins on subscribe.

cancel_news_bulletins

Cancel news bulletin subscription.

def cancel_news_bulletins()

req_current_time

Request current server time.

def req_current_time()

request_fa

Request FA data. Not yet implemented.

def request_fa(_fa_data_type)
ParameterTypeDescription
fa_data_typeintFA data type (1=Groups, 2=Profiles, 3=Aliases).

replace_fa

Replace FA data. Not yet implemented.

def replace_fa(req_id, fa_data_type, cxml))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
fa_data_typeintFA data type (1=Groups, 2=Profiles, 3=Aliases).
cxmlstrFA XML configuration data.

query_display_groups

Query display groups.

def query_display_groups(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

subscribe_to_group_events

Subscribe to display group events.

def subscribe_to_group_events(req_id, group_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
group_idintDisplay group ID.

unsubscribe_from_group_events

Unsubscribe from display group events.

def unsubscribe_from_group_events(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

update_display_group

Update display group.

def update_display_group(req_id, contract_info)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contract_infostrDisplay group contract info string.

req_smart_components

Request SMART routing component exchanges.

def req_smart_components(req_id, bbo_exchange)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
bbo_exchangestrBBO exchange for smart component lookup (e.g. "SMART").

req_news_providers

Request available news providers.

def req_news_providers()

req_soft_dollar_tiers

Request soft dollar tiers.

def req_soft_dollar_tiers(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_family_codes

Request family codes.

def req_family_codes()

set_server_log_level

Set server log level (1=error..5=trace).

def set_server_log_level(log_level=2))
ParameterTypeDescription
log_levelintLog level: 1=error, 2=warn, 3=info, 4=debug, 5=trace.

req_user_info

Request user info (white branding ID).

def req_user_info(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_wsh_meta_data

Request Wall Street Horizon metadata. Not yet implemented.

def req_wsh_meta_data(req_id)
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

req_wsh_event_data

Request Wall Street Horizon event data. Not yet implemented.

def req_wsh_event_data(req_id, wsh_event_data=None))
ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
wsh_event_dataPy<PyAny> or None

EWrapper Callbacks

new

Create a new EClient (or EWrapper) instance.

ParameterTypeDescription
argsBound<'_, pyo3::types::PyTuple>
kwargsBound<'_, pyo3::types::PyDict> or None

connect_ack

Connection acknowledged.


connection_closed

Connection has been closed.


next_valid_id

Next valid order ID from the server.

ParameterTypeDescription
order_idintOrder identifier. Must be unique per session.

managed_accounts

Comma-separated list of managed account IDs.

ParameterTypeDescription
accounts_liststrComma-separated account IDs.

error

Error or informational message from the server.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
error_codeintError code.
error_stringstrError message.
advanced_order_reject_jsonstrJSON with advanced rejection details.

current_time

Current server time (Unix seconds).

ParameterTypeDescription
timeintTick timestamp (Unix seconds).

tick_price

Price tick update (bid, ask, last, etc.).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tick_typeintTick type ID or tick-by-tick type string.
pricefloatTick price.
attribPy<PyAny>Tick attributes.

tick_size

Size tick update (bid size, ask size, volume, etc.).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tick_typeintTick type ID or tick-by-tick type string.
sizefloatTick size.

tick_string

String tick (e.g. last trade timestamp).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tick_typeintTick type ID or tick-by-tick type string.
valuestrAccount value.

tick_generic

Generic numeric tick value.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tick_typeintTick type ID or tick-by-tick type string.
valuefloatAccount value.

tick_snapshot_end

Snapshot delivery complete; subscription auto-cancelled.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

market_data_type

Market data type changed (1=live, 2=frozen, 3=delayed, 4=delayed-frozen).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
market_data_typeint1=live, 2=frozen, 3=delayed, 4=delayed-frozen.

order_status

Order status update (filled, remaining, avg price, etc.).

ParameterTypeDescription
order_idintOrder identifier. Must be unique per session.
statusstrOrder status string ("Submitted", "Filled", "Cancelled", etc.).
filledfloatCumulative filled quantity.
remainingfloatRemaining quantity.
avg_fill_pricefloatAverage fill price.
perm_idintPermanent order ID assigned by the server.
parent_idintParent order ID (0 if no parent).
last_fill_pricefloatPrice of the last fill.
client_idintClient ID (unused — single-client engine).
why_heldstrReason the order is held (e.g. "locate").
mkt_cap_pricefloatMarket cap price for the order.

open_order

Open order details (contract, order, state).

ParameterTypeDescription
order_idintOrder identifier. Must be unique per session.
contractPy<PyAny>Contract specification (symbol, secType, exchange, currency, etc.).
orderPy<PyAny>Order parameters (action, quantity, type, price, TIF, etc.).
order_statePy<PyAny>Order state (status, margin, commission info).

open_order_end

End of open orders list.


exec_details

Execution fill details.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contractPy<PyAny>Contract specification (symbol, secType, exchange, currency, etc.).
executionPy<PyAny>Execution details (exec_id, time, price, shares, etc.).

exec_details_end

End of execution details list.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

commission_and_fees_report

Commission and fees report for an execution.

ParameterTypeDescription
commission_and_fees_reportPy<PyAny>

update_account_value

Account value update (key/value/currency).

ParameterTypeDescription
keystrAccount value key (e.g. "NetLiquidation", "BuyingPower").
valuestrAccount value.
currencystrCurrency code (e.g. "USD").
account_namestrAccount identifier.

update_portfolio

Portfolio position update.

ParameterTypeDescription
contractPy<PyAny>Contract specification (symbol, secType, exchange, currency, etc.).
positionfloatBook position (row index) or position size.
market_pricefloatCurrent market price.
market_valuefloatCurrent market value of position.
average_costfloatAverage cost basis.
unrealized_pnlfloatUnrealized profit/loss.
realized_pnlfloatRealized profit/loss.
account_namestrAccount identifier.

update_account_time

Account update timestamp.

ParameterTypeDescription
timestampstrTimestamp string.

account_download_end

Account data delivery complete.

ParameterTypeDescription
accountstrAccount ID.

account_summary

Account summary tag/value entry.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
tagstrAccount tag name (e.g. "NetLiquidation").
valuestrAccount value.
currencystrCurrency code (e.g. "USD").

account_summary_end

End of account summary.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

position

Position entry (account, contract, size, avg cost).

ParameterTypeDescription
accountstrAccount ID.
contractPy<PyAny>Contract specification (symbol, secType, exchange, currency, etc.).
posfloatPosition size (decimal shares).
avg_costfloatAverage cost per share.

position_end

End of positions list.


pnl

Account P&L update (daily, unrealized, realized).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
daily_pnlfloatDaily profit/loss.
unrealized_pnlfloatUnrealized profit/loss.
realized_pnlfloatRealized profit/loss.

pnl_single

Single-position P&L update.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
posfloatPosition size (decimal shares).
daily_pnlfloatDaily profit/loss.
unrealized_pnlfloatUnrealized profit/loss.
realized_pnlfloatRealized profit/loss.
valuefloatAccount value.

historical_data

Historical OHLCV bar.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
barPy<PyAny>Bar data (date, open, high, low, close, volume, wap, bar_count).

historical_data_end

End of historical data delivery.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
startstrPeriod start date/time.
endstrPeriod end date/time.

historical_data_update

Real-time bar update (keep_up_to_date=true).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
barPy<PyAny>Bar data (date, open, high, low, close, volume, wap, bar_count).

head_timestamp

Earliest available data timestamp.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
head_timestampstrEarliest available data timestamp string.

contract_details

Contract definition details.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contract_detailsPy<PyAny>

contract_details_end

End of contract details.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

symbol_samples

Matching symbol search results.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contract_descriptionsPy<PyAny>

tick_by_tick_all_last

Tick-by-tick last trade.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tick_typeintTick type ID or tick-by-tick type string.
timeintTick timestamp (Unix seconds).
pricefloatTick price.
sizefloatTick size.
tick_attrib_lastPy<PyAny>
exchangestrExchange name.
special_conditionsstrSpecial trade conditions.

tick_by_tick_bid_ask

Tick-by-tick bid/ask quote.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
timeintTick timestamp (Unix seconds).
bid_pricefloatBid price.
ask_pricefloatAsk price.
bid_sizefloatBid size.
ask_sizefloatAsk size.
tick_attrib_bid_askPy<PyAny>

tick_by_tick_mid_point

Tick-by-tick midpoint.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
timeintTick timestamp (Unix seconds).
mid_pointfloatMidpoint price.

scanner_data

Scanner result entry (rank, contract, distance).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
rankintScanner result rank (0-based).
contract_detailsPy<PyAny>
distancestrScanner distance metric.
benchmarkstrScanner benchmark.
projectionstrScanner projection.
legs_strstrCombo legs description.

scanner_data_end

End of scanner results.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

scanner_parameters

Scanner parameters XML.

ParameterTypeDescription
xmlstrXML string.

news_providers

Available news providers list.

ParameterTypeDescription
news_providersPy<PyAny>

news_article

Full news article text.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
article_typeintArticle type: 0=plain text, 1=HTML.
article_textstrFull article body.

historical_news

Historical news headline.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
timestrTick timestamp (Unix seconds).
provider_codestrNews provider code (e.g. "BRFG").
article_idstrNews article identifier.
headlinestrNews headline text.

historical_news_end

End of historical news.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
has_moreboolIf true, more results available.

tick_news

Per-contract news tick.

ParameterTypeDescription
ticker_idintTicker/request ID.
time_stampintTimestamp string.
provider_codestrNews provider code (e.g. "BRFG").
article_idstrNews article identifier.
headlinestrNews headline text.
extra_datastrAdditional tick data.

update_mkt_depth

L2 book update (single exchange).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
positionintBook position (row index) or position size.
operationintBook operation: 0=insert, 1=update, 2=delete.
sideintBook side: 0=ask, 1=bid. Or order side "BOT"/"SLD".
pricefloatTick price.
sizefloatTick size.

update_mkt_depth_l2

L2 book update (with market maker).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
positionintBook position (row index) or position size.
market_makerstrMarket maker ID.
operationintBook operation: 0=insert, 1=update, 2=delete.
sideintBook side: 0=ask, 1=bid. Or order side "BOT"/"SLD".
pricefloatTick price.
sizefloatTick size.
is_smart_depthboolIf true, aggregate depth from multiple exchanges via SMART.

mkt_depth_exchanges

Available exchanges for market depth.

ParameterTypeDescription
depth_mkt_data_descriptionsPy<PyAny>

real_time_bar

Real-time 5-second OHLCV bar.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
dateintBar date string.
openfloatOpen price.
highfloatHigh price.
lowfloatLow price.
closefloatClose price.
volumefloatVolume.
wapfloatVolume-weighted average price.
countintTrade count.

historical_ticks

Historical tick data (Last, BidAsk, or Midpoint).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
ticksPy<PyAny>Historical tick data.
doneboolIf true, all ticks have been delivered.

historical_ticks_bid_ask

Historical bid/ask ticks.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
ticksPy<PyAny>Historical tick data.
doneboolIf true, all ticks have been delivered.

historical_ticks_last

Historical last-trade ticks.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
ticksPy<PyAny>Historical tick data.
doneboolIf true, all ticks have been delivered.

tick_option_computation

Option implied vol / greeks computation.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tick_typeintTick type ID or tick-by-tick type string.
tick_attribint
implied_volfloatImplied volatility.
deltafloatOption delta.
opt_pricefloatOption theoretical price.
pv_dividendfloatPresent value of dividends.
gammafloatOption gamma.
vegafloatOption vega.
thetafloatOption theta.
und_pricefloatUnderlying price.

security_definition_option_parameter

Option chain parameters (strikes, expirations).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
exchangestrExchange name.
underlying_con_idintUnderlying contract ID.
trading_classstrTrading class.
multiplierstrContract multiplier.
expirationsPy<PyAny>Available expiration dates.
strikesPy<PyAny>Available strike prices.

security_definition_option_parameter_end

End of option chain parameters.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

fundamental_data

Fundamental data (XML/JSON).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
datastrRaw data string (XML/JSON).

update_news_bulletin

News bulletin message.

ParameterTypeDescription
msg_idintBulletin message ID.
msg_typeintBulletin message type (1=regular, 2=exchange).
messagestrBulletin message text.
orig_exchangestrOriginating exchange.

receive_fa

Financial advisor data received.

ParameterTypeDescription
fa_data_typeintFA data type (1=Groups, 2=Profiles, 3=Aliases).
xmlstrXML string.

replace_fa_end

Financial advisor replace complete.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
textstrInformational text.

position_multi

Multi-account position entry.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
model_codestrModel portfolio code (empty for default).
contractPy<PyAny>Contract specification (symbol, secType, exchange, currency, etc.).
posfloatPosition size (decimal shares).
avg_costfloatAverage cost per share.

position_multi_end

End of multi-account positions.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

account_update_multi

Multi-account value update.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
accountstrAccount ID.
model_codestrModel portfolio code (empty for default).
keystrAccount value key (e.g. "NetLiquidation", "BuyingPower").
valuestrAccount value.
currencystrCurrency code (e.g. "USD").

account_update_multi_end

End of multi-account updates.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.

display_group_list

Display group list.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
groupsstrFA group definitions.

display_group_updated

Display group updated.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contract_infostrDisplay group contract info string.

market_rule

Market rule: price increment schedule.

ParameterTypeDescription
market_rule_idintMarket rule ID.
price_incrementsPy<PyAny>Price increment rules [{low_edge, increment}].

smart_components

SMART routing component exchanges.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
smart_component_mapPy<PyAny>

soft_dollar_tiers

Soft dollar tier list.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
tiersPy<PyAny>Soft dollar tier list.

family_codes

Family codes linking related accounts.

ParameterTypeDescription
family_codesPy<PyAny>

histogram_data

Price distribution histogram.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
itemsPy<PyAny>Histogram entries [(price, count)].

user_info

User info (white branding ID).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
white_branding_idstrWhite branding ID (empty for standard accounts).

wsh_meta_data

Wall Street Horizon metadata.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
data_jsonstr

wsh_event_data

Wall Street Horizon event data.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
data_jsonstr

completed_order

Completed (filled/cancelled) order details.

ParameterTypeDescription
contractPy<PyAny>Contract specification (symbol, secType, exchange, currency, etc.).
orderPy<PyAny>Order parameters (action, quantity, type, price, TIF, etc.).
order_statePy<PyAny>Order state (status, margin, commission info).

completed_orders_end

End of completed orders list.


order_bound

Order bound to a perm ID.

ParameterTypeDescription
order_idintOrder identifier. Must be unique per session.
api_client_idint
api_order_idint

tick_req_params

Tick parameters: min tick size, BBO exchange, snapshot permissions.

ParameterTypeDescription
ticker_idintTicker/request ID.
min_tickfloatMinimum tick size.
bbo_exchangestrBBO exchange for smart component lookup (e.g. "SMART").
snapshot_permissionsintSnapshot permissions bitmask.

bond_contract_details

Bond contract details.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
contract_detailsPy<PyAny>

delta_neutral_validation

Delta-neutral validation response.

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
delta_neutral_contractPy<PyAny>

historical_schedule

Historical trading schedule (exchange hours).

ParameterTypeDescription
req_idintRequest identifier. Used to match responses to requests.
start_date_timestrStart date/time for tick query.
end_date_timestrEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
time_zonestrTimezone string (e.g. "US/Eastern").
sessionsPy<PyAny>Trading sessions [(ref_date, open, close)].