[][src]Module twsapi::examples::contract_samples

Examples of populating fields that define various types of contacts

Functions

bond
bond_with_cusip
brfgbroadtape_news_feed
brfupdnbroadtape_news_feed
by_con_id

Or their con_id (EUR.uSD sample). Note: passing a contract containing the con_id can cause problems if one of the other provided attributes does not match 100% with what is in IB's database. This is particularly important for contracts such as Bonds which may change their description from one day to another. If the con_id is provided, it is best not to give too much information as in the example below.

by_isin

It is also possible to deine contracts based on their ISIN (IBKR STK sample).

cash_cfd
cfd
commodity
cont_and_expiring_fut
cont_fut
csfbcontract
djnlbroadtape_news_feed
djtopbroadtape_news_feed
dutch_warrant

Dutch Warrants (IOPTs) can be defined using the local symbol or conid

eur_gbp_fx
european_stock
european_stock2
european_stock_cfd
future_combo_contract

CBOE volatility Index Future combo contract

future_with_local_symbol

Rather than giving expiration dates we can also provide the local symbol attributes such as symbol, currency, strike, etc.

future_with_multiplier
futures_on_options
index
inter_cmdty_futures_contract
jefferies_contract
mutual_fund
news_feed_for_query
option_at_box
option_at_ise
option_combo_contract
option_for_query

Ambiguous contracts are great to use with Contract::req_contract_details. This way you can query the whole option chain for an underlying. Bear in mind that there are pacing mechanisms in place which will delay any further responses from the TWS to prevent abuse.

option_with_local_symbol

Using the contract's own symbol (local_symbol) can greatly simplify a contract description. Watch out for the spaces within the local symbol!

option_with_trading_class

Option contracts require far more information since there are many contracts having the exact same attributes such as symbol, currency, strike, etc. This can be overcome by adding more details such as the

qbalgo_contract
simple_future

Future contracts also require an expiration date but are less complicated than options.

smart_future_combo_contract
stock_combo_contract

STK Combo contract Leg 1: 43645865 - IBKR's STK Leg 2: 9408 - McDonald's STK

us_option_contract
us_stock_at_smart
usstock
usstock_cfd
usstock_with_primary_exch
wrong_contract

Note the space in the symbol!