Skip to main content

instrument_id_to_ib_contract

Function instrument_id_to_ib_contract 

Source
pub fn instrument_id_to_ib_contract(
    instrument_id: InstrumentId,
    exchange: Option<&str>,
) -> Result<Contract>
Expand description

Convert a NautilusTrader InstrumentId to an Interactive Brokers Contract.

This function handles all instrument types:

  • Stocks (STK)
  • Options (OPT)
  • Futures (FUT, CONTFUT)
  • Futures Options (FOP)
  • Forex (CASH)
  • Crypto (CRYPTO)
  • CFDs (CFD)
  • Commodities (CMDTY)
  • Indices (IND)
  • Option Spreads (BAG) - requires contract details map

§Arguments

  • instrument_id - The NautilusTrader instrument identifier
  • exchange - An optional exchange string. If None, defaults to “SMART”

§Errors

Returns an error if the conversion fails (e.g., unsupported instrument type, invalid format).