TWSLink Help



The TWSLink batch tester, short: BaTe, is intended to quickly create and test typical TWSLink command sequences. BaTe allows to track the whole circuit: The call of exported functions and TWSLink (API) responses.
BaTe has 2 pages: Page Function calls is used to create your sequence, so a batch of TWSLink exported functions which are to be executed.
Page Callback shows all outgoing commands (exported function calls, green) and what TWSLink answered with callbacks.

Page Function Calls

  • Section 1 is where you create the sequence. It has also a context menu which pops up on right click. Use up- and down arrow on the right, to change the order of function call.
  • Section 2 is where you describe your sequence or set parameter values for a function prev. selected by double click in section 1. Button Load allows to load a previously saved sequence. You will find some predefined sequence in xml/batchtest folder of your TWSLink root. Button Save saves current sequence. Section 2 can be used to attach a description. Switch to description view (if not already active) by a click on button I.
  • Section 3 is where you pick TWSLink functions for your sequence. Click on table header to sort by name or category. This table contains only TWSLink exported functions, except load and unload which are to simluate TWSLink load and TWSLink unload. Press Add Selection to copy all selected functions to the bottom of your sequence in section 1. Press Insert Selection to copy all selected functions on top of the latest selected row in your sequence in section 1.
  • Section 4 is where you get help information for selected function either by double clicking image I in section 3 or single click on a row in section 1. When button open extern pressed, current help site is opened in your standard browser.
  • Section 5 makes some basic logging and can give errors or warnings around batch handling but no TWSLink errors or warnings.

Section 1 control panel

The panel is used to run and control your sequence. Start batch runs the batch as often as defined in field Loops A delay in milliseconds can be defined between 2 calls of the batch. If you need a specific delay, use function WAITDLL. Once you are ready with batch and you need to integrate it in your script or program, press Copy to Clipboard. This allows to paste the batch with a prefix of your choice to your script code.


NOTE: The load command implies a TWSLink exported function call SET_EVENT_HANDLER. So this function is not needed to list in your sequence. By this BaTe runs in passive eventhandling mode. The callback are shown in page Callack.


Section 2 parameter input

When you double click on a function in section 1, the parameters for this function are loaded into section 2. The green field can be edited by a double click in order to set the parameter value. So far, there are 4. special expression which evaluate to a constant value:

  • ret(i) : This means that return value of function call with batch index i is taken as parameter value. Assumed, that function call 2 return 10555, then ret(2) is evaluated to 10555 (for instance to grap a contract uid).
  • #idx# : This is replaced by the batch index of the function.
  • #datetime(+/-1seconds)# : This is replaced by a datetime string of NOW of format yyyymmdd hh:mm:ss +/- (optional) given seconds. Sample: #datetime# is evaluated to datetimenow. #datetime+20# is evaluated to datetimenow + 20 seconds.
  • #datetimesec(+/-1seconds)# : This is replaced by a datetime integer of NOW, which denotes current date as seconds past from 19700101, +/- (optional) given seconds.
  • [mathematical expression] : If you like to pass a mathematical expression, this must be enclosed in '[]'. For instance parameter #7 (upper picture) is evluated by 10 + 0.1 * batch_index = 10 + 0.1 * 5 = 10.5 , as batch index of this function is 5.

Page Callback

The panel shows all exported function calls - green - and responses from TWSLink (callback) ordered by the time of their occurance.

The black columns describe the function call (1. column green) or, in the event of callback, the main category (int1) and optional subcategory (int2) of callback. A double click on row raises a dialog which gives detailed information about the function call or callback. Press Show Help to load a html help with information about the callback: what parameters are used and their meaning. Int1 describes always the category of callback, such as order event order account value, etc..Int2 in addition can describe a subcategory, in particular if Int1=2.


Callback filter

The upper section allows to define an Int1 and Int2 filter. If empty, no filter is active. You can type a comma separated string of integer numbers to set the filter. If Int1 or Int2 values of incoming callbacks are not listed in your filter, they don't get displayed in table.


Help dialog linked to double click on row

Final

BaTe should help you to get fast results with TWSLink as it makes its usage transparent. Before coding with TWSLink in your script, you can use BaTe to check out, if it works like intended. Just play around, nothing can happen.


If you do not know how to implement a specific task with TWSLink or if you like to share your ideas with others, feel free to post your batch file in TWSLink yahoo group

TWSLink Manual, Copyright 2011 trade-commander.org