楼主: ghyang123
8739 8

[经济] matlab中用portvrisk是按照什么方法计算VaR的? [推广有奖]

  • 5关注
  • 16粉丝

已卖:5份资源

教授

20%

还不是VIP/贵宾

-

威望
0
论坛币
88 个
通用积分
2.0003
学术水平
3 点
热心指数
12 点
信用等级
5 点
经验
578 点
帖子
459
精华
0
在线时间
1896 小时
注册时间
2011-11-25
最后登录
2019-4-24

楼主
ghyang123 发表于 2012-12-14 16:33:10 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
计算VaR三种常用方法:历史模拟,参数模型和蒙特卡洛。matlab中的portvrisk函数需要期望收益率,波动率,风险阈值,风险敞口就可以计算VaR,我根据历史数据计算出股票的历史收益率和波动率,来计算VaR,这是根据历史模拟法计算VaR吗?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB atlab matla 什么方法 Port 计算 matlab

沙发
lhs3332003 发表于 2013-7-3 14:32:26
顶一个,同问啊

藤椅
bella501907914 发表于 2013-12-21 10:18:55
貎似懂了,用的是分析方法,不是历史模拟,楼主再看看

板凳
smjsry 发表于 2014-3-13 15:52:30
就是假设正态分布的条件下,求出VaR(零值)
代码如下:
if (nargin < 4)
    PortValue = 1;
end
  
if (nargin < 3 )
   RiskThreshold = 0.05;
end

if (nargin < 2)
   error('You must enter PortReturn and PortRisk');
end

% Make sure all arguments are columns
PortReturn = PortReturn(:);
PortRisk = PortRisk(:);
RiskThreshold = RiskThreshold(:);
PortValue = PortValue(:);

if(any(size(PortReturn) ~= size(PortRisk)))
   error('PortReturn and PortRisk must be of the same length');
end

ArgSize = [];
%确定统一自变量维度
ArgSize = checkSize(ArgSize, PortReturn);
ArgSize = checkSize(ArgSize, PortRisk);
ArgSize = checkSize(ArgSize, PortValue);
ArgSize = checkSize(ArgSize, RiskThreshold );

%x = norminv(p,mu,sigma)
X = norminv(RiskThreshold, PortReturn, PortRisk);
ValueAtRisk  = (-min(X,0) .* PortValue);

报纸
半路学子 发表于 2016-9-1 09:45:42
bella501907914 发表于 2013-12-21 10:18
貎似懂了,用的是分析方法,不是历史模拟,楼主再看看
请问什么是分析方法?

地板
半路学子 发表于 2016-9-1 09:45:47
bella501907914 发表于 2013-12-21 10:18
貎似懂了,用的是分析方法,不是历史模拟,楼主再看看
请问什么是分析方法?

7
半路学子 发表于 2016-9-1 09:46:04
bella501907914 发表于 2013-12-21 10:18
貎似懂了,用的是分析方法,不是历史模拟,楼主再看看
请问什么是分析方法?

8
半路学子 发表于 2016-9-1 09:46:06
bella501907914 发表于 2013-12-21 10:18
貎似懂了,用的是分析方法,不是历史模拟,楼主再看看
请问什么是分析方法?

9
wangxiaoyu8511 发表于 2017-9-4 14:52:00
可以在matlab中输入 edit portvrisk
function ValueAtRisk = portvrisk(PortReturn, PortRisk, RiskThreshold, PortValue)
%PORTVRISK Portfolio Value-At-Risk
%  ValueAtRisk = portvrisk(PortReturn, PortRisk, RiskThreshold, PortValue)
%  returns the potential loss in the value of a portfolio over one
%  period of time, given the loss probability level RiskThreshold.
%
%  Inputs:
%    PortReturn is an NPORTSx1 vector or scalar of the expected return
%    of each portfolio over the period.
%
%    PortRisk is an NPORTSx1 vector or scalar of the standard deviation  
%    of each portfolio over the period.
%            
%    RiskThreshold is an NPORTSx1 vector or scalar specifying the loss
%    probability. The default value is 0.05 (5%).
%
%    PortValue is an NPORTSx1 vector or scalar specifying the total value
%    of asset portfolio. The default value is 1.
%
%  Outputs:
%    ValueAtRisk is an NPORTSx1 vector of the estimated maximum loss in the  
%    portfolio, predicted with a confidence probability of 1 - RiskThreshold.
%
%    With probability 1-RiskThreshold the loss will be ValueAtRisk
%    or less, while with probability RiskThreshold the loss will be
%    ValueAtRisk or more.
%
%  Notes:
%    If PortValue is not given, ValueAtRisk is presented on a per-unit
%    basis. A value of zero indicates no losses.
%   
%    If PortReturn and PortRisk are in dollar units, then PortValue should
%    be 1. If PortReturn and PortRisk are on a percentage basis, then
%    PortValue should be the total value of the portfolio.
%
%
%  See also PORTOPT.
%

%  Copyright 1995-2015 The MathWorks, Inc.

% Check for input errors

if (nargin < 4)
    PortValue = 1;
end
  
if (nargin < 3 )
   RiskThreshold = 0.05;
end

if (nargin < 2)
   error(message('finance:portvrisk:missingInputs'));
end

% Make sure all arguments are columns
PortReturn = PortReturn(:);
PortRisk = PortRisk(:);
RiskThreshold = RiskThreshold(:);
PortValue = PortValue(:);

if(any(size(PortReturn) ~= size(PortRisk)))
   error(message('finance:portvrisk:mismatchReturnRisk'));
end

ArgSize = [];

ArgSize = checkSize(ArgSize, PortReturn);
ArgSize = checkSize(ArgSize, PortRisk);
ArgSize = checkSize(ArgSize, PortValue);
ArgSize = checkSize(ArgSize, RiskThreshold );

%x = norminv(p,mu,sigma)
X = norminv(RiskThreshold, PortReturn, PortRisk);
ValueAtRisk  = (-min(X,0) .* PortValue);


function NewSize = checkSize(OldSize, Arg)
% This function checks consistency between OldSize and the
% size of Arg. If Arg is an array and OldSize is empty, NewSize
% returns the size of Arg.


NewSize = [];
Size = size(Arg);
if ( any( Size ~= [1 1] ) )
  % argument is not a scalar
  if isempty(OldSize)
    % all previous arguments are scalar
    NewSize = Size;
  else
    % check size against previous arguments
    if ( any( Size ~= OldSize ) )
      error(message('finance:portvrisk:mismatchInputs'));
    end
  end  
end

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2025-12-31 19:33