由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - Matlab中如何用expected shortfall做portfolio optimization?
相关主题
数据短如何计算ETL?有什么公式可以算conditional VaR的吗?
Portfolio optimization (转载)那个BL framework有很多人用吗?
question about simulationsimulation problem
问一个sampling from multivariate distribution 的问题投行面试问题请教
大家看看这个PM的职位是不是骗人的?[合集] a question about marginal distribution on copula modeling i
[合集] 有没有free的quadratic optimization package?Brain teaser question
[合集] 有精通copula的人指点一下么?苦闷, portfolio optimization 问题求助
请问在fat tail下如何风险管理啊?[合集] 苦闷, portfolio optimization 问题求助
相关话题的讨论汇总
话题: shortfall话题: cvar话题: parametric话题: portfolio
进入Quant版参与讨论
1 (共1页)
k**k
发帖数: 61
1
大家好,请教个问题。
已有一组simulated returns of constituent stocks (20*10000,即20个stock,共
10000组correlated returns)。想在某个portfolio target return的constraint下通
过变化stock weights来minimize portfolio expected shortfall,不知道该如何设
objective function。主要是如何将每个scenario下portfolio expected shortfall的
计算直接体现在objective function中不知道如何处理。optimization打算直接用
fmincon函数做。大家有什么建议没有?
A*****s
发帖数: 13748
2
设计算法写code啊。。。跟matlab有什么关系。。。

【在 k**k 的大作中提到】
: 大家好,请教个问题。
: 已有一组simulated returns of constituent stocks (20*10000,即20个stock,共
: 10000组correlated returns)。想在某个portfolio target return的constraint下通
: 过变化stock weights来minimize portfolio expected shortfall,不知道该如何设
: objective function。主要是如何将每个scenario下portfolio expected shortfall的
: 计算直接体现在objective function中不知道如何处理。optimization打算直接用
: fmincon函数做。大家有什么建议没有?

k**k
发帖数: 61
3
matlab感觉更实用也更方便些. 这个问题也看到过一些解法,比如设objective
function为:
a + max(- portfolioReturn - a, 0)/(0.05 * number of sample)
其中a是一个适当的初始值, 对于每一个weight scenario, portfolioReturn就是对应
的10000个simulated portfolio returns (从之前的10000个correlated stock return
里算出). 0.05代表的是5%的confidence interval下的expected shortfall
由此直接用fmincon就能找出最后的优化weight。对此不怎么理解,但试验了一下这个
确实是给出了正确解,不知道有没有懂行的能comment一下?或者建议一个更合适的版
问问?

【在 A*****s 的大作中提到】
: 设计算法写code啊。。。跟matlab有什么关系。。。
A*****s
发帖数: 13748
4
CVaR是一个无法解析表示的风险度量,你写的这个逼近方法我看不懂。。。
最简单的办法是假设portfolio回报率的分布,然后解析表示,但是这样就没意思了
成熟一点的办法是对portfolio里所有asset做correlated retun simulation来逼近真
实分布
这要求你有大量的数据基础,不是一般个人可以做得到的
我看股版天天有人号称自己在CVaR,很好奇
CVaR measure对于大投行都还是个难题,不知道这些个人是怎么实现的
不管怎么样,你的这个obj根本不连续(至少一阶不连续),有个max存在
不知道什么神奇的optimization算法能算这个,很期待解答,别告诉我用excel solver

return

【在 k**k 的大作中提到】
: matlab感觉更实用也更方便些. 这个问题也看到过一些解法,比如设objective
: function为:
: a + max(- portfolioReturn - a, 0)/(0.05 * number of sample)
: 其中a是一个适当的初始值, 对于每一个weight scenario, portfolioReturn就是对应
: 的10000个simulated portfolio returns (从之前的10000个correlated stock return
: 里算出). 0.05代表的是5%的confidence interval下的expected shortfall
: 由此直接用fmincon就能找出最后的优化weight。对此不怎么理解,但试验了一下这个
: 确实是给出了正确解,不知道有没有懂行的能comment一下?或者建议一个更合适的版
: 问问?

