Code covered by the BSD License  

Highlights from
Developing a Financial Market Index Tracker using MATLAB OOP and Genetic Algorithms

Developing a Financial Market Index Tracker using MATLAB OOP and Genetic Algorithms

by

 

01 Aug 2008 (Updated )

Files used in the webinar of the same name

TestPerformance(IndexFund,NumStocks,Alpha,Beta,conn,StartIdx,Companies,Wts,Dates)
function [out,VI] = TestPerformance(IndexFund,NumStocks,Alpha,Beta,conn,StartIdx,Companies,Wts,Dates)

% Initialise the Tracker
% Add listeneres for tracker events

TrackerFund = GATracker('Name','DemoIndex Track','TargetIndex',IndexFund,...
    'NumStocks',NumStocks,'NumPop',70,'DataBase',conn,'DisplayFlag',false,...
    'SoftTarget',Alpha,'HardTarget',Beta);

Initialise(TrackerFund);


% Now run through 2007

for ii = StartIdx+1:numel(Dates)
    Idx = find(Wts(ii,:) ~= 0);
    ChangeWeights(IndexFund,Dates(ii),Companies(Idx,1)',Wts(ii,Idx)',true);
end

D = IndexFund.Dates;

out = Value(TrackerFund,D(:));

if nargout > 1
    VI = Value(IndexFund,IndexFund.Dates);
end

Contact us