Skip to content

Commit

Permalink
PGUI + Config Manager
Browse files Browse the repository at this point in the history
1. Now have 3 modes - GUI (only Matlab), Pseuod-GUI(Octave + Matlab) and
Command Line Interface (Octave + Matlab)
2. Implemented Configuration Menu - now easier to add/remove
algorithms/data.
  • Loading branch information
doyensahoo committed Jun 15, 2015
1 parent eb1fbce commit d30fd11
Show file tree
Hide file tree
Showing 17 changed files with 1,626 additions and 15 deletions.
9 changes: 8 additions & 1 deletion GUI/config/addData.m
@@ -1,3 +1,10 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of OLPS: http://OLPS.stevenhoi.org/
% Original authors: Doyen Sahoo
% Contributors: Bin LI, Steven C.H. Hoi
% Change log:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ ] = addData( dataFileName, dataDescriptionName, newDataFrequency, configFile )

load(configFile);
Expand All @@ -6,6 +13,6 @@
dataList{index} = dataDescriptionName;
dataName{index} = dataFileName;
dataFrequency(index) = newDataFrequency;

disp('Added new Dataset.');
save(configFile, 'algorithmList', 'algorithmName', 'algorithmParameters', 'dataFrequency', 'dataList', 'dataName', 'defaultParameters', 'windowRisk');
end
25 changes: 14 additions & 11 deletions GUI/config/addStrategy.m
@@ -1,8 +1,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of OLPS: http://OLPS.stevenhoi.org/
% Original authors: Doyen Sahoo
% Contributors: Bin LI, Steven C.H. Hoi
% Change log:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ ] = addStrategy( newStrategyFileName, configFile )
% Adding a strategy to the configuration so that it can be read by the OLPS
% toolbox



load(configFile);

% In this config file - update 4 things
Expand All @@ -18,26 +24,23 @@
tline = fgets(fid);
while(ischar(tline))
if tline(1) ~= '%'
algoName = tline;
algoName = strtrim(tline);
tline = fgets(fid);
nParameters = str2num(tline);

for i = 1:1:nParameters
tline = fgets(fid);
paraName{i} = tline;
paraName{i} = strtrim(tline);
tline = fgets(fid);
paraValue{i} = str2double(tline);
end

end
tline = fgets(fid);
end


% Implement all updates
algorithmName{end+1} = newStrategyFileName;
algorithmList{end+1} = algoName;
index = size(algorithmList, 1) ;
index = length(algorithmList)+1;
algorithmName{index,1} = newStrategyFileName;
algorithmList{index,1} = algoName;
for i = 1:1:nParameters
algorithmParameters{index,i} = paraName{i};
defaultParameters{index,i} = paraValue{i};
Expand All @@ -48,7 +51,7 @@
cd ../GUI/config/
save(configFile, 'algorithmList', 'algorithmName', 'algorithmParameters', 'dataFrequency', 'dataList', 'dataName', 'defaultParameters', 'windowRisk');

disp('Strategy Added to config. It can now be read by the toolbox.');
disp('Strategy Added to config. It can now be read by the toolbox. Set it as the active configuration and restart the toolbox.');

end

Binary file modified GUI/config/config.mat
Binary file not shown.
16 changes: 16 additions & 0 deletions GUI/config/removeData.m
@@ -0,0 +1,16 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of OLPS: http://OLPS.stevenhoi.org/
% Original authors: Doyen Sahoo
% Contributors: Bin LI, Steven C.H. Hoi
% Change log:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ ] = removeData( dataId, configFile )
% Delete a dataset from a specified configuration file
load(configFile);
dataList(dataId) = [];
dataFrequency(dataId) = [];
dataName(dataId) = [];
save(configFile, 'algorithmList', 'algorithmName', 'algorithmParameters', 'dataFrequency', 'dataList', 'dataName', 'defaultParameters', 'windowRisk');
disp('Dataset removed from config. Set it as the active configuration and restart the toolbox.');
end
17 changes: 17 additions & 0 deletions GUI/config/removeStrategy.m
@@ -0,0 +1,17 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of OLPS: http://OLPS.stevenhoi.org/
% Original authors: Doyen Sahoo
% Contributors: Bin LI, Steven C.H. Hoi
% Change log:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ ] = removeStrategy( strategyId, configFile )
% Delete a dataset from a specified configuration file
load(configFile);
algorithmList(strategyId) = [];
algorithmName(strategyId) = [];
algorithmParameters(strategyId,:) = [];
defaultParameters(strategyId,:) = [];
save(configFile, 'algorithmList', 'algorithmName', 'algorithmParameters', 'dataFrequency', 'dataList', 'dataName', 'defaultParameters', 'windowRisk');
disp('Strategy removed from config. Set it as the active configuration and restart the toolbox.');
end
49 changes: 46 additions & 3 deletions OLPS_cli.m
@@ -1,4 +1,4 @@
function OLPS_cli2
function OLPS_cli(dataset)
% OLPS_cli: run OLPS toolbox in CLI (available in both Matlab and Octave)
% this program demos different strategies of on-line portfolio selection
% in the mode of command-line interface (CLI)
Expand All @@ -21,5 +21,48 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cd CLI;
homeMenu;
cd Strategy;

