R中的相切投资组合

机器算法验证 r 金融 极值
2022-04-02 21:13:04

我正在尝试在 R 中求解一个有效的投资组合。如何将我的约束转换为 2 个风险资产组合的切点以及给定的无风险利率到 R solve.QP 函数?所以基本上我有以下等式:

w = weight of the first risky asset
R1 = mean return of the first risky asset
R2 = mean return of the second risky asset
sd1 = sdev of first risky asset
sd2 = sdev of second risky asset
corr = correlation between two risky assets
rf = risk free rate
Return of portfolio, R = R2*(1-w)+R1*w
Standard Dev of portfolio, SD = sqrt((sd1*w)^2+(sd2*(1-w))^2+2*w*(1-w)*corr*sd1*sd2)

Now I need to maximize R-rf while minimizing SD (that is maximize my sharpe). 
Let sigma be covariance matrix. So my function to minimize is W^T*sigma*W where W is
the weights vector. Now simulataneously I need to maximize the excess return (R-rf)
and W^T*1=1. I don't know how to express that in the constraints function.

我很困惑如何按照http://pbil.univ-lyon1.fr/library/quadprog/html/solve.QP.html的预期表达这些约束如果您还可以指出最终公式的求解推导,那将很有帮助,因为我无法得出最终公式。

1个回答

我还没有查看您的代码,但这里有两个指针: