Rust API

The full Rust API reference is published on docs.rs/ibx — auto-generated from doc comments on every release.

Snapshot reference (this release)

A markdown snapshot of the Rust surface — grouped by area, with signatures and field tables — is included below for offline reading. It is regenerated on each release.

Rust API Reference (v0.7.1)

Auto-generated from source — do not edit.

Table of Contents

Connection

connect

Connect to IB and start the engine.

pub fn connect(config: &EClientConfig) -> Result<Self, Box<dyn std::error::Error>>
ParameterTypeDescription
config&EClientConfigConnection configuration (username, password, host, paper, core_id).

Returns: Result<Self, Box<dyn std::error::Error>>


connect_with_events

Connect to IB and start the engine with an [Event] channel attached. Returns the client plus a receiver carrying every [Event] the engine produces. This is a second, optional delivery path that runs alongside process_msgs() — it does not replace it, and nothing is removed from the wrapper callbacks when it is in use. The channel is bounded by capacity; the engine never blocks on it, so a consumer that falls behind loses events rather than slowing the hot loop. Drain it from a thread that is not the one calling process_msgs(), or keep capacity generous. Attaching a channel makes the engine build events it would otherwise skip, which for bar batches and contract definitions means one deep copy each. Use connect() when you only need the wrapper callbacks (ibx#242).

pub fn connect_with_events( config: &EClientConfig, capacity: usize, ) -> Result<(Self, Receiver<Event>), Box<dyn std::error::Error>>
ParameterTypeDescription
config&EClientConfigConnection configuration (username, password, host, paper, core_id).
capacityusize

Returns: Result<(Self, Receiver<Event>), Box<dyn std::error::Error>>


from_parts

Construct from pre-built components (for testing or custom setups).

pub fn from_parts( shared: Arc<SharedState>, control_tx: Sender<ControlCommand>, handle: thread::JoinHandle<()>, account_id: String, ) -> Self
ParameterTypeDescription
sharedArc<SharedState>Shared state handle.
control_txSender<ControlCommand>Control channel sender.
handlethread::JoinHandle<(Background thread handle.

Returns: Self


map_req_instrument

Map a reqId to an InstrumentId (for testing without a live engine).

pub fn map_req_instrument(&self, req_id: i64, instrument: InstrumentId)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
instrumentInstrumentIdInstrument type for scanner (e.g. "STK", "FUT").

track_order_for_test

Pre-populate the order tracker (for testing the dispatcher path without going through the engine's place-order flow).

pub fn track_order_for_test( &self, order_id: u64, contract: ApiContract, order: ApiOrder, instrument: InstrumentId, )
ParameterTypeDescription
order_idu64Order identifier. Must be unique per session.
contractApiContractContract specification (symbol, secType, exchange, currency, etc.).
orderApiOrderOrder parameters (action, quantity, type, price, TIF, etc.).
instrumentInstrumentIdInstrument type for scanner (e.g. "STK", "FUT").

seed_instrument

Pre-seed a con_id → InstrumentId mapping (for testing without a live engine).

pub fn seed_instrument(&self, con_id: i64, instrument: InstrumentId)
ParameterTypeDescription
con_idi64Contract ID. Unique per instrument.
instrumentInstrumentIdInstrument type for scanner (e.g. "STK", "FUT").

is_connected

False after disconnect(), and after a process_msgs() call that observed the engine stopping (ibx#242).

pub fn is_connected(&self) -> bool

Returns: bool


disconnect

Disconnect from IB. Sends Shutdown to the hot loop, waits for the background thread to exit, and marks the client as disconnected.

pub fn disconnect(&self)

ccp_session_id

Session ID surfaced to webapp REST clients as x-ccp-session-id.

pub fn ccp_session_id(&self) -> String

Returns: String


misc_url

Logical-name → host URL lookup from the gateway logon MiscUrls push (e.g. region_dam). Returns None when the gateway did not push this key.

pub fn misc_url(&self, key: &str) -> Option<String>
ParameterTypeDescription
key&strAccount value key (e.g. "NetLiquidation", "BuyingPower").

Returns: Option<String>


session_token_bytes

Canonical big-endian session-token bytes (leading zeros stripped) captured at connect. Round-trips through BigUint::from_bytes_be to the SRP shared secret K and is the second SHA-1 input for SSO Authenticate-TWS bodies.

pub fn session_token_bytes(&self) -> &[u8]

Returns: &[u8]


token_type

stoken_type discriminator captured at connect ("st", "tst", "zenith", or empty for the SRP-only path). Sent verbatim in SSO authenticator bodies.

pub fn token_type(&self) -> &str

Returns: &str


Account & Portfolio

req_positions

Request positions. Waits for server-pushed account data before delivering, then calls position_end.

pub fn req_positions(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_pnl

Subscribe to account PnL updates.

pub fn req_pnl(&self, req_id: i64, _account: &str, _model_code: &str)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
account&strAccount ID.
model_code&strModel portfolio code (empty for default).

cancel_pnl

Cancel PnL subscription.

pub fn cancel_pnl(&self, req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

req_pnl_single

Subscribe to single-position PnL updates.

pub fn req_pnl_single(&self, req_id: i64, _account: &str, _model_code: &str, con_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
account&strAccount ID.
model_code&strModel portfolio code (empty for default).
con_idi64Contract ID. Unique per instrument.

cancel_pnl_single

Cancel single-position PnL subscription.

pub fn cancel_pnl_single(&self, req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

req_account_summary

Request account summary.

pub fn req_account_summary(&self, req_id: i64, _group: &str, tags: &str)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
group&strAccount group name (e.g. "All").
tags&strComma-separated account tags: "NetLiquidation,BuyingPower,...".

cancel_account_summary

Cancel account summary.

pub fn cancel_account_summary(&self, req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

req_account_updates

Subscribe to account updates.

pub fn req_account_updates(&self, subscribe: bool, _acct_code: &str)
ParameterTypeDescription
subscribebooltrue to start updates, false to stop.
acct_code&strAccount code (e.g. "DU1234567").

cancel_positions

Cancel positions subscription.

pub fn cancel_positions(&self)

req_managed_accts

Request managed accounts.

pub fn req_managed_accts(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_account_updates_multi

Request account updates for multiple accounts/models.

pub fn req_account_updates_multi( &self, _req_id: i64, _account: &str, _model_code: &str, _ledger_and_nlv: bool, wrapper: &mut impl Wrapper, )
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
account&strAccount ID.
model_code&strModel portfolio code (empty for default).
ledger_and_nlvboolIf true, include ledger and NLV data.
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

cancel_account_updates_multi

Cancel multi-account updates.

pub fn cancel_account_updates_multi(&self, _req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

req_positions_multi

Request positions for multiple accounts/models.

pub fn req_positions_multi( &self, _req_id: i64, _account: &str, _model_code: &str, wrapper: &mut impl Wrapper, )
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
account&strAccount ID.
model_code&strModel portfolio code (empty for default).
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

cancel_positions_multi

Cancel multi-account positions.

pub fn cancel_positions_multi(&self, _req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

account

Read account state snapshot.

pub fn account(&self) -> AccountState

Returns: AccountState


Orders

place_order

Place an order.

pub fn place_order(&self, order_id: i64, contract: &Contract, order: &Order) -> Result<(), String>
ParameterTypeDescription
order_idi64Order identifier. Must be unique per session.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
order&OrderOrder parameters (action, quantity, type, price, TIF, etc.).

Returns: Result<(), String>


cancel_order

Cancel an order.

pub fn cancel_order(&self, order_id: i64, _manual_order_cancel_time: &str) -> Result<(), String>
ParameterTypeDescription
order_idi64Order identifier. Must be unique per session.
manual_order_cancel_time&strManual cancel time (empty for immediate).

Returns: Result<(), String>


cancel_order_by_perm_id

Cancel an order identified by permId — stable across sessions. permId is the broker-assigned identifier returned in order_status callbacks and surfaced in account tools. Useful for cancelling an order placed in a prior session, where the local order_id is not retained. Per ib-agent#154 the CCP cancel frame is orderId-only, so ibx looks up the local order_id from permId in the open-order cache (populated by place_order callbacks or by the CCP session-recovery push hydrated in handle_exec_report). Fails if perm_id is not currently tracked.

pub fn cancel_order_by_perm_id(&self, perm_id: i64) -> Result<(), String>
ParameterTypeDescription
perm_idi64Permanent order ID assigned by the server.

Returns: Result<(), String>


req_global_cancel

Cancel all orders.

pub fn req_global_cancel(&self) -> Result<(), String>

Returns: Result<(), String>


req_ids

Request next valid order ID.

pub fn req_ids(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

next_order_id

Get the next order ID (local counter).

pub fn next_order_id(&self) -> i64

Returns: i64


req_open_orders

Request open orders for this client.

pub fn req_open_orders(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_all_open_orders

Request all open orders.

pub fn req_all_open_orders(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_completed_orders

Request completed orders. Immediately delivers all archived completed orders, then calls completed_orders_end.

pub fn req_completed_orders(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_auto_open_orders

Automatically bind future orders to this client.

pub fn req_auto_open_orders(&self, _b_auto_bind: bool)
ParameterTypeDescription
b_auto_bindboolIf true, auto-bind future orders to this client.

req_executions

Request execution reports. Replays stored executions (optionally filtered), firing exec_details + commission_and_fees_report for each, then exec_details_end.

pub fn req_executions(&self, req_id: i64, filter: &ExecutionFilter, wrapper: &mut impl Wrapper)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
filter&ExecutionFilterExecution filter (client_id, acct_code, time, symbol, sec_type, exchange, side).
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

parse_algo_params

Parse algo strategy and TagValue params into internal AlgoParams.

pub fn parse_algo_params(strategy: &str, params: &[TagValue]) -> Result<AlgoParams, String>
ParameterTypeDescription
strategy&strAlgo strategy name (e.g. "Vwap", "Twap").
params&[TagValue]Algo parameter list.

Returns: Result<AlgoParams, String>


Market Data

req_mkt_data

Subscribe to market data. When snapshot is true, delivers the first available quote then calls tick_snapshot_end and auto-cancels the subscription. generic_tick_list is NOT transmitted to the gateway, with one exception: "292" additionally subscribes per-contract news. Other generic tick types (RTVolume and friends) have no emission path, and tick_generic never fires (ibx#234). Delayed data cannot be requested either — see req_market_data_type.

pub fn req_mkt_data( &self, req_id: i64, contract: &Contract, generic_tick_list: &str, snapshot: bool, regulatory_snapshot: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
generic_tick_list&strComma-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).

Returns: Result<(), String>


req_mkt_data_ex

Like [req_mkt_data], but encodes the market-data mode per-request via FIX field 9887, allowing parallel realtime + frozen subscriptions for the same contract: | mode_9887 | mode | wire shape | |-------------|------------------|---| | 0 | REALTIME | 264=442 (BID_ASK) + 264=443 (LAST), no 9887 | | 1 | DELAYED | 264=1 (TOP) + 9887=1 | | 2 | FROZEN | 264=1 (TOP) + 9887=2 | | 3 | DELAYED_FROZEN | 264=1 (TOP) + 9887=3 | The frozen sub keeps thinly-traded names streaming after-hours when the realtime feed is silent. Issue 3-4 parallel calls per contract with different modes and pick whichever feed has data.

pub fn req_mkt_data_ex( &self, req_id: i64, contract: &Contract, generic_tick_list: &str, snapshot: bool, _regulatory_snapshot: bool, mode_9887: i32, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
generic_tick_list&strComma-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).
mode_9887i32

Returns: Result<(), String>


cancel_mkt_data

Cancel market data.

pub fn cancel_mkt_data(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_tick_by_tick_data

Subscribe to tick-by-tick data.

pub fn req_tick_by_tick_data( &self, req_id: i64, contract: &Contract, tick_type: &str, _number_of_ticks: i32, _ignore_size: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
tick_type&strTick type ID or tick-by-tick type string.
number_of_ticksi32Maximum number of ticks to return.
ignore_sizeboolIf true, ignore size in tick-by-tick data.

Returns: Result<(), String>


cancel_tick_by_tick_data

Cancel tick-by-tick data.

pub fn cancel_tick_by_tick_data(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_mkt_depth

Subscribe to market depth (L2 order book).

pub fn req_mkt_depth( &self, req_id: i64, contract: &Contract, num_rows: i32, is_smart_depth: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
num_rowsi32Number of order book rows to subscribe to.
is_smart_depthboolIf true, aggregate depth from multiple exchanges via SMART.

Returns: Result<(), String>


cancel_mkt_depth

Cancel market depth.

pub fn cancel_mkt_depth(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_real_time_bars

Subscribe to real-time 5-second bars.

pub fn req_real_time_bars( &self, req_id: i64, contract: &Contract, _bar_size: i32, what_to_show: &str, use_rth: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
bar_sizei32Bar size: "1 min", "5 mins", "1 hour", "1 day", etc.
what_to_show&strData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthboolIf true, only return data from Regular Trading Hours.

Returns: Result<(), String>


cancel_real_time_bars

Cancel real-time bars.

pub fn cancel_real_time_bars(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_ping

Set market data type preference (1=live, 2=frozen, 3=delayed, 4=delayed-frozen). Request an auth-connection round-trip time sample (ibx#158): sends a lightweight liveness probe with no side effects on subscriptions, contract caches, or pacing budgets. The result lands asynchronously — poll last_rtt() after a moment. No-op while a probe is already in flight or the connection is down.

pub fn req_ping(&self) -> Result<(), String>

Returns: Result<(), String>


last_rtt

Last measured auth-connection round-trip time, if any (ibx#158). A gauge, not a benchmark: the sample is the interval from a probe to the first inbound traffic that followed it, which on an active feed can undercount by racing data already in flight. Also sampled automatically whenever liveness sends its own probe.

pub fn last_rtt(&self) -> Option<std::time::Duration>

Returns: Option<std::time::Duration>


req_market_data_type

NOT supported end to end (ibx#234): the requested type is stored locally but never sent to the gateway, so subscriptions always deliver realtime data and delayed tick variants never arrive. Requesting a non-realtime type logs a warning, and the market_data_type callback reports the DELIVERED type (realtime) rather than echoing the request.

pub fn req_market_data_type(&self, market_data_type: i32)
ParameterTypeDescription
market_data_typei321=live, 2=frozen, 3=delayed, 4=delayed-frozen.

set_news_providers

Set news provider codes for per-contract news ticks.

pub fn set_news_providers(&self, providers: &str)
ParameterTypeDescription
providers&strNews provider list.

quote

Zero-copy SeqLock quote read. Maps reqId → InstrumentId → SeqLock. Returns None if the reqId is not mapped to a subscription.

pub fn quote(&self, req_id: i64) -> Option<Quote>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Option<Quote>


quote_by_instrument

Direct SeqLock read by InstrumentId (for callers who track IDs themselves). Returns None for an out-of-range id — this used to panic (ibx#234).

pub fn quote_by_instrument(&self, instrument: InstrumentId) -> Option<Quote>
ParameterTypeDescription
instrumentInstrumentIdInstrument type for scanner (e.g. "STK", "FUT").

Returns: Option<Quote>


Reference Data

req_historical_data

Request historical data.

pub fn req_historical_data( &self, req_id: i64, contract: &Contract, end_date_time: &str, duration: &str, bar_size: &str, what_to_show: &str, use_rth: bool, _format_date: i32, keep_up_to_date: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
end_date_time&strEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
duration&strDuration string, e.g. "1 D", "1 W", "1 M", "1 Y".
bar_size&strBar size: "1 min", "5 mins", "1 hour", "1 day", etc.
what_to_show&strData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthboolIf true, only return data from Regular Trading Hours.
format_datei32Date format: 1="YYYYMMDD HH:MM:SS", 2=Unix seconds.
keep_up_to_dateboolIf true, continue receiving updates after initial history.

Returns: Result<(), String>


cancel_historical_data

Cancel historical data.

pub fn cancel_historical_data(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_head_time_stamp

Request head timestamp.

pub fn req_head_time_stamp( &self, req_id: i64, contract: &Contract, what_to_show: &str, use_rth: bool, _format_date: i32, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
what_to_show&strData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthboolIf true, only return data from Regular Trading Hours.
format_datei32Date format: 1="YYYYMMDD HH:MM:SS", 2=Unix seconds.

Returns: Result<(), String>


req_contract_details

Request contract details.

pub fn req_contract_details(&self, req_id: i64, contract: &Contract) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).

Returns: Result<(), String>


req_mkt_depth_exchanges

Request available exchanges for market depth.

pub fn req_mkt_depth_exchanges(&self) -> Result<(), String>

Returns: Result<(), String>


req_matching_symbols

Request matching symbols.

pub fn req_matching_symbols(&self, req_id: i64, pattern: &str) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
pattern&strSymbol search pattern.

Returns: Result<(), String>


cancel_head_time_stamp

Cancel head timestamp request.

pub fn cancel_head_time_stamp(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_market_rule

Request market rule by ID. Looks up cached market rules delivered during connection init.

pub fn req_market_rule(&self, market_rule_id: i32, wrapper: &mut impl crate::api::wrapper::Wrapper)
ParameterTypeDescription
market_rule_idi32Market rule ID.
wrapper&mut impl crate::api::wrapper::WrapperWrapper callback receiver for synchronous delivery.

req_news_bulletins

Subscribe to news bulletins.

pub fn req_news_bulletins(&self, _all_msgs: bool)
ParameterTypeDescription
all_msgsboolIf true, receive all existing bulletins on subscribe.

cancel_news_bulletins

Cancel news bulletin subscription.

pub fn cancel_news_bulletins(&self)

req_scanner_parameters

Request scanner parameters XML.

pub fn req_scanner_parameters(&self) -> Result<(), String>

Returns: Result<(), String>


req_scanner_subscription

Subscribe to a market scanner.

pub fn req_scanner_subscription( &self, req_id: i64, instrument: &str, location_code: &str, scan_code: &str, max_items: u32, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
instrument&strInstrument type for scanner (e.g. "STK", "FUT").
location_code&strScanner location (e.g. "STK.US.MAJOR").
scan_code&strScanner code (e.g. "TOP_PERC_GAIN", "HIGH_OPT_IMP_VOLAT").
max_itemsu32Maximum number of scanner results.

Returns: Result<(), String>


cancel_scanner_subscription

Cancel a scanner subscription.

pub fn cancel_scanner_subscription(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_historical_news

Request historical news headlines.

pub fn req_historical_news( &self, req_id: i64, con_id: i64, provider_codes: &str, start_time: &str, end_time: &str, max_results: u32, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
con_idi64Contract ID. Unique per instrument.
provider_codes&strPipe-separated news provider codes.
start_time&strStart date/time for news query.
end_time&strEnd date/time for news query.
max_resultsu32Maximum number of results.

Returns: Result<(), String>


req_news_article

Request a news article by provider and article ID.

pub fn req_news_article(&self, req_id: i64, provider_code: &str, article_id: &str) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
provider_code&strNews provider code (e.g. "BRFG").
article_id&strNews article identifier.

Returns: Result<(), String>


req_fundamental_data

Request fundamental data (e.g. ReportSnapshot, ReportsFinSummary).

pub fn req_fundamental_data(&self, req_id: i64, contract: &Contract, report_type: &str) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
report_type&strReport type: "ReportSnapshot", "ReportsFinSummary", "RESC", etc.

Returns: Result<(), String>


cancel_fundamental_data

Cancel fundamental data.

pub fn cancel_fundamental_data(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_histogram_data

Request price histogram data.

pub fn req_histogram_data(&self, req_id: i64, contract: &Contract, use_rth: bool, period: &str) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
use_rthboolIf true, only return data from Regular Trading Hours.
period&strHistogram period, e.g. "1week", "1month".

Returns: Result<(), String>


cancel_histogram_data

Cancel histogram data.

pub fn cancel_histogram_data(&self, req_id: i64) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Returns: Result<(), String>


req_historical_ticks

Request historical tick data.

pub fn req_historical_ticks( &self, req_id: i64, contract: &Contract, start_date_time: &str, end_date_time: &str, number_of_ticks: i32, what_to_show: &str, use_rth: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
start_date_time&strStart date/time for tick query.
end_date_time&strEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
number_of_ticksi32Maximum number of ticks to return.
what_to_show&strData type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc.
use_rthboolIf true, only return data from Regular Trading Hours.

Returns: Result<(), String>


req_historical_schedule

Request historical trading schedule.

pub fn req_historical_schedule( &self, req_id: i64, contract: &Contract, end_date_time: &str, duration: &str, use_rth: bool, ) -> Result<(), String>
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
end_date_time&strEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
duration&strDuration string, e.g. "1 D", "1 W", "1 M", "1 Y".
use_rthboolIf true, only return data from Regular Trading Hours.

Returns: Result<(), String>


Gateway-Local & Stubs

req_smart_components

Request smart routing components for a BBO exchange. Gateway-local — returns component exchanges from init data.

pub fn req_smart_components(&self, req_id: i64, _bbo_exchange: &str, wrapper: &mut impl Wrapper)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
bbo_exchange&strBBO exchange for smart component lookup (e.g. "SMART").
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_news_providers

Request available news providers. Gateway-local — returns provider list from init data.

pub fn req_news_providers(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_current_time

Request current server time. Returns local system time (no server round-trip).

pub fn req_current_time(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

request_fa

Request FA data. Not yet implemented.

pub fn request_fa(&self, _fa_data_type: i32)
ParameterTypeDescription
fa_data_typei32FA data type (1=Groups, 2=Profiles, 3=Aliases).

replace_fa

Replace FA data. Not yet implemented.

pub fn replace_fa(&self, _req_id: i64, _fa_data_type: i32, _cxml: &str)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
fa_data_typei32FA data type (1=Groups, 2=Profiles, 3=Aliases).
cxml&strFA XML configuration data.

query_display_groups

Query display groups. Not yet implemented.

pub fn query_display_groups(&self, _req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

subscribe_to_group_events

Subscribe to display group events. Not yet implemented.

pub fn subscribe_to_group_events(&self, _req_id: i64, _group_id: i32)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
group_idi32Display group ID.

unsubscribe_from_group_events

Unsubscribe from display group events. Not yet implemented.

pub fn unsubscribe_from_group_events(&self, _req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

update_display_group

Update display group. Not yet implemented.

pub fn update_display_group(&self, _req_id: i64, _contract_info: &str)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract_info&strDisplay group contract info string.

req_soft_dollar_tiers

Request soft dollar tiers. Gateway-local — returns tiers parsed from CCP logon tag 6560.

pub fn req_soft_dollar_tiers(&self, req_id: i64, wrapper: &mut impl Wrapper)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_family_codes

Request family codes. Gateway-local — returns codes parsed from CCP logon tag 6823.

pub fn req_family_codes(&self, wrapper: &mut impl Wrapper)
ParameterTypeDescription
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

set_server_log_level

Set server log level.

pub fn set_server_log_level(&self, log_level: i32)
ParameterTypeDescription
log_leveli32Log level: 1=error, 2=warn, 3=info, 4=debug, 5=trace.

req_user_info

Request user info. Gateway-local — returns whiteBrandingId from CCP logon.

pub fn req_user_info(&self, req_id: i64, wrapper: &mut impl Wrapper)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
wrapper&mut impl WrapperWrapper callback receiver for synchronous delivery.

req_wsh_meta_data

Request WSH metadata. Not yet implemented.

pub fn req_wsh_meta_data(&self, _req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

req_wsh_event_data

Request WSH event data. Not yet implemented.

pub fn req_wsh_event_data(&self, _req_id: i64)
ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

Wrapper Callbacks

connect_ack

Connection acknowledged.


connection_closed

Connection has been closed.


next_valid_id

Next valid order ID from the server.

ParameterTypeDescription
order_idi64Order identifier. Must be unique per session.

managed_accounts

Comma-separated list of managed account IDs.

ParameterTypeDescription
accounts_list&strComma-separated account IDs.

error

Error or informational message from the server.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
error_codei64Error code.
error_string&strError message.
advanced_order_reject_json&strJSON with advanced rejection details.

current_time

Current server time (Unix seconds).

ParameterTypeDescription
timei64Tick timestamp (Unix seconds).

tick_price

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

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tick_typei32Tick type ID or tick-by-tick type string.
pricef64Tick price.
attrib&TickAttribTick attributes.

tick_size

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

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tick_typei32Tick type ID or tick-by-tick type string.
sizef64Tick size.

tick_string

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

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tick_typei32Tick type ID or tick-by-tick type string.
value&strAccount value.

tick_generic

Generic numeric tick value.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tick_typei32Tick type ID or tick-by-tick type string.
valuef64Account value.

tick_snapshot_end

Snapshot delivery complete; subscription auto-cancelled.

ParameterTypeDescription
req_idi64Request 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_idi64Request identifier. Used to match responses to requests.
market_data_typei321=live, 2=frozen, 3=delayed, 4=delayed-frozen.

order_status

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

ParameterTypeDescription
order_idi64Order identifier. Must be unique per session.
status&strOrder status string ("Submitted", "Filled", "Cancelled", etc.).
filledf64Cumulative filled quantity.
remainingf64Remaining quantity.
avg_fill_pricef64Average fill price.
perm_idi64Permanent order ID assigned by the server.
parent_idi64Parent order ID (0 if no parent).
last_fill_pricef64Price of the last fill.
client_idi64Client ID (unused — single-client engine).
why_held&strReason the order is held (e.g. "locate").
mkt_cap_pricef64Market cap price for the order.

open_order

Open order details (contract, order, state).

ParameterTypeDescription
order_idi64Order identifier. Must be unique per session.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
order&OrderOrder parameters (action, quantity, type, price, TIF, etc.).
order_state&OrderStateOrder state (status, margin, commission info).

open_order_end

End of open orders list.


exec_details

Execution fill details.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
execution&ExecutionExecution details (exec_id, time, price, shares, etc.).

exec_details_end

End of execution details list.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

commission_and_fees_report

Commission and fees report for an execution.

ParameterTypeDescription
report&CommissionAndFeesReportCommission report (exec_id, commission, currency, realized P&L).

update_account_value

Account value update (key/value/currency).

ParameterTypeDescription
key&strAccount value key (e.g. "NetLiquidation", "BuyingPower").
value&strAccount value.
currency&strCurrency code (e.g. "USD").
account_name&strAccount identifier.

update_portfolio

Portfolio position update.

ParameterTypeDescription
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
positionf64Book position (row index) or position size.
market_pricef64Current market price.
market_valuef64Current market value of position.
average_costf64Average cost basis.
unrealized_pnlf64Unrealized profit/loss.
realized_pnlf64Realized profit/loss.
account_name&strAccount identifier.

update_account_time

Account update timestamp.

ParameterTypeDescription
timestamp&strTimestamp string.

account_download_end

Account data delivery complete.

ParameterTypeDescription
account&strAccount ID.

account_summary

Account summary tag/value entry.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
account&strAccount ID.
tag&strAccount tag name (e.g. "NetLiquidation").
value&strAccount value.
currency&strCurrency code (e.g. "USD").

account_summary_end

End of account summary.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

position

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

ParameterTypeDescription
account&strAccount ID.
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
posf64Position size (decimal shares).
avg_costf64Average cost per share.

position_end

End of positions list.


pnl

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

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
daily_pnlf64Daily profit/loss.
unrealized_pnlf64Unrealized profit/loss.
realized_pnlf64Realized profit/loss.

pnl_single

Single-position P&L update.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
posf64Position size (decimal shares).
daily_pnlf64Daily profit/loss.
unrealized_pnlf64Unrealized profit/loss.
realized_pnlf64Realized profit/loss.
valuef64Account value.

historical_data

Historical OHLCV bar.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
bar&BarDataBar data (date, open, high, low, close, volume, wap, bar_count).

historical_data_end

End of historical data delivery.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
start&strPeriod start date/time.
end&strPeriod end date/time.

historical_data_update

Real-time bar update (keep_up_to_date=true).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
bar&BarDataBar data (date, open, high, low, close, volume, wap, bar_count).

head_timestamp

Earliest available data timestamp.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
head_timestamp&strEarliest available data timestamp string.

contract_details

Contract definition details.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
details&ContractDetailsContract details object.

contract_details_end

End of contract details.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

symbol_samples

Matching symbol search results.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
descriptions&[ContractDescription]Array of matching contract descriptions.

tick_by_tick_all_last

Tick-by-tick last trade.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tick_typei32Tick type ID or tick-by-tick type string.
timei64Tick timestamp (Unix seconds).
pricef64Tick price.
sizef64Tick size.
attrib&TickAttribLastTick attributes.
exchange&strExchange name.
special_conditions&strSpecial trade conditions.

tick_by_tick_bid_ask

Tick-by-tick bid/ask quote.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
timei64Tick timestamp (Unix seconds).
bid_pricef64Bid price.
ask_pricef64Ask price.
bid_sizef64Bid size.
ask_sizef64Ask size.
attrib&TickAttribBidAskTick attributes.

tick_by_tick_mid_point

Tick-by-tick midpoint.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
timei64Tick timestamp (Unix seconds).
mid_pointf64Midpoint price.

scanner_data

Scanner result entry (rank, contract, distance).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
ranki32Scanner result rank (0-based).
details&ContractDetailsContract details object.
distance&strScanner distance metric.
benchmark&strScanner benchmark.
projection&strScanner projection.
legs_str&strCombo legs description.

scanner_data_end

End of scanner results.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

scanner_parameters

Scanner parameters XML.

ParameterTypeDescription
xml&strXML string.

update_news_bulletin

News bulletin message.

ParameterTypeDescription
msg_idi64Bulletin message ID.
msg_typei32Bulletin message type (1=regular, 2=exchange).
message&strBulletin message text.
orig_exchange&strOriginating exchange.

tick_news

Per-contract news tick.

ParameterTypeDescription
ticker_idi64Ticker/request ID.
timestampi64Timestamp string.
provider_code&strNews provider code (e.g. "BRFG").
article_id&strNews article identifier.
headline&strNews headline text.
extra_data&strAdditional tick data.

historical_news

Historical news headline.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
time&strTick timestamp (Unix seconds).
provider_code&strNews provider code (e.g. "BRFG").
article_id&strNews article identifier.
headline&strNews headline text.

historical_news_end

End of historical news.

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

news_article

Full news article text.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
article_typei32Article type: 0=plain text, 1=HTML.
article_text&strFull article body.

real_time_bar

Real-time 5-second OHLCV bar.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
datei64Bar date string.
openf64Open price.
highf64High price.
lowf64Low price.
closef64Close price.
volumef64Volume.
wapf64Volume-weighted average price.
counti32Trade count.

historical_ticks

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

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
ticks&HistoricalTickDataHistorical tick data.
doneboolIf true, all ticks have been delivered.

historical_ticks_bid_ask

Historical bid/ask ticks.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
ticks&HistoricalTickDataHistorical tick data.
doneboolIf true, all ticks have been delivered.

historical_ticks_last

Historical last-trade ticks.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
ticks&HistoricalTickDataHistorical tick data.
doneboolIf true, all ticks have been delivered.

tick_option_computation

Option implied vol / greeks computation.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tick_typei32Tick type ID or tick-by-tick type string.
tick_attribi32
implied_volf64Implied volatility.
deltaf64Option delta.
opt_pricef64Option theoretical price.
pv_dividendf64Present value of dividends.
gammaf64Option gamma.
vegaf64Option vega.
thetaf64Option theta.
und_pricef64Underlying price.

security_definition_option_parameter

Option chain parameters (strikes, expirations).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
exchange&strExchange name.
underlying_con_idi64Underlying contract ID.
trading_class&strTrading class.
multiplier&strContract multiplier.
expirations&[String]Available expiration dates.
strikes&[f64]Available strike prices.

security_definition_option_parameter_end

End of option chain parameters.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.

delta_neutral_validation

Delta-neutral validation response.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
con_idi64Contract ID. Unique per instrument.
deltaf64Option delta.
pricef64Tick price.

histogram_data

Price distribution histogram.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
items&[(f64, i64Histogram entries [(price, count)].

market_rule

Market rule: price increment schedule.

ParameterTypeDescription
market_rule_idi64Market rule ID.
price_increments&[PriceIncrement]Price increment rules [{low_edge, increment}].

completed_order

Completed (filled/cancelled) order details.

ParameterTypeDescription
contract&ContractContract specification (symbol, secType, exchange, currency, etc.).
order&OrderOrder parameters (action, quantity, type, price, TIF, etc.).
order_state&OrderStateOrder state (status, margin, commission info).

completed_orders_end

End of completed orders list.


historical_schedule

Historical trading schedule (exchange hours).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
start_date_time&strStart date/time for tick query.
end_date_time&strEnd date/time in "YYYYMMDD HH:MM:SS" format, or empty for now.
time_zone&strTimezone string (e.g. "US/Eastern").
sessions&[(String, String, StringTrading sessions [(ref_date, open, close)].

fundamental_data

Fundamental data (XML/JSON).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
data&strRaw data string (XML/JSON).

update_mkt_depth

L2 book update (single exchange).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
positioni32Book position (row index) or position size.
operationi32Book operation: 0=insert, 1=update, 2=delete.
sidei32Book side: 0=ask, 1=bid. Or order side "BOT"/"SLD".
pricef64Tick price.
sizef64Tick size.

update_mkt_depth_l2

L2 book update (with market maker).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
positioni32Book position (row index) or position size.
market_maker&strMarket maker ID.
operationi32Book operation: 0=insert, 1=update, 2=delete.
sidei32Book side: 0=ask, 1=bid. Or order side "BOT"/"SLD".
pricef64Tick price.
sizef64Tick size.
is_smart_depthboolIf true, aggregate depth from multiple exchanges via SMART.

mkt_depth_exchanges

Available exchanges for market depth.

ParameterTypeDescription
descriptions&[crate::types::DepthMktDataDescription]Array of matching contract descriptions.

tick_req_params

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

ParameterTypeDescription
ticker_idi64Ticker/request ID.
min_tickf64Minimum tick size.
bbo_exchange&strBBO exchange for smart component lookup (e.g. "SMART").
snapshot_permissionsi64Snapshot permissions bitmask.

smart_components

SMART routing component exchanges.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
components&[crate::types::SmartComponent]Smart routing component exchanges.

news_providers

Available news providers list.

ParameterTypeDescription
providers&[crate::types::NewsProvider]News provider list.

soft_dollar_tiers

Soft dollar tier list.

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
tiers&[crate::types::SoftDollarTier]Soft dollar tier list.

family_codes

Family codes linking related accounts.

ParameterTypeDescription
codes&[crate::types::FamilyCode]Family code list.

user_info

User info (white branding ID).

ParameterTypeDescription
req_idi64Request identifier. Used to match responses to requests.
white_branding_id&strWhite branding ID (empty for standard accounts).