get_tangency_portfolio

EfficientFrontier.get_tangency_portfolio(rf_return=0, rate_of_return='cagr')

Calculate asset weights, risk and return values for tangency portfolio within given bounds.

Tangency portfolio or Maximum Sharpe Ratio (MSR) is the point on the Efficient Frontier where Sharpe Ratio reaches its maximum.

The Sharpe ratio is the average annual return in excess of the risk-free rate per unit of risk (annualized standard deviation).

Bounds are defined with ‘bounds’ property.

Parameters:
rf_returnfloat, default 0

Risk-free rate of return.

rate_of_return{‘cagr’, ‘mean_return’}, default ‘cagr’

Return definition used to calculate Sharpe ratio.

  • ‘cagr’: Compound Annual Growth Rate.

  • ‘mean_return’: Arithmetic mean return (annualized).

Returns:
dict

Weights of assets, risk and return of the tangency portfolio.

Examples

>>> three_assets = ["SPY.US", "AGG.US", "GLD.US"]
>>> ef = ok.EfficientFrontier(assets=three_assets, ccy="USD", last_date="2022-06")
>>> msr = ef.get_tangency_portfolio(rf_return=0.03)  # risk free rate of return is 3%
>>> msr
{'Weights': array([0.47687653, 0.25779952, 0.26532395]),
'Rate_of_return': 0.07759168028010821,
'Risk': 0.0959884843475395}

To calculate tangency portfolio parameters for arithmetic mean set rate_of_return=’mean_return’:

>>> msr_mean = ef.get_tangency_portfolio(rate_of_return="mean_return", rf_return=0.03)
>>> msr_mean
{'Weights': array([0.61143897, 0.00159518, 0.38696585]),
'Rate_of_return': 0.09876868143927053,
'Risk': 0.12609086541280776}