|
|
This documentation is now deprecated. Please switch to the IBKR Campus for up-to-date information regarding IBKR's API solutions. |
The TWS API is a simple yet powerful interface through which IB clients can automate their trading strategies, request market data and monitor your account balance and portfolio in real time.
Our TWS API components are aimed at experienced professional developers willing to enhance the current TWS functionality. Regrettably, Interactive Brokers cannot offer any programming consulting. Before contacting our API support, please always refer to our available documentation, sample applications and Recorded Webinars
This guide reflects the very latest version of the TWS API -9.72 and higher- and constantly references the Java, VB, C#, C++ and Python Testbed sample projects to demonstrate the TWS API functionality. All code snippets are extracted from these projects and we suggest all those users new to the TWS API to get familiar with them in order to quickly understand the fundamentals of our programming interface. The Testbed sample projects can be found within the samples folder of the TWS API's installation directory.
Our programming interface is designed to automate some of the operations a user normally performs manually within the TWS Software such as placing orders, monitoring your account balance and positions, viewing an instrument's live data... etc. There is no logic within the API other than to ensure the integrity of the exchanged messages. Most validations and checks occur in the backend of TWS and our servers. Because of this it is highly convenient to familiarize with the TWS itself, in order to gain a better understanding on how our platform works. Before spending precious development time troubleshooting on the API side, it is recommended to first experiment with the TWS directly.
Remember: If a certain feature or operation is not available in the TWS, it will not be available on the API side either!
The TWS is designed to accept up to fifty messages per second coming from the client side. Anything coming from the client application to the TWS counts as a message (i.e. requesting data, placing orders, requesting your portfolio... etc.). This limitation is applied to all connected clients in the sense were all connected client applications to the same instance of TWS combined cannot exceed this number. On the other hand, there are no limits on the amount of messages the TWS can send to the client application.
If your regular trading account has been approved and funded, you can use your Account Management page to open a Paper Trading Account which lets you use the full range of trading facilities in a simulated environment using real market conditions. Using a Paper Trading Account will allow you not only to get familiar with the TWS API but also to test your trading strategies without risking your capital. Note the paper trading environment has inherent limitations.
This product includes Intel® Decimal Floating-Point Math Library (in binary form) developed by the Intel Corporation under its license which can be found here.
Decimal type (source/cppclient/client/Decimal.h)
All operations with Decimal type should be performed with Intel® Decimal Floating-Point Math Library.
Currently the following methods from the library are exposed: add, sub, mul, div, stringToDecimal, decimalToString, decimalStringToDisplay, decimalToDouble and doubleToDecimal.
All other methods can be exposed on demand.
Details of exposed methods:
Decimal add (Decimal, Decimal) - adds two decimal values. Returns decimal result of operation.
Decimal sub (Decimal, Decimal) - subtracts the second decimal value from the first. Returns decimal result of operation.
Decimal mul (Decimal, Decimal) - multiplies two decimal values. Returns decimal result of operation.
Decimal div (Decimal, Decimal) - divides the first decimal value by the second. Returns decimal result of operation.
Decimal stringToDecimal (std::string) - converts string to decimal value.
std::string decimalToString (Decimal) - converts decimal value to string. String can have scientific notation.
std::string decimalStringToDisplay (Decimal) - converts decimal value to string without scientific notation.
double decimalToDouble (Decimal) - converts decimal value to double value. Note: conversion of decimal to double may lose 16th-18th decimal.
Decimal doubleToDecimal (double) - converts double value to decimal value.