Expand description
A Contract object represents trading instruments such as a stocks, futures or options.
Every time a new request that requires a contract (i.e. market data, order placing, etc.) is sent to the API, the system will try to match the provided contract object with a single candidate. If there is more than one contract matching the same description, the API will return an error notifying you there is an ambiguity. In these cases the API needs further information to narrow down the list of contracts matching the provided description to a single element. Contract definitions and related functionality for trading instruments.
This module provides data structures for representing various financial instruments including stocks, options, futures, and complex securities. It includes contract creation helpers, validation, and conversion utilities.
Modules§
- tick_
types - Tick type constants used in option computations and market data.
Structs§
- AnyMonth
- Marker type for a futures builder with an unspecified contract month (open query).
- Butterfly
Legs - Legs of a
SpreadBuilder::butterfly, by option contract id. - Collar
Legs - Legs of a
SpreadBuilder::collar, by contract id. - Combo
Leg - A single component within a combo contract.
- Continuous
Futures Builder - Continuous futures contract builder with type states
- Contract
- Contract describes an instrument’s definition.
- Contract
Builder - Builder for creating and validating Contract instances
- Contract
Description - Contract data and list of derivative security types
- Contract
Details - ContractDetails provides extended contract details.
- Contract
Details Builder - Builder for a contract-details request that yields one
ContractDetailsper matching contract. - Contract
Month - Contract month for futures
- Crypto
Builder - Crypto currency builder
- Currency
- Currency identifier
- Cusip
- CUSIP identifier
- Delta
Neutral Contract - Delta and underlying price for Delta-Neutral combo orders. Underlying (STK or FUT), delta and underlying price goes into this attribute.
- Exchange
- Exchange identifier
- Expiration
Date - Date for option expiration
- Forex
Builder - Forex pair builder
- Futures
Builder - Futures contract builder with type states
- Ineligibility
Reason - Reason why a contract is ineligible for trading.
- Iron
Condor Legs - Legs of a
SpreadBuilder::iron_condor, by option contract id. - Isin
- ISIN identifier
- Leg
- Internal representation of a spread leg used by SpreadBuilder.
- LegBuilder
- Builder for individual spread legs
- Market
Rule - Minimum price increment structure for a particular market rule ID.
- Missing
- Marker type for missing required fields in type-state builders
- Option
Builder - Option contract builder with type states for required fields
- Option
Chain - Option chain metadata for a specific underlying security.
- Option
Chain Builder - Builder for an underlying’s option chain: one
OptionChainper exchange the options trade on. - Option
Computation - Receives option specific market data. TWS’s options model volatility, prices, and deltas, along with the present value of dividends expected on that options underlier.
- Price
Increment - Price ladder entry describing the minimum tick between price bands.
- Smart
Component - One contributing exchange behind a consolidated BBO feed.
- Spread
Builder - Spread/Combo builder
- Stock
Builder - Stock contract builder with type-safe API
- Strike
- Validated strike price (must be positive)
- Symbol
- Strong type for trading symbols
- TagValue
- TagValue is a convenience struct to define key-value pairs.
Enums§
- Bond
Identifier - Bond identifier type
- Combo
LegOpen Close - OpenClose specifies whether an order is an open or closing order.
- Fund
Asset Type - Fund asset type.
- Fund
Distribution Policy Indicator - Fund distribution policy indicator.
- 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. - Option
Right - Option right (Call or Put). Matches IBKR’s wire vocabulary
"C"/"P". - Security
IdType - Security identifier scheme. Matches IBKR’s
secIdTypewire vocabulary. - Security
Type - SecurityType enumerates available security types
Constants§
- MAX_
BUFFER_ LIMIT Deprecated - The largest
buffer_limit.