k**k
发帖数: 61
5
我之前提到已经有correlated return for individual stocks,这是用historical
price,然后假设individual stock return follows:
r(t) = u + sigma(t)*z(t) (z(t) ~ i.i.d)
利用GJR(1,1)model( 用于forcast每个stock的sigma(t) ),generalized pareto
distribution( 用于fit每个stock的empirical CDF of z(t) ),外加t-copula(用于
simulate joint distribution of不同stock之间的z(t) )最后得到。剩下就是如何利
用这组simulated return来优化portfolio weight.之前的步骤都能用matlab实现,就
是最后优化不清楚如何在matlab中实现.
不知道哪位能赐教?

solver

【在 A*****s 的大作中提到】
: CVaR是一个无法解析表示的风险度量,你写的这个逼近方法我看不懂。。。
: 最简单的办法是假设portfolio回报率的分布,然后解析表示,但是这样就没意思了
: 成熟一点的办法是对portfolio里所有asset做correlated retun simulation来逼近真
: 实分布
: 这要求你有大量的数据基础,不是一般个人可以做得到的
: 我看股版天天有人号称自己在CVaR,很好奇
: CVaR measure对于大投行都还是个难题,不知道这些个人是怎么实现的
: 不管怎么样,你的这个obj根本不连续(至少一阶不连续),有个max存在
: 不知道什么神奇的optimization算法能算这个,很期待解答,别告诉我用excel solver
:

A*****s
发帖数: 13748
6
比如你有1000个scenario,关心99%的CVaR
每个secnario的loss都是weight的函数
你给每个scenario都配一个0-1变量,要求一千个另一变量的和为10
given一个weight,max这个sum{0-1变量*scenario loss},这样你就有了每个weight下
的CVaR
然后你再去改变weight来minimize CVaR
等于最后是个min max问题
不过解起来什么效果,我不知
objective怪怪的

【在 k**k 的大作中提到】
: 我之前提到已经有correlated return for individual stocks,这是用historical
: price,然后假设individual stock return follows:
: r(t) = u + sigma(t)*z(t) (z(t) ~ i.i.d)
: 利用GJR(1,1)model( 用于forcast每个stock的sigma(t) ),generalized pareto
: distribution( 用于fit每个stock的empirical CDF of z(t) ),外加t-copula(用于
: simulate joint distribution of不同stock之间的z(t) )最后得到。剩下就是如何利
: 用这组simulated return来优化portfolio weight.之前的步骤都能用matlab实现,就
: 是最后优化不清楚如何在matlab中实现.
: 不知道哪位能赐教?
:

k**k
发帖数: 61
7
从概念上讲,这个优化问题没什么难的.但我想用matlab中现有的功能去实现,比如说
最常用的constrained optimization中的fmincon函数.难点就是如何设objective
function.要能做到在每一个weight scenario下能自动找出对应的expected shortfall
.之前我提的objective function就是一个workable的例子,只是我没看懂.谁能有具
体的idea?

【在 A*****s 的大作中提到】
: 比如你有1000个scenario,关心99%的CVaR
: 每个secnario的loss都是weight的函数
: 你给每个scenario都配一个0-1变量,要求一千个另一变量的和为10
: given一个weight,max这个sum{0-1变量*scenario loss},这样你就有了每个weight下
: 的CVaR
: 然后你再去改变weight来minimize CVaR
: 等于最后是个min max问题
: 不过解起来什么效果,我不知
: objective怪怪的

m***s
发帖数: 605
8
non-parametric CVaR 是个 linear programming, 你这种没什么特别好的办法吧, 就
把tail平均吧。

shortfall

【在 k**k 的大作中提到】
: 从概念上讲,这个优化问题没什么难的.但我想用matlab中现有的功能去实现,比如说
: 最常用的constrained optimization中的fmincon函数.难点就是如何设objective
: function.要能做到在每一个weight scenario下能自动找出对应的expected shortfall
: .之前我提的objective function就是一个workable的例子,只是我没看懂.谁能有具
: 体的idea?

