okama.EfficientFrontier.optimize_return

EfficientFrontier.optimize_return(option='max')

Find a portfolio with global max or min for the rate of return within given bounds.

The objective function is an arithmetic mean of monthly Rate of return.

Bounds are defined with ‘bounds’ property.

Parameters:
option{‘max’, ‘min’}, default ‘max’

Find objective function global maximun if ‘max’ or global minimum if ‘min’.

Returns:
dict

Weights of assets, risk and return of the portfolio.

Examples

>>> ef = ok.EfficientFrontier(['SPY.US', 'AGG.US', 'GLD.US'])
>>> ef.optimize_return(option='max')
{'Weights': array([1.00000000e+00, 1.94289029e-16, 1.11022302e-16]), 'Mean_return_monthly': 0.009144, 'Risk_monthly': 0.041956276163975015}

The global maximum can be found with constrained optimization using bounds.

>>> ef.bounds = ((0, 1.), (0, 1.), (0.20, 1.))  # The portfolio should have at least 20% of GLD
>>> ef.optimize_return(option='max')
{'Weights': array([8.00000000e-01, 5.48172618e-16, 2.00000000e-01]), 'Mean_return_monthly': 0.008894299999999997, 'Risk_monthly': 0.035570987973869726}