pub struct Contract {Show 20 fields
pub contract_id: i32,
pub symbol: String,
pub security_type: SecurityType,
pub last_trade_date_or_contract_month: String,
pub strike: f64,
pub right: String,
pub multiplier: String,
pub exchange: String,
pub currency: String,
pub local_symbol: String,
pub primary_exchange: String,
pub trading_class: String,
pub include_expired: bool,
pub security_id_type: String,
pub security_id: String,
pub combo_legs_description: String,
pub combo_legs: Vec<ComboLeg>,
pub delta_neutral_contract: Option<DeltaNeutralContract>,
pub issuer_id: String,
pub description: String,
}
Expand description
Contract describes an instrument’s definition
Fields§
§contract_id: i32
The unique IB contract identifier.
symbol: String
The underlying’s asset symbol.
security_type: SecurityType
§last_trade_date_or_contract_month: String
The contract’s last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day.
strike: f64
The option’s strike price.
right: String
Either Put or Call (i.e. Options). Valid values are P, PUT, C, CALL.
multiplier: String
The instrument’s multiplier (i.e. options, futures).
exchange: String
The destination exchange.
currency: String
The underlying’s currency.
local_symbol: String
The contract’s symbol within its primary exchange For options, this will be the OCC symbol.
primary_exchange: String
The contract’s primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE.
trading_class: String
The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec ’13 future’s trading class is “FGBL”.
include_expired: bool
If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available.
security_id_type: String
Security’s identifier when querying contract’s details or placing orders ISIN - Example: Apple: US0378331005 CUSIP - Example: Apple: 037833100.
security_id: String
Identifier of the security type.
combo_legs_description: String
Description of the combo legs.
combo_legs: Vec<ComboLeg>
§delta_neutral_contract: Option<DeltaNeutralContract>
Delta and underlying price for Delta-Neutral combo orders. Underlying (STK or FUT), delta and underlying price goes into this attribute.
issuer_id: String
§description: String
Implementations§
Source§impl Contract
impl Contract
Sourcepub fn stock(symbol: &str) -> Contract
pub fn stock(symbol: &str) -> Contract
Creates a stock contract from the specified symbol.
Currency defaults to USD and exchange defaults to SMART.
§Examples
use ibapi::contracts::Contract;
let aapl = Contract::stock("AAPL");
assert_eq!(aapl.symbol, "AAPL");
assert_eq!(aapl.currency, "USD");
assert_eq!(aapl.exchange, "SMART");
Sourcepub fn futures(symbol: &str) -> Contract
pub fn futures(symbol: &str) -> Contract
Creates a futures contract from the specified symbol.
Currency defaults to USD.
§Examples
use ibapi::contracts::Contract;
let es = Contract::futures("ES");
assert_eq!(es.symbol, "ES");
assert_eq!(es.currency, "USD");
Sourcepub fn crypto(symbol: &str) -> Contract
pub fn crypto(symbol: &str) -> Contract
Creates a cryptocurrency contract from the specified symbol.
Currency defaults to USD and exchange defaults to PAXOS.
§Examples
use ibapi::contracts::Contract;
let btc = Contract::crypto("BTC");
assert_eq!(btc.symbol, "BTC");
assert_eq!(btc.currency, "USD");
assert_eq!(btc.exchange, "PAXOS");
Sourcepub fn news(provider_code: &str) -> Contract
pub fn news(provider_code: &str) -> Contract
Creates a news contract from the specified provider code.
§Examples
use ibapi::contracts::Contract;
let news = Contract::news("BRFG");
assert_eq!(news.symbol, "BRFG:BRFG_ALL");
assert_eq!(news.exchange, "BRFG");
Sourcepub fn option(
symbol: &str,
expiration_date: &str,
strike: f64,
right: &str,
) -> Contract
pub fn option( symbol: &str, expiration_date: &str, strike: f64, right: &str, ) -> Contract
Creates an option contract from the specified parameters.
Currency defaults to USD and exchange defaults to SMART.
§Arguments
symbol
- Symbol of the underlying assetexpiration_date
- Expiration date of option contract (YYYYMMDD)strike
- Strike price of the option contractright
- Option type: “C” for Call, “P” for Put
§Examples
use ibapi::contracts::Contract;
let call = Contract::option("AAPL", "20240119", 150.0, "C");
assert_eq!(call.symbol, "AAPL");
assert_eq!(call.strike, 150.0);
assert_eq!(call.right, "C");