m***s
发帖数: 605
9
你不能sort之后去尾部平均吗? 我觉得你现在的这个方法下的cvar恐怕不是convex的,
需要很多起始点。 另外cvar不是万能的, 你这种parametric的方法解出来的不比non
-parametric解出来的好。 因为你的non-normal distribution在fit的过程中paramete
r的uncertainty很大, 加上cvar是个尾部量, 本身的variance很大。

shortfall

【在 k**k 的大作中提到】
: 从概念上讲,这个优化问题没什么难的.但我想用matlab中现有的功能去实现,比如说
: 最常用的constrained optimization中的fmincon函数.难点就是如何设objective
: function.要能做到在每一个weight scenario下能自动找出对应的expected shortfall
: .之前我提的objective function就是一个workable的例子,只是我没看懂.谁能有具
: 体的idea?

A*****s
发帖数: 13748
10
sort然后取尾部平均就是我刚才说的用10个1和9990个0的算法,我那个更快一点
他不听。。。

的,
non
paramete

【在 m***s 的大作中提到】
: 你不能sort之后去尾部平均吗? 我觉得你现在的这个方法下的cvar恐怕不是convex的,
: 需要很多起始点。 另外cvar不是万能的, 你这种parametric的方法解出来的不比non
: -parametric解出来的好。 因为你的non-normal distribution在fit的过程中paramete
: r的uncertainty很大, 加上cvar是个尾部量, 本身的variance很大。
:
: shortfall

相关主题
[合集] 有没有free的quadratic optimization package?有什么公式可以算conditional VaR的吗?
[合集] 有精通copula的人指点一下么?那个BL framework有很多人用吗?
请问在fat tail下如何风险管理啊?simulation problem
进入Quant版参与讨论
k**k
发帖数: 61
11
没错,之前想用的就是sort之后尾部平均,但没想清楚怎么写这个目标函数。我对
matlab优化不是很熟,印象中objective function就一个表达式,不能够展开写成一个
子函数,包含sort与average的功能,还是我错了?

的,
non
paramete

【在 m***s 的大作中提到】
: 你不能sort之后去尾部平均吗? 我觉得你现在的这个方法下的cvar恐怕不是convex的,
: 需要很多起始点。 另外cvar不是万能的, 你这种parametric的方法解出来的不比non
: -parametric解出来的好。 因为你的non-normal distribution在fit的过程中paramete
: r的uncertainty很大, 加上cvar是个尾部量, 本身的variance很大。
:
: shortfall

s***e
发帖数: 267
12
It seems to me that if your objective is
0.05*a + \sum_i max(- portfolioReturn(i) - a, 0)/n
where "a" is the 95% Var for your time horizon (or converges to that
quantity), then it makes sense. Note that this is pretty close to what you
have earlier. Not sure which method you use to compute "a" using weights.

return

【在 k**k 的大作中提到】
: matlab感觉更实用也更方便些. 这个问题也看到过一些解法,比如设objective
: function为:
: a + max(- portfolioReturn - a, 0)/(0.05 * number of sample)
: 其中a是一个适当的初始值, 对于每一个weight scenario, portfolioReturn就是对应
: 的10000个simulated portfolio returns (从之前的10000个correlated stock return
: 里算出). 0.05代表的是5%的confidence interval下的expected shortfall
: 由此直接用fmincon就能找出最后的优化weight。对此不怎么理解,但试验了一下这个
: 确实是给出了正确解,不知道有没有懂行的能comment一下?或者建议一个更合适的版
: 问问?

k**k
发帖数: 61
13
You are exactly right. I accidentally dropped the summation term. Could you
please explain why this yields the correct answer? Note that "a", the 95%
VaR varies under each weight scenario. The algorithm I saw starts with a
relatively arbitrage value of "a". Under that objective function, it returns
the same optimal weight each time.
Thoughts?

