Reference

getSettings

QuantiacsMatlabToolbox_v220.getSettings(tsName)

Scans a trading system file for its global settings and returns them in struct settings. getSettings is called once from runts prior to the first call of a trading system.

Usage:

s = getSettings('tsName')

parses trading system tsName and stores its settings in struct s.

Args:

Field Data Type Description
tsName (required) STRING Specifies the trading system to be scanned

Returns:

Field Data Type Description
settings STRUCT  
settings.arguments CELL ARRAY Strings with arguments of the trading system settings.markets
settings.samplebegin INTEGER Date in the format YYYYMMDD
The date specifies the beginning of the in sample period, market data before that date is ignored by runts
DEFAULT: 0 (no sample begin)
settings.sampleend INTEGER Date in the format YYYYMMDD
The date specifies the end of the in sample market data before that date is ignored by runts
DEFAULT: inf (no sample end)
settings.lookback INTEGER Specifies the size of the lookback window, i.e.The amount of data given to the trading system in each call. Limiting the lookback to the absolute necessary usually reduces the runtime
DEFAULT: 504 - roughly two years of daily market data
settings.budget DOUBLE Starting capital in USD for the backtest
DEFAULT: 1,000,000.00
settings.slippage DOUBLE Multiplier of the daily range (HIGH - LOW). That is used to simulate the impact of transaction costs
DEFAULT: 0.05

loaddata

QuantiacsMatlabToolbox_v220.loaddata(settings, refresh)

Loads market data loaddata is called from runts. It downloads and reads the market data specified in argument settings.markets and returns the mandatory data collection DATE, OPEN, HIGH, LOW, CLOSE, VOL, OI, P, R, RINFO and other data fields eventually listed in settings.arguments. The timeline of the data is standardized and trimmed to DATEs between settings.samplebegin and settings.sampleend. Missing data is interpolated with the last known value.

Usage:

data = loaddata(settings)

loads the market data specified in settings.markets and returns a struct out with the mandatory data and user defined variables in settings.arguments

Args:

Field Data Type Description
settings (required) STRUCT  
settings.markets (required)   Defines the markets to be loaded
settings.arguments (required)   Defines the market data to be loaded
settings.samplebegin (required)   Defines the begin of the in sample period
settings.sampleend (required)   Defines the end of the in sample period
refresh (optional) BOOLEAN Force download of market data
Default: FALSE

Returns:

Field Data Type Description
out STRUCT Collection of standardized, filled and trimmed market data

runts

QuantiacsMatlabToolbox_v220.runts(tsName, plotEquity, reloadData, state)

Backtests a trading system. runts evaluates the trading system function specified in the argument tsName` and returns the struct ret. ``runts calls the trading system for each period with sufficient market data, and collets the returns of each call to compose a backtest.

Usage:

s = runts('tsName')

evaluates the trading system specified in string tsName, and stores the result in struct s.

Args:

Field Data Type Description
tsName (required) STRING Specifies the trading system to be backtested
plotEquity (optional) BOOLEAN Show the equity curve plot after the evaluation
Default: TRUE
reloadData (optional) BOOLEAN Force reload of market data.
Default: FALSE
state (optional) STRUCT Resume computation of an existing backtest. State needs to be of the same form as ret.

Returns:

Field Data Type Description
ret STRUCT  
ret.tsName STRING Name of the trading system, same as tsName
ret.fundDate INTEGERS All dates of the backtest in the format YYYYMMDD
ret.fundEquity DOUBLE Equity curve for the fund (collection of all markets)
ret.marketEquity DOUBLE Equity curves for each market in the fund
ret.marketExposure DOUBLE Collection of the returns p of the trading system function. Equivalent to the percent exposure of each market in the fund. Normalized between -1 and 1.
ret.settings STRUCT The settings of the trading system as defined in file
ret.errorLog CELL ARRAY Strings with error messages
ret.runtime DOUBLE Runtime of the evaluation in seconds
ret.stats STRUCT Performance numbers of the backtest
ret.evalDate INTEGER Last market data present in the backtest