Manual

Use cases

Backtesting system doesn't support portfolio testing so only one kind of market instrument allowed. Though doesn't matter how trading system was defined (it can be even not automatic). Backtesting is performed using scenario file. Scenario file should be generated by trading system using any accessible method.

How to use

"Backtester" file is an application, compiled for Unix systems, it can be started from command line without any parameters. Files "account", "history" and "scenario" should be in the same folder.

Input

Input data is represented by following text files, which application searches in its own catalog. Files must be composed from records, which are lines, composed from numbers. Numbers should be separated by comma or semicolon.

Account

Has one record from two numbers, corresponding to initial cash and assets amount. Example: 1000,0 means 1000 currency units and 0 asset units.

History

Has large number of records, every record represents one deal in the past (tick time frame in other words). Data should be written in [date];[time];[price];[volume] format, where date and time are numbers without delimiters in format ddmmyyyy and hhmmss, where, for example, "hh" is a hour number, using two digits in 24h format.

Example: 20090507,102959,172.99000,5 means a deal was at 7 May 2009, 10:29:59 at the price of 172.99 with 5 shares.

Scenario

Every record in scenario file corresponds to one order generated by trading system. Format of each line is [number],[order type],[transaction type],[price],[volume],[activation data],[activation time],[deactivation data],[deactivation time],[number of relating order],[spread],[indent].

Number is simply order number in scenario list beginning from 1.

Order type can be: 1: market, 2: limit, 3: stop loss, 4: take profit, 5: trailing stop.

Transaction type is: 1: buy, 2: sell.

Price and volume, data and time should be written simular to history file. Activation is the point in time, when trading system wants to send order to market. Deactivation is the point in time when trading system wants to cancel this order if it still wasn't fulfilled.

When order gets to market, some portion of currency or assets at your account become reserved. So if you use relating order, this amount will not be reserved twice. For example, stop loss and take profit orders for same position.

Spread is a number in currency units which is used as main parameter for trailing stop order.

Indent is a number in currency units which shows acceptable slippage. For example, when price falls to stop level, system generates limit sell order, which price value should be less than stop level to avoid skipping. Difference between stop level and limit sell level called indent.

Example: 2,5,2,176.6,1000,20090507,113350,20090507,184455,1,0.5,0.2 means that this is second order in the list; order is trailing stop for long position (transaction type = 2(sell), so trailing stop order will sell when conditions will be performed); start price to activate order is 176.6; 1000 shares; start time is 7 May 2009, 11:33:50; deactivating time is 7 May 2009, 18:44:55; order relates to the first order in the list (which probable have bought these shares); spread for trailing stop is 0.5 (when price will fall deeper than to 0.5 from the highest value since order activating, system will execute limit order with price value less by 0.2 (indent field) to current).

Output

Output shows report about every deal during the test. After test is completed backtester shows scenario efficiency on the used history data. Report shows account condition at the time moment, when testing was stopped, compares it with initial data. Also report shows efficiency metrics like deals number, total income, buy-and-hold profit, max drawdown, profit mean and standart deviation, sharp ratio, payoff ratio, profit factor and details about profitable and loss deals.