【在 s***e 的大作中提到】
: It seems to me that if your objective is
: 0.05*a + \sum_i max(- portfolioReturn(i) - a, 0)/n
: where "a" is the 95% Var for your time horizon (or converges to that
: quantity), then it makes sense. Note that this is pretty close to what you
: have earlier. Not sure which method you use to compute "a" using weights.
:
: return

s***e
发帖数: 267
14
Interesting...
If you assume a is the correct 95% Var, then you get the right weights which
minimizes the expected shortfall. Now if you have the right weights, and
just try to vary "a", you should get the right a, i.e. the 95% var.
So it turns out that a* and w* (the optimal var and optimal weights) are
solution of the optimization problem.

you
returns

【在 k**k 的大作中提到】
: You are exactly right. I accidentally dropped the summation term. Could you
: please explain why this yields the correct answer? Note that "a", the 95%
: VaR varies under each weight scenario. The algorithm I saw starts with a
: relatively arbitrage value of "a". Under that objective function, it returns
: the same optimal weight each time.
: Thoughts?

y*w
发帖数: 238
15
第一句话是这个问题的正解



【在 m***s 的大作中提到】
: non-parametric CVaR 是个 linear programming, 你这种没什么特别好的办法吧, 就
: 把tail平均吧。
:
: shortfall

k**k
发帖数: 61
16
How should I interpret this? By setting the objective function that way I
could achieve optimization of both parameters simultaneously? Still kinda
hard to grasp though. Any literature that talks about such idea?

which

【在 s***e 的大作中提到】
: Interesting...
: If you assume a is the correct 95% Var, then you get the right weights which
: minimizes the expected shortfall. Now if you have the right weights, and
: just try to vary "a", you should get the right a, i.e. the 95% var.
: So it turns out that a* and w* (the optimal var and optimal weights) are
: solution of the optimization problem.
:
: you
: returns

m***s
发帖数: 605
17
see
Rockafellar, R.T. and Uryasev, S., 2000, Optimization of conditional value-a
t-risk. J. Risk, 2, 21-41.
Rockafellar, R.T. and Uryasev, S., 2002, Conditional value-at-risk for gener
al loss distributions. J. Bank. Finance, 26(7) 1443-1471.
But I thought you were doing parametric CVaR. You have marginal and t-copula
. Everytime, you change the weights, your parametric CVaR should be differen
t from the non-parametric CVaR, no?

【在 k**k 的大作中提到】
: How should I interpret this? By setting the objective function that way I
: could achieve optimization of both parameters simultaneously? Still kinda
: hard to grasp though. Any literature that talks about such idea?
:
: which

k**k
发帖数: 61
18
Just read a few paragraphs in the first article. Think this is the one I'm
looking for. Thanks a lot!
As to parametric vs. non-parametric, not sure your exact definitions. What I
did is to parameterize the marginal distribution of standard innovation z(t
) from their empirical CDF. Together with a t-copula, I can directly sample
from their empirical joint distribution. That way I can obtain a set of
simulated portfolio returns taking into account the non-normal joint
distribution of returns. Thi

【在 m***s 的大作中提到】
: see
: Rockafellar, R.T. and Uryasev, S., 2000, Optimization of conditional value-a
: t-risk. J. Risk, 2, 21-41.
: Rockafellar, R.T. and Uryasev, S., 2002, Conditional value-at-risk for gener
: al loss distributions. J. Bank. Finance, 26(7) 1443-1471.
: But I thought you were doing parametric CVaR. You have marginal and t-copula
: . Everytime, you change the weights, your parametric CVaR should be differen
: t from the non-parametric CVaR, no?

