I am trying to solve for an efficient portfolio in R. How do I translate my constraints for a tangency point for 2 risky asset portfolio, and a given risk free rate to R solve.QP function? So basically I have the following equations:
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.
I am confused how to express these constraints as expected by http://pbil.univ-lyon1.fr/library/quadprog/html/solve.QP.html . If you could also point me to a solved derivation of the final formula, that would be helpful as well as I am unable to get to the final formula.