okama.EfficientFrontier.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:
rate_of_return{cagr, mean_return}, default cagr

Use CAGR (Compound annual growth rate) or arithmetic mean of return to calculate Sharpe Ratio.

rf_returnfloat, default 0

Risk-free rate of return.

Returns:
dict

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

Examples

>>> three_assets = ['MCFTR.INDX', 'RGBITR.INDX', 'GC.COMM']
>>> ef = ok.EfficientFrontier(assets=three_assets, ccy='USD', last_date='2022-06')
>>> ef.get_tangency_portfolio(rf_return=0.03)  # risk free rate of return is 3%
{'Weights': array([0.30672901, 0.        , 0.69327099]), 'Mean_return': 0.12265215404959617, 'Risk': 0.1882249366394522}

To calculate tangency portfolio parameters for CAGR (geometric mean) set cagr=True:

>>> ef.get_tangency_portfolio(rate_of_return="mean_return", rf_return=0.03)
{'Weights': array([2.95364739e-01, 1.08420217e-17, 7.04635261e-01]), 'Mean_return': 0.10654206521088283, 'Risk': 0.048279725208422115}