m***s
发帖数: 605
19
non-parametric means you dont have a parametrized distribution, except the e
mpirical distribution. You dont fit anything, just use the historical data.
parametric form, e.g. you fit the data with normal, and var=mu-2*sigma or cv
ar=mu-lambda*sigma. If it is normal distribution, this way the estimate is m
uch more efficient (smaller variance). However, you can not be sure this is
a normal distribution, you have two sources of errors: misspecification in m
odel and parameter uncertainty. You fit

【在 k**k 的大作中提到】
: Just read a few paragraphs in the first article. Think this is the one I'm
: looking for. Thanks a lot!
: As to parametric vs. non-parametric, not sure your exact definitions. What I
: did is to parameterize the marginal distribution of standard innovation z(t
: ) from their empirical CDF. Together with a t-copula, I can directly sample
: from their empirical joint distribution. That way I can obtain a set of
: simulated portfolio returns taking into account the non-normal joint
: distribution of returns. Thi

r*g
发帖数: 3159
20
似乎笔误,max前少一个求和,然后就是 - expected shortfall 定义。

return

【在 k**k 的大作中提到】
: matlab感觉更实用也更方便些. 这个问题也看到过一些解法,比如设objective
: function为:
: a + max(- portfolioReturn - a, 0)/(0.05 * number of sample)
: 其中a是一个适当的初始值, 对于每一个weight scenario, portfolioReturn就是对应
: 的10000个simulated portfolio returns (从之前的10000个correlated stock return
: 里算出). 0.05代表的是5%的confidence interval下的expected shortfall
: 由此直接用fmincon就能找出最后的优化weight。对此不怎么理解,但试验了一下这个
: 确实是给出了正确解,不知道有没有懂行的能comment一下?或者建议一个更合适的版
: 问问?

相关主题
投行面试问题请教苦闷, portfolio optimization 问题求助
[合集] a question about marginal distribution on copula modeling i[合集] 苦闷, portfolio optimization 问题求助
Brain teaser questionClayton Copula
进入Quant版参与讨论
k**k
发帖数: 61
21
Agreed. On the other hand, I wonder without a certain way to parameterize
the distribution, how can one conveniently sample new random returns with
proper correlation embedded? Curious to the available strategies here...

e
.
cv
m
is
m
generate
dis
w
po

【在 m***s 的大作中提到】
: non-parametric means you dont have a parametrized distribution, except the e
: mpirical distribution. You dont fit anything, just use the historical data.
: parametric form, e.g. you fit the data with normal, and var=mu-2*sigma or cv
: ar=mu-lambda*sigma. If it is normal distribution, this way the estimate is m
: uch more efficient (smaller variance). However, you can not be sure this is
: a normal distribution, you have two sources of errors: misspecification in m
: odel and parameter uncertainty. You fit

k**k
发帖数: 61
22
你也看出来了。不知道对这个目标函数有什么比较直观的解释没有?

【在 r*g 的大作中提到】
: 似乎笔误,max前少一个求和,然后就是 - expected shortfall 定义。
:
: return

m***s
发帖数: 605
23
people do guess work probably, with factor models or just do the way you are
trying. I guess it's popular, but not sure how effective.

【在 k**k 的大作中提到】
: Agreed. On the other hand, I wonder without a certain way to parameterize
: the distribution, how can one conveniently sample new random returns with
: proper correlation embedded? Curious to the available strategies here...
:
: e
: .
: cv
: m
: is
: m

1 (共1页)
进入Quant版参与讨论
相关主题
[合集] 苦闷, portfolio optimization 问题求助大家看看这个PM的职位是不是骗人的?
Clayton Copula[合集] 有没有free的quadratic optimization package?
equity risk management.这方面的的面试问题有一些什么?[合集] 有精通copula的人指点一下么?
Copula software/code请问在fat tail下如何风险管理啊?
数据短如何计算ETL?有什么公式可以算conditional VaR的吗?
Portfolio optimization (转载)那个BL framework有很多人用吗?
question about simulationsimulation problem
问一个sampling from multivariate distribution 的问题投行面试问题请教
相关话题的讨论汇总
话题: shortfall话题: cvar话题: parametric话题: portfolio