金融数量分析2:Markowitz均值方差模型

博客原址:http://blog.sina.com.cn/s/blog_6afc560001017xuy.html

Portfolio在金融投资理论中占有非常重要的地位,Markowitz根据每一种证券的预期收益率、方差和所有证券间的协方差矩阵,得到证券组合的有效边界,再根据投资者的效用无差异曲线,确定一组Portfolio。

Markowitz均值方差模型为:

min sigma^2=X'MX

max E(r)=X'R

s.t. x1+x2+...+xn=1

其中,R=(R1,R2,...,Rn)';Ri=E(ri)是第i种资产的预期收益率;X=(x1,x2,...,xn)'是投资组合的权重向量;M是n种资产间的协方差矩阵;E(r)和sigma^2分别是投资组合的期望回报率和方差。

 

一、收益与风险计算函数portstats

[PortRisk,PortReturn]=portstats(ExpReturn,ExpCovariance,PortWts)

选取 浦发银行600000sh  皖通高速600012sh  老白干酒600559sh 国药股份600511sh 四只股票三年中的月收益率作为期望收益率ExpReturn,它们的协方差矩阵为ExpCovariance
     ExpReturn=[ 0.0082    0.0072    0.0426    0.0056]
     ExpCovariance=     0.0106    0.0053    0.0055    0.0004
                        0.0053    0.0092    0.0043    0.0026
                        0.0055    0.0043    0.0306    0.0071
                        0.0004    0.0026    0.0071    0.0095

假设资产权重为PortWts=[0.25 0.25 0.25 0.25]

 

>>[PortRisk,PortReturn]=portstats(ExpReturn,ExpCovariance,PortWts)

PortRisk =

0.0830
    PortReturn =

0.0159

二、有效前沿计算函数frontcon

Markowitz均值方差模型是经典的带约束的二次优化问题,给定期望收益时,方差最小解唯一,frontcon使用matlab优化工具箱的fmincon函数进行求解。(也可以参见 )

[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, NumPorts, PortReturn, AssetBounds, Groups, GroupBounds, varargin)

输入参数:ExpReturn资产的预期收益率;ExpCovariance资产的协方差矩阵; NumPorts(可选)有效前沿上输出点的个数,默认为10;PortReturn(可选)给定有效前沿上输出点回报;AssetBounds(可选)每种资产权重的上下限;Groups(可选)资产分组;GroupBounds(可选)每个资产群的约束;

 

输出参数:PortRisk资产组合风险(标准差), PortReturn资产组合预期收益(期望), PortWts(权重)

 

对于 浦发银行600000sh 皖通高速600012sh 老白干酒600559sh 国药股份600511sh 四只股票

ExpReturn=[ 0.0082 0.0072 0.0426 0.0056]
    ExpCovariance= 0.0106 0.0053 0.0055 0.0004
                   0.0053 0.0092 0.0043 0.0026
                   0.0055 0.0043 0.0306 0.0071
                   0.0004 0.0026 0.0071 0.0095

NumPorts=10

>>[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn, ExpCovariance, NumPorts)

PortRisk =

0.0702
    0.0737
    0.0806
    0.0901
    0.1014
    0.1141
    0.1278
    0.1427
    0.1585
    0.1750
    PortReturn =

0.0068
    0.0108
    0.0148
    0.0187
    0.0227
    0.0267
    0.0307
    0.0346
    0.0386
    0.0426
    PortWts =

0.3404    0.2133         0    0.4463
    0.3058    0.2219    0.1095    0.3628
    0.2673    0.2305    0.2193    0.2829
    0.2288    0.2391    0.3291    0.2030
    0.1903    0.2478    0.4389    0.1230
    0.1518    0.2564    0.5486    0.0431
    0.1067    0.2330    0.6602         0
    0.0538    0.1722    0.7740         0
    0.0009    0.1114    0.8877         0
         0         0    1.0000         0

>> frontcon(ExpReturn,ExpCovariance, NumPorts)

金融数量分析2:Markowitz均值方差模型

三、约束条件下的有效前沿计算函数portopt

在实际构建投资组合时要考虑到法律法规、风险管理等条件的限制,这样的portfolio就是有约束条件,例如基金的“双百分之十规则”:基金投资于某一证券的市值不能超过基金资产的百分之十,投资于某一上市公司的股票不能超过该公司市值的百分之十。

[PortRisk, PortReturn, PortWts] = portopt(ExpReturn, ExpCovariance, NumPorts, PortReturn, ConSet, varargin)

输入参数中的PortReturn为可选项,指给定有效前沿上输出点回报。ConSet组合约束一般通过portcons函数进行设置。

现在配置浦发银行、皖通高速、老白干酒、国药股份四只股票,假设浦发银行最大配置50%,皖通高速最大配置60%,老白干酒最大配置40&,国药股份最大配置70%,浦发银行/皖通高速为资产集合A,老白干酒和国药股份为资产集合B,集合A的配置不能超过B的1.5倍,如何配置?

>>NumAssets = 4;
     >>PVal = 1; % Scale portfolio value to 1.
     >>AssetMin = 0;
     >>AssetMax = [0.5 0.6 0.4 0.7];
     >>GroupA = [1 1 0 0];
     >>GroupB = [0 0 1 1];
     >>AtoBmax = 1.5 % Value of assets in Group A at most 1.5 times value in group B.

>>ConSet = portcons('PortValue', PVal, NumAssets,'AssetLims',...
             AssetMin, AssetMax, NumAssets, 'GroupComparison',GroupA, NaN,...
             AtoBmax, GroupB)

>>Numports=10

>>[PortRisk,PortReturn,PortWts]=portopt(ExpReturn,ExpCovariance,Numports,[],ConSet)

PortRisk =

0.0702
    0.0713
    0.0729
    0.0752
    0.0781
    0.0814
    0.0852
    0.0894
    0.0940
    0.1037
   PortReturn =

0.0068
    0.0085
    0.0102
    0.0118
    0.0135
    0.0152
    0.0168
    0.0185
    0.0202
    0.0218
   PortWts =

0.3404    0.2133         0    0.4463
    0.3281    0.2169    0.0458    0.4092
    0.3119    0.2205    0.0919    0.3756
    0.2958    0.2241    0.1380    0.3420
    0.2796    0.2278    0.1841    0.3085
    0.2635    0.2314    0.2302    0.2749
    0.2473    0.2350    0.2764    0.2413
    0.2311    0.2386    0.3225    0.2078
    0.2150    0.2423    0.3686    0.1742
    0.5000    0.1000    0.4000    0.0000

>> portopt(ExpReturn,ExpCovariance,Numports,[],ConSet)

金融数量分析2:Markowitz均值方差模型
可以看到约束使得前沿不再平滑。


展开阅读全文

没有更多推荐了,返回首页