Appendix A: The Scripting Language
Previous  Top  Next

The TradeMatcher engine provides and uses a small but powerful scripting language which gives it the capability to preprocess and match virtually any data file of trades from any brokerage. By building in a scripting language, you won't be tied to software that becomes obsolete with a simple brokerage change of the data order.

We don't expect that many users will want to learn how to make their own scripts, and indeed, there will be no need, as common scripts are provided. However, that power is there "under the hood" if needed, and everyone gets the benefits from any user that develops and shares a new script for changing circumstances.

Prepared scripts can be downloaded from the website at www.tradematcher.com or copied from this document for common situations. If no script is available, and you are willing to supply your trade data to us, we will prepare a script for the data and will then add it to our library. Your trade data will not be kept once the script to process it is completed.

Every script used by the program is a simple text file that can be created with any text editor such as NotePad or WordPad. The script file name must be "script.txt" for the program to recognize and load it. When creating this file on a windows machine, in most cases you will name the file "script" and in the save dialog box make sure it has a type of "text". This will cause the operating system to name it script.txt for the full name. In the event you have created such a file and it is in your project folder but the TradeMatcher program tells you it does not exist, the most common cause is that you have a file named "script.txt.txt" because you manually put the .txt extension. If so, simply rename the file and run again.

By way of illustration, here is a sample script for use with data grabbed from Ameritrade:

replace|inputfile.txt|outputfile.txt| |
reorder|outputfile.txt|reordered.txt| |,|1,7,8,10,13
reverse|reordered.txt|reversed.txt
striplines|reversed.txt|mergedfile.txt|strippedlines.txt|2|,|buy|sell
match|mergedfile.txt

 
From the sample, you may notice that the file is densely packed with the vertical bar or "pipe" character (which is the shifted backslash) used to break up the fields. This character is used because spaces are common items which may appear in a data file while the vertical bar is not. You should also notice that every line begins with one of the seven command words detailed below. Any line that begins with anything other than one of these commands is ignored by the scripting engine and is treated as a comment. The fields following the command words are parameters, and the necessary parameters for each command are described below.

The purpose of the scripting language is first to manipulate a data file into the format which the matching engine can use. The manipulation could also be done by a user with a combination of other tools such as a text editor, spreadsheet and word processor. However, by providing a scripting language and common scripts the program is much more flexible and the process is much simplified from the user standpoint.

The scripting language is simple and concise, yet very powerful. The seven commands are:

replace  
reverse  
reorder  
striplines  
match  
wash  
delete  
 
A summary of each of the command words with sample usage follows: