Content

TWSLink2 introduction

TWSLink2 is a DLL / COM based plugin for all applications, programming- and script languages that can utilize DLL or COM. TWSLink2 is NOT a standalone application. So you can use it only in conjunction with your favor application or programming language or script.

Before you can use TWSLink2 functions, you need to load it as DLL (like in MetaTrader) or create as COM (like in Excel). Once done, you can see an icon in your quick launch section, usually lower right of your screen.The icon looks like one of the samples below:
Make also sure, that TWS or Gateway is configured to work with TWSLink2.

TWSLink2 tray icon states
no licensenot connectedconnectingconnected
License is invalid. This can have various reason. Get more information by right click on tray icon select "Show / Update license...". TWSLink2 is not connected to TWS / Gateways. Use function CONNECT for this. TWSLink2 is connecting and doing initial requests. TWSLink2 is connected and initial requests complete.

Loading / creating is a single action per runtime. The next step usually connects to TWS / Gateway and proximate you do all contract registration. This as well is done once. Now you are ready to place orders, getting market data, account data and so on. The following table shows the standard usage of TWSLink2:


create (CreateObject("twslink.twslinkCom")) / load (LoadLibrary("twslink.dll") TWSLinkdoing once
connect to TWS / Gatewaydoing once
register contractsdoing once
place orders
request market data
request historical data
...

A complete list of TWSLink2 functions can be found here .

How to retrieve data back from TWSLink2, TWS / Gateway or IB is explained in this subject.

A typical attribute of TWSLink2 functions is the UID. This is an integer number to identify uniquely an order, a contract or an event. Such UIDs are either returned by a function or expected as parameter for a function. For instance, REGISTER_CONTRACT returns an UID for contract, which can subsequently passed to function PLACE_ORDER to place an order for this contract.

Please have a look at this brief Excel sample.

 

To get results quickly with TWSLink2, TWSLinkBaTe is recommended, a batch testing tool, which is installed in TWSLink2 root. This tools allows to checkout all TWSLink2 function and is well integrated with TWSLink2 help.

If you need additional support or like to share your solution with other users or give other TWSLink2 users advice, please join the TWSLink2-yahoo-group.


Please read also about TWSLink2 license.


Good luck for your trading.


 

 


TWSLink2 Manual, Copyright 2012 trade-commander.org