Rust API
The full Rust API reference is published on docs.rs/ibx — auto-generated from doc comments on every release.
Quick links
ibx::api::client::EClient— request side of the APIibx::api::wrapper::Wrapper— callback trait you implementibx::api::client::Contract— instrument descriptoribx::api::client::Order— order descriptor
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
- EClient: Connection
- EClient: Account & Portfolio
- EClient: Orders
- EClient: Market Data
- EClient: Reference Data
- EClient: Gateway-Local & Stubs
- Wrapper Callbacks
Connection
connect
Connect to IB and start the engine.
pub fn connect(config: &EClientConfig) -> Result<Self, Box<dyn std::error::Error>>
| Parameter | Type | Description |
|---|---|---|
config | &EClientConfig | Connection 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 means one copy of each answer (bar batches, contract definitions, option chains, scanner rows and the others, ibx#498). 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>>
| Parameter | Type | Description |
|---|---|---|
config | &EClientConfig | Connection configuration (username, password, host, paper, core_id). |
capacity | usize |
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
| Parameter | Type | Description |
|---|---|---|
shared | Arc<SharedState> | Shared state handle. |
control_tx | Sender<ControlCommand> | Control channel sender. |
handle | thread::JoinHandle<( | Background thread handle. |
Returns: Self
map_req_instrument
Map a reqId to an InstrumentId (for testing without a live engine). The request takes every tick of the instrument, its headlines too.
pub fn map_req_instrument(&self, req_id: i64, instrument: InstrumentId)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
instrument | InstrumentId | Instrument 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: OrderId, contract: ApiContract, order: ApiOrder, instrument: InstrumentId, )
| Parameter | Type | Description |
|---|---|---|
order_id | OrderId | Order identifier. Must be unique per session. |
contract | ApiContract | Contract specification (symbol, secType, exchange, currency, etc.). |
order | ApiOrder | Order parameters (action, quantity, type, price, TIF, etc.). |
instrument | InstrumentId | Instrument 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)
| Parameter | Type | Description |
|---|---|---|
con_id | i64 | Contract ID. Unique per instrument. |
instrument | InstrumentId | Instrument type for scanner (e.g. "STK", "FUT"). |
server_version
API level the session follows: 214, the level the reference gives a current client (ibx#426)., for code that tests it before using a feature.
pub fn server_version(&self) -> i32
Returns: i32
tws_connection_time
Time the session started, as yyyyMMdd HH:mm:ss {zone} in the machine's local time (ibx#426). The connection time of the C++ client.
pub fn tws_connection_time(&self) -> String
Returns: String
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>
| Parameter | Type | Description |
|---|---|---|
key | &str | Account 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. A subscription, as the reference (ibx#477): the snapshot and position_end once the position data is in, then one position row each time a position or its average cost changes, until cancel_positions. What is ready now is sent through wrapper; the rest comes through process_msgs. No wait in the caller's thread.
pub fn req_positions(&self, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
req_pnl
Subscribe to account PnL updates. Several requests can run; an empty or unknown account gives 321, a request id already running gives 102 (ibx#478).
pub fn req_pnl(&self, req_id: i64, account: &str, _model_code: &str)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
model_code | &str | Model portfolio code (empty for default). |
cancel_pnl
Cancel PnL subscription. A request id not running gives 10185 (ibx#478).
pub fn cancel_pnl(&self, req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
req_pnl_single
Subscribe to single-position PnL updates. Same checks as req_pnl (ibx#478).
pub fn req_pnl_single(&self, req_id: i64, account: &str, _model_code: &str, con_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
model_code | &str | Model portfolio code (empty for default). |
con_id | i64 | Contract ID. Unique per instrument. |
cancel_pnl_single
Cancel single-position PnL subscription. A request id not running gives 10186 (ibx#478).
pub fn cancel_pnl_single(&self, req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
req_account_summary
Request account summary. A server subscription: the rows come as the server sends them, each batch ends with account_summary_end, until the cancel (ibx#479).
pub fn req_account_summary(&self, req_id: i64, group: &str, tags: &str)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
group | &str | Account group name (e.g. "All"). |
tags | &str | Comma-separated account tags: "NetLiquidation,BuyingPower,...". |
cancel_account_summary
Cancel account summary.
pub fn cancel_account_summary(&self, req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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)
| Parameter | Type | Description |
|---|---|---|
subscribe | bool | true to start updates, false to stop. |
acct_code | &str | Account code (e.g. "DU1234567"). |
cancel_positions
Cancel positions subscription.
pub fn cancel_positions(&self)
req_managed_accts
Request managed accounts. Every account of the logon's account list, in logon order, comma separated, as the reference (ibx#420); the logon account when the logon had no list.
pub fn req_managed_accts(&self, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
req_account_updates_multi
Request account updates for multiple accounts/models. A subscription, as the reference (ibx#476): the account values (unless ledger_and_nlv) and the ledger rows as the server sent them, each through account_update_multi with the request id and model code, then account_update_multi_end; then the rows that change, until cancel_account_updates_multi. A request id already running gives error 322. What is ready is sent through wrapper at once; the rest comes through process_msgs.
pub fn req_account_updates_multi( &self, req_id: i64, account: &str, model_code: &str, ledger_and_nlv: bool, wrapper: &mut impl Wrapper, )
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
model_code | &str | Model portfolio code (empty for default). |
ledger_and_nlv | bool | If true, include ledger and NLV data. |
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
cancel_account_updates_multi
Cancel multi-account updates.
pub fn cancel_account_updates_multi(&self, req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
req_positions_multi
Request positions for multiple accounts/models. A subscription, as the reference (ibx#476): position_multi rows with the request id and model code, position_multi_end, then a row each time a position or its average cost changes, until cancel_positions_multi.
pub fn req_positions_multi( &self, req_id: i64, account: &str, model_code: &str, wrapper: &mut impl Wrapper, )
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
model_code | &str | Model portfolio code (empty for default). |
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
cancel_positions_multi
Cancel multi-account positions.
pub fn cancel_positions_multi(&self, req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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>
| Parameter | Type | Description |
|---|---|---|
order_id | i64 | Order identifier. Must be unique per session. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
order | &Order | Order 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>
| Parameter | Type | Description |
|---|---|---|
order_id | i64 | Order identifier. Must be unique per session. |
manual_order_cancel_time | &str | Manual 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>
| Parameter | Type | Description |
|---|---|---|
perm_id | i64 | Permanent order ID assigned by the server. |
Returns: Result<(), String>
req_global_cancel
Cancel all orders.: every order of the account the session knows, those of other clients and of earlier sessions too, as the reference cancels them.
pub fn req_global_cancel(&self) -> Result<(), String>
Returns: Result<(), String>
req_ids
Request next valid order ID.: the highest order id this client used + 1, as the reference computes it per client id (1 when none), a 32-bit id. The ids of the client's earlier sessions count as far as the server's replays of the logon show them (orders with the client's id); right after the connect the answer waits for the order replay of the logon. Nothing is reserved.
pub fn req_ids(&self, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
next_order_id
The next order id for a new order: the next valid id (see req_ids), or above the ids this method gave before. Each call reserves the id it gives.
pub fn next_order_id(&self) -> i64
Returns: i64
req_open_orders
Request open orders for this client. Before the order replay of the logon has ended, and while the auth link is lost, the request is answered only after the order replay, from process_msgs (ibx#251).
pub fn req_open_orders(&self, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
req_all_open_orders
Request all open orders. Held like req_open_orders until the order replay (ibx#251).
pub fn req_all_open_orders(&self, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper 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)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper 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)
| Parameter | Type | Description |
|---|---|---|
b_auto_bind | bool | If 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)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
filter | &ExecutionFilter | Execution filter (client_id, acct_code, time, symbol, sec_type, exchange, side). |
wrapper | &mut impl Wrapper | Wrapper 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>
| Parameter | Type | Description |
|---|---|---|
strategy | &str | Algo 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, the request is a snapshot, as the reference's: each tick type is sent once, then tick_snapshot_end when the bid, ask, last, open and close came (with the option computations for an option; the types a contract has none of are not waited for), or 11 seconds after the start; then the request is gone. A snapshot with generic ticks, or beyond the per-second snapshot limit, is refused with error 321. generic_tick_list is checked as the reference checks it: a list with an unknown tick, or one not legal for the security type, is refused with error 321 (ibx#450). Each generic tick valid for the contract is its own farm entry, shared by the requests of the contract, and its values come as the reference's ticks (control::generic_values): option volume 29/30 (100), open interest 27/28 (101), average option volume 87 (105), implied and historical volatility 24 (106) and 23 (104), misc stats 21 and 15-20 (165), auction 34-36 and 61 (225), RTVolume 48 (233) and RT trade volume 77 (375), shortable 46 and 89 (236), trade count, rate and volume rate 54-56 (293-295), last RTH trade 57 (318), dividends 59 (456), futures open interest 86 (588). The other legal ticks are accepted and not sent. The news tick, "292" (every subscribed news source) or "292:CODE1+CODE2", subscribes the contract's headlines, delivered as tick_news (ibx#458); a derivative contract or a code that is not a subscribed source ends the request with error 10094. mdoff keeps the top of book ticks from the request. Several request ids may ask for one contract, as with the reference (ibx#444): they share its subscription, a request that joins gets at once what the others have, and the subscription ends with the cancel of the last one.
pub fn req_mkt_data( &self, req_id: i64, contract: &Contract, generic_tick_list: &str, snapshot: bool, regulatory_snapshot: bool, ) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
generic_tick_list | &str | Comma-separated generic tick IDs (e.g. "233" for RT volume). |
snapshot | bool | If true, delivers one quote then auto-cancels. |
regulatory_snapshot | bool | If true, request a regulatory snapshot (additional fees may apply). |
Returns: Result<(), String>
req_mkt_data_ex
Like [req_mkt_data], but sends a market-data mode with the request, allowing parallel realtime + frozen subscriptions for the same contract. The request is always the bid/ask and last pair; the mode rides on each of its entries: | mode_9887 | mode | |-------------|------------------| | 0 | REALTIME (no mode sent) | | 1 | DELAYED | | 2 | FROZEN | | 3 | DELAYED_FROZEN | 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
generic_tick_list | &str | Comma-separated generic tick IDs (e.g. "233" for RT volume). |
snapshot | bool | If true, delivers one quote then auto-cancels. |
regulatory_snapshot | bool | If true, request a regulatory snapshot (additional fees may apply). |
mode_9887 | i32 |
Returns: Result<(), String>
calculate_implied_volatility
Implied volatility of an option price. Computed locally by the option model, as the reference: one tick_option_computation with tick type 53, or nothing when no volatility is found within 5 seconds. The options are read and not used, as the reference.
pub fn calculate_implied_volatility( &self, req_id: i64, contract: &Contract, option_price: f64, under_price: f64, _implied_vol_options: &[crate::api::types::TagValue], ) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
option_price | f64 | Option market price. |
under_price | f64 | Underlying asset price. |
implied_vol_options | &[crate::api::types::TagValue] |
Returns: Result<(), String>
calculate_option_price
Price and greeks of an option at a volatility.: one tick_option_computation with tick type 53; after 30 seconds without a price, the tick has no price and no greeks, as the reference.
pub fn calculate_option_price( &self, req_id: i64, contract: &Contract, volatility: f64, under_price: f64, _opt_prc_options: &[crate::api::types::TagValue], ) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
volatility | f64 | Implied volatility. |
under_price | f64 | Underlying asset price. |
opt_prc_options | &[crate::api::types::TagValue] |
Returns: Result<(), String>
cancel_calculate_implied_volatility
Does nothing, as the reference: a running calculation still answers.
pub fn cancel_calculate_implied_volatility(&self, _req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
cancel_calculate_option_price
Does nothing, as the reference: a running calculation still answers.
pub fn cancel_calculate_option_price(&self, _req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
cancel_mkt_data
Cancel market data.
pub fn cancel_mkt_data(&self, req_id: i64) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
Returns: Result<(), String>
req_tick_by_tick_data
Subscribe to tick-by-tick data. tick_type is "Last", "AllLast", "BidAsk" or "MidPoint", each asked under its own name; anything else gives error 321, as the reference. number_of_ticks above 0 asks for that many past ticks first, given as historical ticks; ignore_size asks for the size filter. A request for a contract, type and size filter already streaming joins that stream (ibx#455).
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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
tick_type | &str | Tick type ID or tick-by-tick type string. |
number_of_ticks | i32 | Maximum number of ticks to return. |
ignore_size | bool | If 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
num_rows | i32 | Number of order book rows to subscribe to. |
is_smart_depth | bool | If 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
bar_size | i32 | Bar size: "1 min", "5 mins", "1 hour", "1 day", etc. |
what_to_show | &str | Data type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc. |
use_rth | bool | If 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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
Set the market data type (ibx#447), as the reference sets its modes: 1 all off, 2 frozen on, 3 delayed on, 4 delayed and delayed-frozen on (2 keeps the delayed modes, 3 keeps frozen). With delayed on, a subscription the server rejects goes on with delayed data when the server has it: market_data_type(reqId, 3) then error 10167, as the reference. With frozen on (2, until 1), a streaming request also asks the contract's market data status; while it says frozen, the request gets the frozen top of book: market_data_type(reqId, 2), then the kept values; back on real-time data, type 1 and the real-time values. A value outside 1..=4 gives error 321 with id -1.
pub fn req_market_data_type(&self, market_data_type: i32)
| Parameter | Type | Description |
|---|---|---|
market_data_type | i32 | 1=live, 2=frozen, 3=delayed, 4=delayed-frozen. |
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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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>
| Parameter | Type | Description |
|---|---|---|
instrument | InstrumentId | Instrument type for scanner (e.g. "STK", "FUT"). |
Returns: Option<Quote>
Reference Data
req_historical_data
Request historical data. A request the reference refuses locally gets its error (321 or 10314) and no query; SCHEDULE asks for the trading schedule (ibx#430).
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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
end_date_time | &str | End date/time in "YYYYMMDD HH:MM:SS" format, or empty for now. |
duration | &str | Duration string, e.g. "1 D", "1 W", "1 M", "1 Y". |
bar_size | &str | Bar size: "1 min", "5 mins", "1 hour", "1 day", etc. |
what_to_show | &str | Data type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc. |
use_rth | bool | If true, only return data from Regular Trading Hours. |
format_date | i32 | Date format: 1="YYYYMMDD HH:MM:SS", 2=Unix seconds. |
keep_up_to_date | bool | If 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
what_to_show | &str | Data type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc. |
use_rth | bool | If true, only return data from Regular Trading Hours. |
format_date | i32 | Date 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract 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. An empty or invalid pattern gives 321 and nothing is sent; the pattern is sent trimmed (ibx#439).
pub fn req_matching_symbols(&self, req_id: i64, pattern: &str) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
pattern | &str | Symbol search pattern. |
Returns: Result<(), String>
req_sec_def_opt_params
Request option chain parameters. A request the reference refuses locally gets 321; the rows come through security_definition_option_parameter, then security_definition_option_parameter_end (ibx#440).
pub fn req_sec_def_opt_params( &self, req_id: i64, underlying_symbol: &str, fut_fop_exchange: &str, underlying_sec_type: &str, underlying_con_id: i64, ) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
underlying_symbol | &str | Underlying symbol (e.g. "AAPL"). |
fut_fop_exchange | &str | Exchange for futures/FOP options. |
underlying_sec_type | &str | Underlying security type (e.g. "STK"). |
underlying_con_id | i64 | Underlying contract ID. |
Returns: Result<(), String>
cancel_head_time_stamp
Cancel head timestamp request.
pub fn cancel_head_time_stamp(&self, req_id: i64) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
Returns: Result<(), String>
req_market_rule
Request market rule by ID. Answered from the rules of the definition replies received; an id not received, or a rule with no price increments, gives 322 (ibx#437).
pub fn req_market_rule(&self, market_rule_id: i32, wrapper: &mut impl crate::api::wrapper::Wrapper)
| Parameter | Type | Description |
|---|---|---|
market_rule_id | i32 | Market rule ID. |
wrapper | &mut impl crate::api::wrapper::Wrapper | Wrapper callback receiver for synchronous delivery. |
req_news_bulletins
Subscribe to news bulletins.: all_msgs replays the bulletins of the day first.
pub fn req_news_bulletins(&self, all_msgs: bool)
| Parameter | Type | Description |
|---|---|---|
all_msgs | bool | If 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.: the whole subscription, the subscription options and the filter options (ibx#456). A local refusal comes back through error.
pub fn req_scanner_subscription( &self, req_id: i64, subscription: &crate::api::types::ScannerSubscription, scanner_subscription_options: &[TagValue], scanner_subscription_filter_options: &[TagValue], ) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
subscription | &crate::api::types::ScannerSubscription | Scanner subscription parameters. |
scanner_subscription_options | &[TagValue] | |
scanner_subscription_filter_options | &[TagValue] |
Returns: Result<(), String>
cancel_scanner_subscription
Cancel a scanner subscription.
pub fn cancel_scanner_subscription(&self, req_id: i64) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
Returns: Result<(), String>
req_historical_news
Request historical news headlines. The dates are sent as given; at most 300 headlines. A local refusal comes back through error.
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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
con_id | i64 | Contract ID. Unique per instrument. |
provider_codes | &str | Pipe-separated news provider codes. |
start_time | &str | Start date/time for news query. |
end_time | &str | End date/time for news query. |
max_results | u32 | Maximum number of results. |
Returns: Result<(), String>
req_news_article
Request a news article by provider and article ID. A local refusal comes back through error.
pub fn req_news_article(&self, req_id: i64, provider_code: &str, article_id: &str) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
provider_code | &str | News provider code (e.g. "BRFG"). |
article_id | &str | News 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
report_type | &str | Report 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
use_rth | bool | If true, only return data from Regular Trading Hours. |
period | &str | Histogram 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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
Returns: Result<(), String>
req_historical_ticks
Request historical tick data. The reference's warnings (2174, 10299) and local refusals (10314, 321) come first (ibx#432).
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, ignore_size: bool, _misc_options: &[TagValue], ) -> Result<(), String>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
start_date_time | &str | Start date/time for tick query. |
end_date_time | &str | End date/time in "YYYYMMDD HH:MM:SS" format, or empty for now. |
number_of_ticks | i32 | Maximum number of ticks to return. |
what_to_show | &str | Data type: "TRADES", "MIDPOINT", "BID", "ASK", "BID_ASK", etc. |
use_rth | bool | If true, only return data from Regular Trading Hours. |
ignore_size | bool | If true, ignore size in tick-by-tick data. |
misc_options | &[TagValue] |
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>
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
end_date_time | &str | End date/time in "YYYYMMDD HH:MM:SS" format, or empty for now. |
duration | &str | Duration string, e.g. "1 D", "1 W", "1 M", "1 Y". |
use_rth | bool | If 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, as the reference (ibx#441): the exchange map of the BBO exchange that market data made known (the bboExchange of tick_req_params); an unknown one gives error 321. When the map has not come yet, the answer comes from process_msgs, within 2 s.
pub fn req_smart_components(&self, req_id: i64, bbo_exchange: &str, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
bbo_exchange | &str | BBO exchange for smart component lookup (e.g. "SMART"). |
wrapper | &mut impl Wrapper | Wrapper 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)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
req_current_time
Request current server time. Answered locally, as the reference: the local clock plus the offset to the server clock of the logon (ibx#421).
pub fn req_current_time(&self, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
request_fa
Request FA data. On a session that is not FA, error 321 as the reference (ibx#481); the FA data exchange itself is not implemented.
pub fn request_fa(&self, _fa_data_type: i32)
| Parameter | Type | Description |
|---|---|---|
fa_data_type | i32 | FA data type (1=Groups, 2=Profiles, 3=Aliases). |
replace_fa
Replace FA data. On a session that is not FA, error 321 for the request as the reference (ibx#481); the FA data exchange itself is not implemented.
pub fn replace_fa(&self, req_id: i64, _fa_data_type: i32, _cxml: &str)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
fa_data_type | i32 | FA data type (1=Groups, 2=Profiles, 3=Aliases). |
cxml | &str | FA XML configuration data. |
query_display_groups
Query display groups. Gateway-local, as the reference (ibx#424): the fixed list of groups.
pub fn query_display_groups(&self, req_id: i64, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
subscribe_to_group_events
Subscribe to display group events. Gateway-local, as the reference (ibx#424): the contract of the group at once, none since no group has one; error 321 for a group outside 1 to 7 or a request id already subscribed.
pub fn subscribe_to_group_events(&self, req_id: i64, group_id: i32, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
group_id | i32 | Display group ID. |
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
unsubscribe_from_group_events
Unsubscribe from display group events. No answer, but error 321 for a request id that is not subscribed, as the reference (ibx#424).
pub fn unsubscribe_from_group_events(&self, req_id: i64)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
update_display_group
Update display group. As the reference (ibx#424): error 321 for bad input or a request id that is not subscribed, error 473 for a conId that is not a contract, and no answer for a valid update, which changes no group.
pub fn update_display_group(&self, req_id: i64, contract_info: &str)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract_info | &str | Display group contract info string. |
req_soft_dollar_tiers
Request soft dollar tiers. Gateway-local — returns tiers parsed from CCP logon tag 6522, none when the logon has no tiers (ibx#480).
pub fn req_soft_dollar_tiers(&self, req_id: i64, wrapper: &mut impl Wrapper)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
wrapper | &mut impl Wrapper | Wrapper 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)
| Parameter | Type | Description |
|---|---|---|
wrapper | &mut impl Wrapper | Wrapper callback receiver for synchronous delivery. |
set_server_log_level
Set server log level.
pub fn set_server_log_level(&self, log_level: i32)
| Parameter | Type | Description |
|---|---|---|
log_level | i32 | Log 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)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
wrapper | &mut impl Wrapper | Wrapper 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)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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)
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request 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.
| Parameter | Type | Description |
|---|---|---|
order_id | i64 | Order identifier. Must be unique per session. |
managed_accounts
Comma-separated list of managed account IDs.
| Parameter | Type | Description |
|---|---|---|
accounts_list | &str | Comma-separated account IDs. |
error
Error or informational message from the server.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
error_code | i64 | Error code. |
error_string | &str | Error message. |
advanced_order_reject_json | &str | JSON with advanced rejection details. |
current_time
Current server time (Unix seconds).
| Parameter | Type | Description |
|---|---|---|
time | i64 | Tick timestamp (Unix seconds). |
tick_price
Price tick update (bid, ask, last, etc.).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tick_type | i32 | Tick type ID or tick-by-tick type string. |
price | f64 | Tick price. |
attrib | &TickAttrib | Tick attributes. |
tick_size
Size tick update (bid size, ask size, volume, etc.).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tick_type | i32 | Tick type ID or tick-by-tick type string. |
size | f64 | Tick size. |
tick_string
String tick (e.g. last trade timestamp).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tick_type | i32 | Tick type ID or tick-by-tick type string. |
value | &str | Account value. |
tick_generic
Generic numeric tick value.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tick_type | i32 | Tick type ID or tick-by-tick type string. |
value | f64 | Account value. |
tick_snapshot_end
Snapshot delivery complete; subscription auto-cancelled.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
market_data_type
Market data type changed (1=live, 2=frozen, 3=delayed, 4=delayed-frozen).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
market_data_type | i32 | 1=live, 2=frozen, 3=delayed, 4=delayed-frozen. |
order_status
Order status update (filled, remaining, avg price, etc.).
| Parameter | Type | Description |
|---|---|---|
order_id | i64 | Order identifier. Must be unique per session. |
status | &str | Order status string ("Submitted", "Filled", "Cancelled", etc.). |
filled | f64 | Cumulative filled quantity. |
remaining | f64 | Remaining quantity. |
avg_fill_price | f64 | Average fill price. |
perm_id | i64 | Permanent order ID assigned by the server. |
parent_id | i64 | Parent order ID (0 if no parent). |
last_fill_price | f64 | Price of the last fill. |
client_id | i64 | Client ID (unused — single-client engine). |
why_held | &str | Reason the order is held (e.g. "locate"). |
mkt_cap_price | f64 | Market cap price for the order. |
open_order
Open order details (contract, order, state).
| Parameter | Type | Description |
|---|---|---|
order_id | i64 | Order identifier. Must be unique per session. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
order | &Order | Order parameters (action, quantity, type, price, TIF, etc.). |
order_state | &OrderState | Order state (status, margin, commission info). |
open_order_end
End of open orders list.
exec_details
Execution fill details.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
execution | &Execution | Execution details (exec_id, time, price, shares, etc.). |
exec_details_end
End of execution details list.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
commission_and_fees_report
Commission and fees report for an execution.
| Parameter | Type | Description |
|---|---|---|
report | &CommissionAndFeesReport | Commission report (exec_id, commission, currency, realized P&L). |
update_account_value
Account value update (key/value/currency).
| Parameter | Type | Description |
|---|---|---|
key | &str | Account value key (e.g. "NetLiquidation", "BuyingPower"). |
value | &str | Account value. |
currency | &str | Currency code (e.g. "USD"). |
account_name | &str | Account identifier. |
update_portfolio
Portfolio position update.
| Parameter | Type | Description |
|---|---|---|
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
position | f64 | Book position (row index) or position size. |
market_price | f64 | Current market price. |
market_value | f64 | Current market value of position. |
average_cost | f64 | Average cost basis. |
unrealized_pnl | f64 | Unrealized profit/loss. |
realized_pnl | f64 | Realized profit/loss. |
account_name | &str | Account identifier. |
update_account_time
Account update timestamp.
| Parameter | Type | Description |
|---|---|---|
timestamp | &str | Timestamp string. |
account_download_end
Account data delivery complete.
| Parameter | Type | Description |
|---|---|---|
account | &str | Account ID. |
account_summary
Account summary tag/value entry.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
tag | &str | Account tag name (e.g. "NetLiquidation"). |
value | &str | Account value. |
currency | &str | Currency code (e.g. "USD"). |
account_summary_end
End of account summary.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
position
Position entry (account, contract, size, avg cost).
| Parameter | Type | Description |
|---|---|---|
account | &str | Account ID. |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
pos | f64 | Position size (decimal shares). |
avg_cost | f64 | Average cost per share. |
position_end
End of positions list.
account_update_multi
A row of req_account_updates_multi (ibx#476).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
model_code | &str | Model portfolio code (empty for default). |
key | &str | Account value key (e.g. "NetLiquidation", "BuyingPower"). |
value | &str | Account value. |
currency | &str | Currency code (e.g. "USD"). |
account_update_multi_end
End of multi-account updates.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
position_multi
A row of req_positions_multi (ibx#476).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
account | &str | Account ID. |
model_code | &str | Model portfolio code (empty for default). |
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
pos | f64 | Position size (decimal shares). |
avg_cost | f64 | Average cost per share. |
position_multi_end
End of multi-account positions.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
pnl
Account P&L update (daily, unrealized, realized).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
daily_pnl | f64 | Daily profit/loss. |
unrealized_pnl | f64 | Unrealized profit/loss. |
realized_pnl | f64 | Realized profit/loss. |
pnl_single
Single-position P&L update.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
pos | f64 | Position size (decimal shares). |
daily_pnl | f64 | Daily profit/loss. |
unrealized_pnl | f64 | Unrealized profit/loss. |
realized_pnl | f64 | Realized profit/loss. |
value | f64 | Account value. |
historical_data
Historical OHLCV bar.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
bar | &BarData | Bar data (date, open, high, low, close, volume, wap, bar_count). |
historical_data_end
End of historical data delivery.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
start | &str | Period start date/time. |
end | &str | Period end date/time. |
historical_data_update
Real-time bar update (keep_up_to_date=true).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
bar | &BarData | Bar data (date, open, high, low, close, volume, wap, bar_count). |
head_timestamp
Earliest available data timestamp.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
head_timestamp | &str | Earliest available data timestamp string. |
contract_details
Contract definition details.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
details | &ContractDetails | Contract details object. |
contract_details_end
End of contract details.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
bond_contract_details
A bond row of a contract details request (bondContractDetails).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
details | &ContractDetails | Contract details object. |
symbol_samples
Matching symbol search results.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
descriptions | &[ContractDescription] | Array of matching contract descriptions. |
tick_by_tick_all_last
Tick-by-tick last trade.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tick_type | i32 | Tick type ID or tick-by-tick type string. |
time | i64 | Tick timestamp (Unix seconds). |
price | f64 | Tick price. |
size | f64 | Tick size. |
attrib | &TickAttribLast | Tick attributes. |
exchange | &str | Exchange name. |
special_conditions | &str | Special trade conditions. |
tick_by_tick_bid_ask
Tick-by-tick bid/ask quote.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
time | i64 | Tick timestamp (Unix seconds). |
bid_price | f64 | Bid price. |
ask_price | f64 | Ask price. |
bid_size | f64 | Bid size. |
ask_size | f64 | Ask size. |
attrib | &TickAttribBidAsk | Tick attributes. |
tick_by_tick_mid_point
Tick-by-tick midpoint.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
time | i64 | Tick timestamp (Unix seconds). |
mid_point | f64 | Midpoint price. |
scanner_data
Scanner result entry (rank, contract, distance).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
rank | i32 | Scanner result rank (0-based). |
details | &ContractDetails | Contract details object. |
distance | &str | Scanner distance metric. |
benchmark | &str | Scanner benchmark. |
projection | &str | Scanner projection. |
legs_str | &str | Combo legs description. |
scanner_data_end
End of scanner results.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
scanner_parameters
Scanner parameters XML.
| Parameter | Type | Description |
|---|---|---|
xml | &str | XML string. |
update_news_bulletin
News bulletin message.
| Parameter | Type | Description |
|---|---|---|
msg_id | i64 | Bulletin message ID. |
msg_type | i32 | Bulletin message type (1=regular, 2=exchange). |
message | &str | Bulletin message text. |
orig_exchange | &str | Originating exchange. |
tick_news
Per-contract news tick.
| Parameter | Type | Description |
|---|---|---|
ticker_id | i64 | Ticker/request ID. |
timestamp | i64 | Timestamp string. |
provider_code | &str | News provider code (e.g. "BRFG"). |
article_id | &str | News article identifier. |
headline | &str | News headline text. |
extra_data | &str | Additional tick data. |
historical_news
Historical news headline.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
time | &str | Tick timestamp (Unix seconds). |
provider_code | &str | News provider code (e.g. "BRFG"). |
article_id | &str | News article identifier. |
headline | &str | News headline text. |
historical_news_end
End of historical news.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
has_more | bool | If true, more results available. |
news_article
Full news article text.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
article_type | i32 | Article type: 0=plain text, 1=HTML. |
article_text | &str | Full article body. |
real_time_bar
Real-time 5-second OHLCV bar.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
date | i64 | Bar date string. |
open | f64 | Open price. |
high | f64 | High price. |
low | f64 | Low price. |
close | f64 | Close price. |
volume | f64 | Volume. |
wap | f64 | Volume-weighted average price. |
count | i32 | Trade count. |
historical_ticks
Historical tick data (Last, BidAsk, or Midpoint).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
ticks | &HistoricalTickData | Historical tick data. |
done | bool | If true, all ticks have been delivered. |
historical_ticks_bid_ask
Historical bid/ask ticks.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
ticks | &HistoricalTickData | Historical tick data. |
done | bool | If true, all ticks have been delivered. |
historical_ticks_last
Historical last-trade ticks.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
ticks | &HistoricalTickData | Historical tick data. |
done | bool | If true, all ticks have been delivered. |
tick_option_computation
Option implied vol / greeks computation.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tick_type | i32 | Tick type ID or tick-by-tick type string. |
tick_attrib | i32 | |
implied_vol | f64 | Implied volatility. |
delta | f64 | Option delta. |
opt_price | f64 | Option theoretical price. |
pv_dividend | f64 | Present value of dividends. |
gamma | f64 | Option gamma. |
vega | f64 | Option vega. |
theta | f64 | Option theta. |
und_price | f64 | Underlying price. |
security_definition_option_parameter
Option chain parameters (strikes, expirations).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
exchange | &str | Exchange name. |
underlying_con_id | i64 | Underlying contract ID. |
trading_class | &str | Trading class. |
multiplier | &str | Contract multiplier. |
expirations | &[String] | Available expiration dates. |
strikes | &[f64] | Available strike prices. |
security_definition_option_parameter_end
End of option chain parameters.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
delta_neutral_validation
Delta-neutral validation response.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
con_id | i64 | Contract ID. Unique per instrument. |
delta | f64 | Option delta. |
price | f64 | Tick price. |
histogram_data
Price distribution histogram.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
items | &[(f64, i64 | Histogram entries [(price, count)]. |
market_rule
Market rule: price increment schedule.
| Parameter | Type | Description |
|---|---|---|
market_rule_id | i64 | Market rule ID. |
price_increments | &[PriceIncrement] | Price increment rules [{low_edge, increment}]. |
completed_order
Completed (filled/cancelled) order details.
| Parameter | Type | Description |
|---|---|---|
contract | &Contract | Contract specification (symbol, secType, exchange, currency, etc.). |
order | &Order | Order parameters (action, quantity, type, price, TIF, etc.). |
order_state | &OrderState | Order state (status, margin, commission info). |
completed_orders_end
End of completed orders list.
historical_schedule
Historical trading schedule (exchange hours).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
start_date_time | &str | Start date/time for tick query. |
end_date_time | &str | End date/time in "YYYYMMDD HH:MM:SS" format, or empty for now. |
time_zone | &str | Timezone string (e.g. "US/Eastern"). |
sessions | &[(String, String, String | Trading sessions [(ref_date, open, close)]. |
fundamental_data
Fundamental data (XML/JSON).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
data | &str | Raw data string (XML/JSON). |
update_mkt_depth
L2 book update (single exchange).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
position | i32 | Book position (row index) or position size. |
operation | i32 | Book operation: 0=insert, 1=update, 2=delete. |
side | i32 | Book side: 0=ask, 1=bid. Or order side "BOT"/"SLD". |
price | f64 | Tick price. |
size | f64 | Tick size. |
update_mkt_depth_l2
L2 book update (with market maker).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
position | i32 | Book position (row index) or position size. |
market_maker | &str | Market maker ID. |
operation | i32 | Book operation: 0=insert, 1=update, 2=delete. |
side | i32 | Book side: 0=ask, 1=bid. Or order side "BOT"/"SLD". |
price | f64 | Tick price. |
size | f64 | Tick size. |
is_smart_depth | bool | If true, aggregate depth from multiple exchanges via SMART. |
mkt_depth_exchanges
Available exchanges for market depth.
| Parameter | Type | Description |
|---|---|---|
descriptions | &[crate::types::DepthMktDataDescription] | Array of matching contract descriptions. |
tick_req_params
Tick parameters: min tick size, BBO exchange, snapshot permissions.
| Parameter | Type | Description |
|---|---|---|
ticker_id | i64 | Ticker/request ID. |
min_tick | f64 | Minimum tick size. |
bbo_exchange | &str | BBO exchange for smart component lookup (e.g. "SMART"). |
snapshot_permissions | i64 | Snapshot permissions bitmask. |
smart_components
SMART routing component exchanges.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
components | &[crate::types::SmartComponent] | Smart routing component exchanges. |
news_providers
Available news providers list.
| Parameter | Type | Description |
|---|---|---|
providers | &[crate::types::NewsProvider] | News provider list. |
display_group_list
Display group list.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
groups | &str | FA group definitions. |
display_group_updated
Display group updated.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
contract_info | &str | Display group contract info string. |
soft_dollar_tiers
Soft dollar tier list.
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
tiers | &[crate::types::SoftDollarTier] | Soft dollar tier list. |
family_codes
Family codes linking related accounts.
| Parameter | Type | Description |
|---|---|---|
codes | &[crate::types::FamilyCode] | Family code list. |
receive_fa
FA data (groups or profiles XML), as receiveFA (ibx#481).
| Parameter | Type | Description |
|---|---|---|
fa_data_type | i32 | FA data type (1=Groups, 2=Profiles, 3=Aliases). |
xml | &str | XML string. |
replace_fa_end
End of a replaceFA, as replaceFAEnd (ibx#481).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
text | &str | Informational text. |
user_info
User info (white branding ID).
| Parameter | Type | Description |
|---|---|---|
req_id | i64 | Request identifier. Used to match responses to requests. |
white_branding_id | &str | White branding ID (empty for standard accounts). |