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 identifierexchange- An optional exchange string. IfNone, defaults to “SMART”
§Errors
Returns an error if the conversion fails (e.g., unsupported instrument type, invalid format).