get_most_diversified_portfolio
- EfficientFrontier.get_most_diversified_portfolio(target_return=None)
Calculate assets weights and portfolio metrics for the most diversified portfolio within bounds.
The most diversified portfolio is defined as the portfolio with the maximum Diversification Ratio.
- Parameters:
- target_returnfloat, default None
Target Compound Annual Growth Rate (CAGR) for the portfolio. If provided, the optimizer searches for a portfolio with the target CAGR and the maximum Diversification Ratio. If None, the global most diversified portfolio is returned.
- Returns:
- dict[str, float]
Mapping with asset weights (keys are tickers or asset names depending on ticker_names) and portfolio metrics: ‘CAGR’, ‘Risk’, and ‘Diversification ratio’.
Examples
>>> ls4 = ["SPY.US", "AGG.US", "VNQ.US", "GLD.US"] >>> x = ok.EfficientFrontier(assets=ls4, ccy="USD", last_date="2021-12") >>> x.get_most_diversified_portfolio() # get a global most diversified portfolio {'SPY.US': 0.19612726258395477, 'AGG.US': 0.649730553241489, 'VNQ.US': 0.020096313783052246, 'GLD.US': 0.13404587039150392, 'CAGR': 0.062355715886719176, 'Risk': 0.05510135025563423, 'Diversification ratio': 1.5665720501693001}
It is possible to get the most diversified portfolio for a given target CAGR.
>>> x.get_most_diversified_portfolio(target_return=0.10) {'SPY.US': 0.3389762570274293, 'AGG.US': 0.12915657041748244, 'VNQ.US': 0.15083042115027034, 'GLD.US': 0.3810367514048179, 'CAGR': 0.09370688842211439, 'Risk': 0.11725067815643951, 'Diversification ratio': 1.4419864802150442}