154 OLPS: A TOOLBOX FOR ONLINE PORTFOLIO SELECTION
A.2.2.1 Trading Manager
Algorithm A.2: Trading manager for online portfolio selection.
Input: strategy_name: A string of the specified strategy;
dataset_name: A string of the specified dataset;
varargins: A variable-length input argument list for the specified strategy;
opts: A variable for options controlling the trading environment.
Output: cumulative_ret: Final cumulative wealth;
Cumprod_ret: Cumulative wealth at the end of each period;
daily ret: Daily return for each period;
ra_et: Analyzed results, including risk-adjusted returns;
run_time: Time for the strategy (in seconds).
begin
Initialize market data from dataset;
Open the log file and mat file;
Start the time variables;
Call strategy with parameters in varargins;
Terminate the time variables;
Analyze the results;
Close the log file and mat file;
end
The Trading Manager, as shown in Algorithm A.2, controls the whole simulation
of OLPS. At the start (Line 2), it loads market data from the specified dataset. Note
that this can be easily extended to load data from real brokers. Then, Lines 3 and 8
open and close two logging files, one for text and one for .MAT format. Lines 4 and
6 measure the computational time of the execution of a specified strategy. Measuring
the time in the trading manager ensures a fair comparison of the computational time
among different strategies. Line 5 is the core component, which calls the specified
strategy with specified parameters. Section A.3 will illustrate all included strategies
and their usages. Line 7 analyzes the executed results of the strategy, which will be
introduced later. The “manager.m” usage is shown as follows.
Usage
function [cum_ret, cumprod_ret, daily_ret, ra_ret,
run_time]...
= manager(strategy name, dataset name, varargins,
opts);
• cum_ret: cumulative return;
• cumprod_ret: a vector of cumulative returns at the end of every trading day;
• daily_ret: a vector of daily returns at the end of every trading day;
• ra_ret: analyzed result;
• run_time: computational time of the core strategy (excluding the manager routine);
T&F Cat #K23731 — K23731_A001 — page 154 — 9/28/2015 — 20:46