1. Who are Interactive Brokers?
Interactive Brokers is an international broker. It offers trading on over 100 platforms in 24 countries. If you want to trade in America, this is the first name that will catch your eye.
https://www.interactivebrokers.com
2. Trader Work Station terminal (TWS).
Interactive Brokers has its own desktop terminal called TWS. This terminal provides the ability to connect through API using WebSocket and TcpIp protocols. If you have an account with IB, you first need to install the TWS terminal. The TWS looks like this:
3. Setting up the TWS terminal.
To connect OsEngine to TWS, we need to configure the terminal. Open its settings:
In the main window of TWS:
1. Click on the File button in the top left corner.
2. Click on "Global Configuration".
A settings window will open. We are interested in the API settings. They are located here:
In the API settings, make sure everything matches the following screenshot:
4. Connecting OsEngine to Interactive Brokers.
Open Bot Station Light:
In the main window of the terminal:
1. Go to the connections tab.
2. Select the InteractiveBrokers connector and double-click on it.
A connection window will open:
Note that the port must match the port in TWS settings:
Next, configure the instruments you want to trade. Without this, the connection will not work. Click the "Show securities" button on the server:
1. Base active – the underlying asset of the contract. It's not necessary to specify for futures.
2. Market – the platform from which we want to obtain the contract.
3. Security Type – the type of contract.
4. Symbol – the name of the contract in the trading system.
5. Prime market – the main exchange for the contract.
6. Currency – the trading currency of the contract.
7. MD is internal - if you haven't purchased market data, you need to set this option to true. This will allow the robot to receive prices for trading based on the latest trades.
After this, press the Connect button, and the server will be active:
You can then create robots, connect them to data, and start trading:
If you have purchased deep data for instruments, the history will be loaded. If no data has been purchased, there will be no history.
IMPORTANT 1!!!
Check the server log.
If you have any issues with order placement, be sure to check the server log first before getting nervous. Don't ignore it. TWS will most likely provide information on why the robots are experiencing problems.
IMPORTANT 2!!!
Set your computer's time to match the location where you want to trade. TWS does not understand time settings on its own, and the API doesn't either. It's important for the candles to be drawn accurately.
Happy algorithm development!