Trading with Multiple TWS

 

 

This documentation provides instructions on how to set ZeroLine Trader/ZeroLine SimTrader to trade with multiple TWS.

 

  1. Open Multiple TWS
  2. Define the Connections to the Multiple TWS
  3. Define Allocation Profile
  4. Trade with Multiple TWS

 

Open Multiple TWS

You can try ZLT's multiple TWS capability with IB demo accounts first. Here is the instruction how to open two demo TWS.

The screen shots in this document is based on two individual TWS opened on two computers.

 

Define the Connections to the Multiple TWS

1. Add the multiple TWS into the Connections. In the ZLT main window, select Configure -> Markets ....

2. In the Connections table, right click and select New.

 

 3. Note a new connection row is inserted.

        Double click on a field to edit it.

Name:  the connection name. Just make sure the name is unique from other connections.

Broker: the broker name. For now, it is only IB.

Account: the IB account name, such as U255432.

IP Address is the IP Address of the computer where the TWS is running.

If the TWS is running on the same computer as ZLT is. You can use 127.0.0.1 as the IP address.

Otherwise, you can find the IP address by typing "ipconfig" in a DOS command window.

To open a DOM command window, click Start->Run ...

Then type cmd in the Run window:

Click OK and in the DOS window type ipconfig:

 

 

The Port Number should be the same as the number in the TWS's Configure->API->Socket Port ....

If you are running multiple TWS on the same computer, please make sure the TWS have different Port Numbers.

The Client ID can be any positive integer number. If you make multiple connections to one TWS, each connection has to have different client ID.

Auto Connect: check it if you want the connection to be connected at the ZLT startup.

Data Source: check it if you want ZLT to get market data for this connection.

 

Notes:

1. If you are connecting ZLT, for example, which is on Computer A to a TWS on a different computer (Computer B), please make sure Computer B is able to accept connection from Computer A. Please check the fireware settings on Computer B.

A simple way to check the connection is to use the ping command. Just type ping <IP Address> in the DOS command window.

In following example, it shows that it fails to connect to the computer at IP address 192.168.0.100.

Define the Allocation Profile

Now we need to define the allocation profile which determine how shares or contracts are allocated to different TWS, or more accurately, to different accounts in different TWS. The TWS may have multiple accounts if it is a Financial Advisor TWS.

1. From ZLT main window, click Configure->Allocation Profiles ... to open the Allocation Profiles dialog:

Note: ZLT automatically create Sub Account allocation profile for each account. The Sub Account allocation profile's name is in the format of AccountName:ConnectionName, for example, U163:TWS-C. If an order has this allocation profile, all the contracts/shares will be allocated to the account U163 in TWS-C.

2. Right click on the profiles table and select New Absolute Shares Profile ...:

 

3. The New Allocation Profile dialog pops up:

4. Enter the profile name and shares as following:

5. Click OK to dismiss the New Allocation Profile dialog. Note in the Allocation Profiles dialog, the new profile we just created is listed:

 

6. Click OK to close the Allocation Profiles dialog.

 

Trading with Multiple TWS
 

Now we are back to the ZLT main window and ready to send orders to multiple TWS.

1. If the Allocation column is not shown, just right click on the column header and check the Allocation checkbox in the popup menu.

2. Select a data line and click in its Allocation cell and select the ALL-ONE profile.

3. Click on the Ask Price to generate a Buy order line. Note the order quantity is 2.

4. Click the "T" Transmit cell to transmit the order

Note:

  1. The orders are sent to two TWS and has been executed.
  2. The stop and target orders are generated in the two TWS.
  3. Two data lines, one for each account U163 and U151, are automatically inserted.  The account information is indicated in its Allocation cell. These two data lines are called Sub Data Lines. The data line with profile "ALL-ONE" is called Parent Data Line.
  4. When a sub data line is selected, the operation will be only pertain to the one account. For example, when the sub data line for account U151 is selected, the CLS button will only close the position is U151. You can right click on sub data line and open a DOM to visualize the orders in one account such as U151.
  5. When a parent data line is selected, the operation will be applied to all its sub accounts. For example, when the data line with "ALL-ONE" allocation profile is selected, the CLS button will close the positions in both U163 and U151 account. You can right click on a parent data line to open a DOM and see all the orders in multiple accounts.

5. Right click on the parent data line with "ALL-ONE" allocation profile and select Close. Notice the positions in account U163 and U151 are all closed.

 

Note: You may have different account numbers instead of U163 and U151.

If you have any question or comment, feel free to email support@zerolinetrader.com