-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdp.m
19 lines (19 loc) · 833 Bytes
/
mdp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function [new_weights] = mdp(weights,returns,lambda)
%Checks if entered data is timetable and mods if so
if istimetable(returns)
temp = timetable2table(returns);
returns = tick2ret(temp(:,2:(length(weights)+1)));
end
%creates new Portfolio object
p = Portfolio('NumAssets',length(weights));
p = estimateAssetMoments(p,returns);
%sets default constraints, i.e. weights are b/t 0 and 1 inclusive and must
%sum up to 1
p = setDefaultConstraints(p);
sigma = sqrt(diag(p.AssetCovar));
% Variance + Herfindahl-Hirschman (HH) index
%0.1 instead of lambda for now
MDPMixObjFun = @(x) x'*p.AssetCovar*x - lambda*(sigma'*x);
% Solution that accounts for risk and HH diversification
new_weights = estimateCustomObjectivePortfolio(p,MDPMixObjFun);
end