视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
CVaR投资组合优化程序
2025-09-25 14:29:34 责编:小OO
文档
我是新手 下面的程序是我从网上找的 是求投资组合模型CVaR的 请问Riskfun=@(w) w(nAssets+1)+(1/J)*(1/(1-beta))*sum(max(-w(i)*ScenRets(:,i)'-w(nAssets+1),0)); 中的(-w(i)*ScenRets(:,i)'是什么意思 w(i)表示什么呢 它与初值w0有什么关系

还有就是 i=1:nAssets; 我觉得 i 应该是收益样本的个数 i 的取值应该是从1到 J ,但是我该成i=1:J; 却运行错误

同时 请大家帮忙找找这个程序还存在哪些问题 谢谢

%-------------PORTFOLIO OPTIMIZATION FUNCTION UNDER CVAR MINIMIZATION----

%

function [fval,w]=CVaROptimization(ScenRets, R0, VaR0, beta, UB, LB)

%

%

% The function estimates the optimal portfolio weights that minimize CVaR

% under a given target return R0

%

%INPUTS: ScenRets: Portfolio returns matrix

% R0: The target return

% beta:The confidence level between 0.9 and 0.999

% LB, UB the upper and lower bound for the optimal weights. For example If

% you imput UB=.25 none of the stocks can consist more than the 25% of the

% portfolio.

% VaR0= the initial guess for the portfolio VaR

%

%OUTPUTS: fval = CVaR of the optimal portfolio

% w= the weights of the optimal portfolio, The last element in w

% equals the VaR of the optimal portfolio

%

%---------------- INPUT ARGUMENTS--------------------------------------

% The function accepts 6 imputs however only the two first are required

% If you dont supply the 6 argument then LB=0 (no short positions)

% If you dont supply the 5 argument then UB=1

% If you dont supply the 4 argument then beta=0.95

% If you dont supply the 3 argument VaR0 equals the HS VaR of the equally weighted

% portfolio

% Author: Manthos Vogiatzoglou, Un of Macedonia, 20/08/2008

% contact: vogia@yahoo.com

ScenRets=load('11.txt');

LB=0;

UB=0.5;

beta=0.99;

VaR0=0.05;

R0=0.25;

[J, nAssets]=size(ScenRets);

w0=[(1/nAssets)*ones(1,nAssets)];

if isempty(LB)

LB=0;

end

if isempty(UB)

UB=1;

end

if isempty(beta)

beta=.95;

end

if isempty(VaR0)

VaR0=quantile(ScenRets*w0',.95);

end

if beta>1|beta<0.9

error('The confidence level beta = 1 - alpha, should be in (0.9 0.99)')

end

if LB>=UB

error('The LB has to be smaller than UB')

end

if UB>1

error('The upper bound should be less than 1')

end

if LB<-1

error('The lower bound should be greater than -1')

end

i=1:nAssets;

% the objective function

Riskfun=@(w) w(nAssets+1)+(1/J)*(1/(1-beta))*sum(max(-w(i)*ScenRets(:,i)'-w(nAssets+1),0));

w0=[w0 VaR0];

% the (linear) equalities and unequalities matrixes

A=[-mean(ScenRets) 0];

A=[A; -eye(nAssets) zeros(nAssets,1)];

A=[A; eye(nAssets) zeros(nAssets,1)];

b=[-R0 -LB*ones(1,nAssets) UB*ones(1,nAssets)];

b=b';

Aeq=[ ones(1,nAssets) 0];

beq=[1];

options=optimset('LargeScale','off');

options=optimset(options,'MaxFunEvals',5000);

% The VaR of the optimal portfolio equals w(nassets+1)

[w,fval,exitflag,output

]=fmincon(Riskfun,w0,A,b,Aeq,beq,LB,UB,[],options)下载本文

显示全文
专题