opts.quiet_mode = 1; opts.display_interval = 500;
opts.log_mode = 1; opts.mat_mode = 1;
opts.analyze_mode = 1; opts.progress = 0;
opts.his = 0;

if (nargin<1)
dataset = 'djia';
end

%----------Benchmarks--------------
manager('ubah', dataset, {0}, opts);
manager('best', dataset, {0}, opts);
manager('ucrp', dataset, {0}, opts);
manager('bcrp', dataset, {0}, opts);

%---------Follow the Winner-------------------
manager('up', dataset, {0}, opts);
manager('eg', dataset, {0.05, 0}, opts);
manager('ons', dataset, {0, 1, 1/8, 0}, opts);

% manager('sp_start', dataset, {0.25, 0}, opts);
% manager('grw_start', dataset, {0.00005, 0}, opts);
% manager('m0_start', dataset, {0.5, 0}, opts);

%----------Follow the Loser------------------------
manager('anticor', dataset, {30, 0}, opts);
manager('anticor_anticor', dataset, {30, 0}, opts);
manager('pamr', dataset, {0.5, 0}, opts);
manager('pamr_1', dataset, {0.5, 500, 0}, opts);
manager('pamr_2', dataset, {0.5, 500, 0}, opts);
manager('cwmr_var', dataset, {2, 0.5, 0}, opts);
manager('cwmr_stdev', dataset, {2, 0.5, 0}, opts);
manager('olmar1', dataset, {10, 5, 0}, opts);
manager('olmar2', dataset, {10, 0.5, 0}, opts);

%--------Pattern Matching based approach---------
manager('bk', dataset, {5, 10, 1, 0}, opts);
manager('bnn', dataset, {5, 10, 0}, opts);
manager('corn', dataset, {5, 0.1, 0}, opts);
manager('cornu', dataset, {5, 1, 0.1, 0}, opts);
manager('cornk', dataset, {5, 10, 0.1, 0, 1}, opts);

end
25 changes: 25 additions & 0 deletions OLPS_pgui.m
@@ -0,0 +1,25 @@
function OLPS_pgui
% OLPS_cli: run OLPS toolbox in CLI (available in both Matlab and Octave)
% this program demos different strategies of on-line portfolio selection
% in the mode of command-line interface (CLI)
%
% OLPS_cli(dataset)
%
% dataset: one can choose any of the following data sets
% - 'djia': (default) DJIA (US) perioid 01/14/2001 - 01/14/2003
% - 'msci': MSCI (global) peroid 04/01/2006 - 03/31/2010
% - 'nyse-n': NYSE (US) peroid 01/01/1985 - 06/30/2010
% - 'nyse-o': NYSE (US) peroid 07/03/1962 - 12/31/1984
% - 'sp500': S&P500(US) period 01/02/1998 - 01/31/2003
% - 'tse': TSE (CA) peroid 01/04/1994 - 12/31/1998

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of OLPS: http://OLPS.stevenhoi.org/
% Original authors: Bin LI, Doyen Sahoo, Steven C.H. Hoi
% Contributors:
% Change log:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cd PGUI;
homeMenu;

0 comments on commit d30fd11

Please sign in to comment.