Asset Classes

Free investment financial education

Language

Multilingual content from IBKR

Close Navigation
Learn more about IBKR accounts

Configuring IB’s Trader Workstation

Lesson 3 of 8
Duration 4:00
Level Intermediate
Close Navigation
Contributed By: QuantInsti

In previous lesson, we listed down the steps for installation of R and Rstudio. The next step is to configure the Trader Workstation (TWS) before we start writing programs in R. This lesson explains the steps required to set up the Trader Workstation.

In this lesson, you would:

  • Learn about the Interactive Brokers API Architecture
  • Learn to configure the Trader WorkStation (TWS)

Interactive Brokers API Architecture

Interactive Brokers provides API solutions which can be run on Windows, Linux, and MacOS. The API makes a connection to the IB Trader Workstation (TWS). The TWS, in turn, is connected to the IB data centers and thus, all the communication is routed via the TWS. The IBrokers R package enables a user to write his strategy/program in R and helps it get executed via the IB TWS.

Flow Structure Diagram

Before we start writing programs in R, we need to configure the Trader Workstation (TWS). The next section explains the steps to configure the TWS.

Steps to Configure the Trader Workstation (TWS)

  • Click on the File tab in Trader Workstation (TWS).
  • Click on the “Global configuration” under the “Application Settings” section.
  • Click on the “API-Settings” under the “Configuration” folder shown on the left-hand side panel.
  • Check the “Enable ActiveX and Socket Clients” box.
  • Check the “Create API message log file” box.
  • Check the ‘Include market data in API log file’ box.
  • Finally, click on the “Apply” shown at the bottom of the API settings page and click OK.

Additional notes

TWS Log Files

If you check the “Create API message log file” box, it will create TWS log files.

  • API message log file contain the exchanged message sequences between the R application and the Trader Workstation.
  • The API message log files will be created within the C drive Jts folder on a Windows system.
  • The TWS logs will be log.[day].txt where day corresponds to the week day when the log file was written.
  • By default, the logging level is set to ‘Error’ which records a minimum amount of diagnostic information.
  • To capture the API messages it necessary to set the logging level to ‘Detail’.

If you also check the ‘include market data in API log file’ box, it will cause real-time market data to be captured in the API when trouble shooting market data problems.

Reset API order Id sequence button

A unique order Id is required every time an order is placed to an account. This unique order Id has to be greater than all the order Ids previously used. The reset button allows resetting the order Id sequence. However, note that this can be done if there are no active orders.

Summary

In this lesson, we learned to configure the Trader Workstation (TWS). In the next lesson, we start with the introduction to the IBrokers Package and explain the various API methods available in the package with examples. The subsequent lessons will explain other advanced API methods and finally illustrate an example strategy in R.

Note – The IBrokers package provides native R access to Interactive Brokers Trader Workstation API

Join The Conversation

If you have a general question, it may already be covered in our FAQs. If you have an account-specific question or concern, please reach out to Client Services.

Leave a Reply

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from QuantInsti and is being posted with its permission. The views expressed in this material are solely those of the author and/or QuantInsti and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

Disclosure: R API Disclosure

This software is in no way affiliated, endorsed, or approved by Interactive Brokers or any of its affiliates. It comes with absolutely no warranty and should not be used in actual trading unless the user can read and understand the source. IBrokers is a pure R implementation of the TWS API.

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.