• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Financial Instruments (Contracts)

Overview

An IBApi.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 TWS, the platform will try to match the provided contract object with a single candidate. If there is more than one contract matching the same description, TWS will return an error notifying you there is an ambiguity. In these cases the TWS needs further information to narrow down the list of contracts matching the provided description to a single element.

The best way of finding a contract’s description is within the TWS itself. Within the TWS, you can easily check a contract’s description either by double clicking it or through the Contract Info -> Description menu, which you access by right-clicking a contract in TWS:

contract_info_tws.png

The description will then appear:

contract_description_tws_without_debug.png

Note: you can see the extended contract details by choosing Contract Info -> Details. This option will open a web page showing all available information on the contract.

Whenever a contract description is provided via the TWS API, the TWS will try to match the given description to a single contract. This mechanism allows for great flexibility since it gives the possibility to define the same contract in multiple ways.

The simplest way to define a contract is by providing its symbol, security type, currency and exchange. The vast majority of stocks, CFDs, Indexes or FX pairs can be uniquely defined through these four attributes. More complex contracts such as options and futures require some extra information due to their nature. Below are several examples for different types of instruments.

ISLAND to NASDAQ API Compatibility

Upcoming ISLAND to NASDAQ naming change will make all of the ISLAND exchange definitions invalid.
As a compatibility measure a new setting has been introduced in TWS 10.16+: "Compatibility Mode: Send ISLAND for US Stocks trading on NASDAQ".
This setting will enable all of the contract definitions with ISLAND exchange to be still acknowledged.
It is strongly recommended to start implementing the NASDAQ exchange definition.

See also: