Lesson 6 of 15
Sharpe Ratio Maximization (Tangency Portfolio)
Tangency Portfolio
The tangency portfolio is the risky portfolio that maximizes the Sharpe ratio:
It is the point on the efficient frontier where a line from the risk-free rate is tangent to the frontier.
Analytical Solution for Two Assets
To find the tangency weights, we solve the system of equations z = Σ⁻¹(μ − r_f · 1) and normalize:
For two assets with covariance matrix Σ = [[σ₁², ρσ₁σ₂], [ρσ₁σ₂, σ₂²]]:
where eᵢ = μᵢ − r_f and det(Σ) = σ₁²σ₂² − (ρσ₁σ₂)².
Your Task
Implement tangency_weights_2(mu1, mu2, s1, s2, corr, rf) that returns a tuple (w1, w2) of the tangency portfolio weights, each rounded to 4 decimal places.
Python runtime loading...
Loading...
Click "Run" to execute your code.