Skip to main content

Module contracts

Module contracts 

Source
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).
ButterflyLegs
Legs of a SpreadBuilder::butterfly, by option contract id.
CollarLegs
Legs of a SpreadBuilder::collar, by contract id.
ComboLeg
A single component within a combo contract.
ContinuousFuturesBuilder
Continuous futures contract builder with type states
Contract
Contract describes an instrument’s definition.
ContractBuilder
Builder for creating and validating Contract instances
ContractDescription
Contract data and list of derivative security types
ContractDetails
ContractDetails provides extended contract details.
ContractDetailsBuilder
Builder for a contract-details request that yields one ContractDetails per matching contract.
ContractMonth
Contract month for futures
CryptoBuilder
Crypto currency builder
Currency
Currency identifier
Cusip
CUSIP identifier
DeltaNeutralContract
Delta and underlying price for Delta-Neutral combo orders. Underlying (STK or FUT), delta and underlying price goes into this attribute.
Exchange
Exchange identifier
ExpirationDate
Date for option expiration
ForexBuilder
Forex pair builder
FuturesBuilder
Futures contract builder with type states
IneligibilityReason
Reason why a contract is ineligible for trading.
IronCondorLegs
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
MarketRule
Minimum price increment structure for a particular market rule ID.
Missing
Marker type for missing required fields in type-state builders
OptionBuilder
Option contract builder with type states for required fields
OptionChain
Option chain metadata for a specific underlying security.
OptionChainBuilder
Builder for an underlying’s option chain: one OptionChain per exchange the options trade on.
OptionComputation
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.
PriceIncrement
Price ladder entry describing the minimum tick between price bands.
SmartComponent
One contributing exchange behind a consolidated BBO feed.
SpreadBuilder
Spread/Combo builder
StockBuilder
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§

BondIdentifier
Bond identifier type
ComboLegOpenClose
OpenClose specifies whether an order is an open or closing order.
FundAssetType
Fund asset type.
FundDistributionPolicyIndicator
Fund distribution policy indicator.
LegAction
Trading action for spread/combo legs. Mirrors the IBKR wire vocabulary BUY / SELL / SSHORT. SLONG is 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.
OptionRight
Option right (Call or Put). Matches IBKR’s wire vocabulary "C" / "P".
SecurityIdType
Security identifier scheme. Matches IBKR’s secIdType wire vocabulary.
SecurityType
SecurityType enumerates available security types

Constants§

MAX_BUFFER_LIMITDeprecated
The largest buffer_limit.