%% Compute the Optimal Risky Portfolio
% This example shows how to compute the optimal risky portfolio by generating the efficient frontier from the asset data and then finding the optimal risky portfolio and allocate capital. The risk-free investment return is 8%, and the borrowing rate is 12%.

ExpReturn = [0.1 0.2 0.15]; 

ExpCovariance = [0.005   -0.010    0.004 
                -0.010    0.040   -0.002 
                 0.004   -0.002    0.023];
[PortRisk, PortReturn, PortWts] = portopt(ExpReturn,... 
ExpCovariance);

RisklessRate  = 0.08;
BorrowRate    = 0.12;
RiskAversion  = 3;

[RiskyRisk, RiskyReturn, RiskyWts, RiskyFraction, ... 
OverallRisk, OverallReturn] = portalloc(PortRisk, PortReturn,... 
PortWts, RisklessRate, BorrowRate, RiskAversion)

% Copyright 2015 The MathWorks, Inc.