Features of working with Interactive Brokers data provider

Selecting a security (contract)

While working through the Interactive Brokers data provider, the TSLab program does not have the ability to receive a list of available securities (contracts).

To start working with a security (contract), you need to enter the ticker of the security (contract) in the appropriate field of the "Manage Contracts" window, which can be accessed from the Interactive Brokers data provider settings. In the same window, you must specify:

  • the name of the market (either in manual mode or select from the list of available ones)

  • the type of security (contracts).

As additional contract parameters, you can specify the contract currency and contract expiration in the corresponding fields of the window.

Adding Futures

You can add all futures for the underlying asset. To do this, you need to specify:

  • Ticker;

  • Market;

  • Currency;

  • Type (futures);

  • Expiration may not be specified.

For example: MSFT, ONE, USD, Futures.

After the necessary properties of a security (contract) are specified, you can add the security to the list of cached contracts for further use using the "Add contract" button.

Adding Options

To add options, you must specify the expiration date, since there are a lot of options. Select the type of Option (Call or Put).

After the necessary properties of a security (contract) are specified, you can add the security to the list of cached contracts for further use using the "Add contract" button.

Alternatively, in order for the security to be recognized by the TSLab program, you must place and immediately cancel an order for the security you are interested in using the TWS terminal. Thus, the name of the security will be remembered in the list of cached contracts in the TSLab program.

Manage limits in lots

The Interactive Brokers API used by the TSLab program does not transmit lot size information. Accordingly, to buy 1 lot containing, for example, 100 shares, you must specify 100 in the agent's settings.

Unfortunately, the Interactive Brokers API we use does not transmit lot size information. Therefore, if one lot is set in the agent's settings, the agent will buy one share, not one lot. Accordingly, to purchase one lot = 100 shares, 100 lots must be specified in the agent's settings. The same goes for the ticket manager.

Interactive Brokers Commission

To test algorithms on stocks, use the "Relative commission with minimum" block.

  • In the block, set the parameter "Minimum commission" = 1. The broker does not charge a fee for the volume of the transaction, and each transaction, with any volume, is 1$

  • The "Commission, %" block parameter can be used to approximate slippage in trades.

  • "Margin" is indicated in % per annum. Accounting is only for shorts. Specify its size with the broker.

Placing orders outside the trading session on the exchange

The IB broker supports placing orders outside of the trading session on the exchange. This functionality is not fully supported by TSLab. Therefore, when placing an application outside the session, the response to confirm the application may take longer than the specified amount of waiting for a response in the Program settings.

After the timeout expires, the program will place the request again, thus there will be a double execution.

Solution

To prevent this situation with the Interactive Brokers data provider, it is necessary to organize the algorithms so that they do not place orders outside of trading hours. If it is not possible to do this, then it is recommended to organize a connection to TWS, taking into account the request waiting timeout.

In TSLab, open the Program Settings window.

File -> Program settings -> Trading -> Order timeout

The value of the Order timeout field must be greater than the difference between the trading session start time and the broker connection time.

We do not recommend placing orders outside the exchange, obviously the broker executes such orders either rarely or never. Also, in a few milliseconds, the broker can send an update on an order placed outside of trading time, that the order is CANCELLED, and then it is executed.

Accordingly, the same problem arises with double execution. The order has been canceled, so the program must place a new one, according to the signals.

Setting up a SMART data provider

If you set the "Use SMART always" setting in the data provider's settings, then instruments from some exchanges, such as MEXI, cannot be loaded, since MEXI is not available in the SMART market. You can create multiple data providers. Using different API IDs. There is no special configuration required for TWS.

How to download instruments from the CBOE exchange

Last updated