Expand description
ibcore — Standalone IB Gateway integration layer.
Wraps ibapi::Client in a newtype IbClient that provides:
- Market data snapshots —
StockSnapshot,OptionSnapshotfor one-shot bid/ask/last/Greeks data viaIbClient::stock_snapshotandIbClient::option_snapshot. - Order-agnostic account data —
IbClient::positions,IbClient::account_summary,IbClient::pnl,IbClient::net_liquidation. - Option chain resolution —
IbClient::fetch_option_chainreturnsOptionChainData(expirations + strikes). - Market data streaming —
TickEvent,TickStreamfor real-time market data ticks viaIbClient::tick_stream. - Historical data —
IbClient::historical_datareturnsHistoricalDatawith OHLCVBars. Types re-exported fromhistoricalmodule. - Structured errors —
IbErrortranslates raw IB error codes into typed variants instead of letting rawNoticecodes escape. - Diagnostic events —
DiagnosticEventemitted viatokio::sync::broadcaston the underlyingibapi::Client’s notice stream, carrying gateway version, farm status, connection state, and structured error context.
§Design
ibcore wraps ibapi rather than re-implementing it. All IB wire-protocol
details are handled by the underlying ibapi crate; ibcore adds ergonomics,
structured errors, and observability on top.
§Re-exports
Commonly-used ibapi types are re-exported so consumers need only depend on
ibcore, never on ibapi directly:
- Contracts:
Contract,OptionRight,SecurityType,LegAction - Account data:
Position,PnL - Orders:
Action,combo_limit_order,combo_market_order - Market data:
MarketDataType - Prelude: [
ibapi::prelude::*]
Re-exports§
pub use client::IbClient;pub use client::is_connection_dead;pub use snapshots::StockSnapshot;pub use snapshots::OptionSnapshot;pub use chain::OptionChainData;pub use diagnostics::DiagnosticEvent;pub use diagnostics::FarmState;pub use diagnostics::ConnectionState;pub use diagnostics::AccountType;pub use errors::IbError;pub use exchange::get_primary_exchange;pub use contract::build_option_contract;pub use contract::parse_expiry;pub use streaming::TickEvent;pub use streaming::TickStream;pub use orders::OpenOrder;pub use orders::OrderStatusEvent;pub use orders::OrderStatusStream;
Modules§
- chain
- Option chain data — expirations and strikes for an underlying.
- client
- Persistent IB Gateway client wrapper.
- contract
- Option contract construction helpers.
- diagnostics
- Diagnostic event types — structured notifications from the IB Gateway notice stream.
- errors
- Structured IB error types — maps raw ibapi error codes to typed variants.
- exchange
- Primary options exchange resolution for stock symbols.
- historical
- Historical market data.
- order_
builder - Helpers for constructing commonly used order templates. Free-function order constructors — the advanced / client-less layer.
- orders
- Order placement, cancellation, and status tracking.
- snapshots
- Market data snapshot types for stocks and options.
- streaming
- Real-time market data streaming.
Structs§
- Account
Summary Tags - Constants for account summary tags used in account summary requests. These tags define which account information fields to retrieve.
- Bar
- Bar describes the historical data bar.
- Client
- Asynchronous TWS API Client
- Client
Builder - Builder for an async
Client. Acquire viaClient::builder. - Contract
- Contract describes an instrument’s definition.
- Contract
Month - Contract month for futures
- Currency
- Currency identifier
- Cusip
- CUSIP identifier
- Duration
- Duration specifier used in historical data requests (e.g.
1 D). - Exchange
- Exchange identifier
- Execution
Filter - Filter criteria used to determine which execution reports are returned.
- Expiration
Date - Date for option expiration
- Family
Code - Family code assigned to a group of accounts.
- Historical
Data - Container for historical bar responses.
- Historical
Data Builder - Builder for historical bar data requests.
- Historical
Schedule Builder - Builder for the historical-schedule API.
- Historical
Ticks Builder - Builder for the historical-ticks API.
- Isin
- ISIN identifier
- Market
Depth Builder - Builder for level-2 (order book) market-depth subscriptions.
- Notice
- An error message from the TWS API.
- Notice
Stream - A handle for receiving globally routed notices on the async transport.
- PnL
- Aggregated profit and loss metrics for the entire account.
- PnLSingle
- Real-time profit and loss metrics for a single position.
- Position
- Open position held within the account.
- Strike
- Validated strike price (must be positive)
- Subscription
- Asynchronous subscription for streaming data.
- Symbol
- Strong type for trading symbols
- Tick
ByTick Builder - Builder for tick-by-tick real-time subscriptions.
Enums§
- Account
Summary Result - Result of an account summary request emitted by the Client.
- Account
Update - Account update events delivered while streaming high-level account data.
- Account
Update Multi - Account update events scoped to an account/model code pair.
- Action
- Identifies the side. Generally available values are BUY and SELL. Additionally, SSHORT and SLONG are available in some institutional-accounts only. For general account types, a SELL order will be able to enter a short position automatically if the order quantity is larger than your current long position. SSHORT is only supported for institutional account configured with Long/Short account segments or clearing with a separate account. SLONG is available in specially-configured institutional accounts to indicate that long position not yet delivered is being sold.
- BarSize
- Request granularity for historical bars.
- Bond
Identifier - Bond identifier type
- Error
- The main error type for IBAPI operations.
- Execution
Filter Side - Side filter on outbound execution requests. IBKR’s wire vocabulary for
ExecutionFilter.sideis"BUY"/"SELL"only. - Execution
Side - Side of an
Executionreport — direction of a filled order. - Historical
BarSize - Request granularity for historical bars.
- Historical
What ToShow - Enumerates the data payload returned when requesting historical data.
- Ignore
Size - Whether a tick-by-tick subscription should drop tick size information.
- LegAction
- Trading action for spread/combo legs. Mirrors the IBKR wire vocabulary
BUY/SELL/SSHORT.SLONGis not accepted on combo legs — only the SSHORT short-sale form is gated (SSHORT_COMBO_LEGS = 35, well below our floor of 210), so all three variants are unconditionally valid. - Market
Data Type - Market data type for switching between real-time and frozen/delayed.
- Notice
Category - Typed classification of a
Noticeby TWS error-code range. - Option
Right - Option right (Call or Put). Matches IBKR’s wire vocabulary
"C"/"P". - Order
Status Kind - The lifecycle state of an order, as reported by TWS.
- Order
Update - Updates received when monitoring order activity.
This enum is used by
order_update_streamto deliver real-time order updates. - Orders
- Enumerates possible results from querying an Order.
- Place
Order - Responses from placing an order.
- Position
Update - Messages emitted while streaming position updates.
- Position
Update Multi - Messages emitted while streaming model-code scoped position updates.
- Realtime
BarSize - Bar size for real-time bars.
- Realtime
What ToShow - Specifies the type of data to show for real-time bars.
- Security
Type - SecurityType enumerates available security types
- Smart
Depth - Whether a market-depth subscription aggregates rows across exchanges.
- Subscription
Item - An item yielded by a
Subscription. - Tick
Types - Various types of market data ticks.
- Trading
Hours - Specifies whether to include only regular trading hours or extended hours
- What
ToShow - Enumerates the data payload returned when requesting historical data.
Constants§
- IBAPI_
VERSION - Version of the
ibapidependency this crate was built against.
Traits§
- Stream
Ext - An extension trait for
Streams that provides a variety of convenient combinator functions. - Subscription
Item Stream Ext - Extension trait that adds
filter_datato any stream yieldingResult<SubscriptionItem<T>, Error>. Async mirror of the syncSubscriptionItemIterExt. - ToDuration
- Helper trait to convert integer counts into
Durations.
Functions§
- combo_
limit_ order - Create combination orders that include options, stock and futures legs (stock legs can be included if the order is routed through SmartRouting). Although a combination/spread order is constructed of separate legs, it is executed as a single transaction if it is routed directly to an exchange. For combination orders that are SmartRouted, each leg may be executed separately to ensure best execution. Products: OPT, STK, FUT
- combo_
market_ order - Create combination orders that include options, stock and futures legs (stock legs can be included if the order is routed through SmartRouting). Although a combination/spread order is constructed of separate legs, it is executed as a single transaction if it is routed directly to an exchange. For combination orders that are SmartRouted, each leg may be executed separately to ensure best execution. Products: OPT, STK, FUT
- version
- Crate version string, from
CARGO_PKG_VERSIONat compile time.