./backtest.pl [ options ] <code>

./backtest.pl [ options ] <system_alias> <code>

./backtest.pl [ options ] "<full_system_name>" <code>


Backtest will run a backtest of a system on the indicated code.

You can either describe the system using options, give a full system name, or you can give a system alias. An alias is defined in the configuration file with entries of the form Aliases::Global::<alias_name> <full_system_name>.

The full system name consists of a set of properties, such as trade filters, close strategy, etc., together with their parameters, separated by vertical bars ("|"). Multiple properties of the same type can be defined, e.g., there could be a set of close strategies. For example, System:ADX 30 | TradeFilters:Trend 2 5 | MoneyManagement:Normal defines a system based on the "ADX" system, using a trend following trade filter "Trend", and the "Normal" money management.

The following abbreviations are supported: Systems = SY CloseStrategy = CS TradeFilters = TF MoneyManagement = MM OrderFactory = OF Signals = S Indicators = I Generic = G

Another example of a full system name is SY:TFS|CS:SY:TFS|CS:Stop:Fixed 4|MM:VAR.


Backtest provide a set of options, so that you can use a combination of MoneyManagement, TradeFilters, OrderFactory an CloseStrategy modules.

--full, --start=<date>, --end=<date>, --nb-item=<nr>

Determines the time interval over which to perform the backtest. In detail:

--start=2001-1-10, --end=2002-11-17

The start and end dates over which to perform the backtest. The date needs to be in the format configured in ~/.gt/options and must match the timeframe selected.


The number of periods to use in the analysis.


Consider all available periods.

The periods considered are relative to the selected time frame (i.e., if timeframe is "day", these indicate a date; if timeframe is "week", these indicate a week; etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and "YYYY" for years.

The interval of periods examined is determined as follows:

  1. if present, use --start and --end (otherwise default to last price)
  2. use --nb-item (from first or last, whichever has been determined), if present
  3. if --full is present, use first or last price, whichever has not yet been determined
  4. otherwise, consider a two year interval.

The first period determined following this procedure is chosen. If additional options are given, these are ignored (e.g., if --start, --end, --full are given, --full is ignored).


The timeframe can be any of the available modules in GT/DateTime.


Determines the number of periods (back from the last period) that are loaded for a given market from the data base. Care should be taken to ensure that these are consistent with the performed analysis. If not enough data is loaded to satisfy dependencies, for example, correct results cannot be obtained. This option is effective only for certain data base modules and ignored otherwise.


Output is generated using the indicated HTML::Mason component. For Example, --template="backtest.mpl" The template directory is defined as Template::directory in the options file. Each template can be predefined by including it into the options file For example, Template::backtest backtest.mpl


Output is generated in html


Generate a graph of your portfolio value over the time of the backtest and display it in the generated html.


Display the trades with little symbols on the graph. This works well if trades last long enough otherwise your graph will be overwhelmed with unsignificant symbols.


Store the resulting portfolio in the indicated file.


Calculate commissions and annual account charge, if applicable, using GT::Brokers::<broker_name> as broker.


use the GT::Systems::<system_name> as the source of buy/sell orders.


use the GT::MoneyManagement::<money_management_name> as money management system.


use the GT::TradeFilters::<filter_name> as a trade filter.


use GT::OrderFactory::<order_factory_name> as an order factory.


use GT::CloseStrategy::<close_strategy_name> as a close strategy.


Stores the backtest results in the "backtests" directory (refer to your options file for the location of this directory) using the set name SETNAME. Use the --set option of analyze_backtest.pl to differentiate between the different backtest results in your directory.


Override the "backtests" directory in the options file.


A configuration option (typically given in the options file) in the form of a key=value pair. For example, --option=DB::Text::format=0 sets the format used to parse markets via the DB::Text module to 0.


./backtest.pl TFS 13000

./backtest.pl --full TFS 13000

./backtest.pl --close-strategy="Systems::TFS" --close-strategy="Stop::Fixed 6" --money-management="VAR" --money-management="OrderSizeLimit" --system="TFS" --broker="SelfTrade Intégral" 13000

./backtest.pl --broker="SelfTrade Intégral" "SY:TFS|CS:SY:TFS|CS:Stop:Fixed 6|MM:VAR|MM:OrderSizeLimit" 13000