okama.EfficientFrontierReb.ef_points

property EfficientFrontierReb.ef_points

Generate multi-period Efficient Frontier.

Each point on the Efficient Frontier is a rebalanced portfolio with optimized annual risk for a given CAGR. In case of non-convexity along the risk axis, the second part of the chart is generated, where the maximum risk value is found for each point.

Returns:
DataFrame

Table of weights and risk/return values for the Efficient Frontier. The columns:

  • assets weights

  • CAGR

  • Risk (standard deviation)

All the values are annualized.

Examples

>>> ls = ['SPY.US', 'GLD.US']
>>> curr = 'USD'
>>> y = ok.EfficientFrontierReb(assets=ls,
...                             first_date='2004-12',
...                             last_date='2020-10',
...                             ccy=curr,
...                             rebalancing_period='year',
...                             ticker_names=True,  # use tickers in DataFrame column names (can be set to False to show full assets names instead tickers)
...                             n_points=20,  # number of points in the Efficient Frontier
...                             full_frontier=False,  # draw the frontier to the global CAGR max only
...                             verbose=False)  # verbose mode is False to skip the progress while the EF points are calcualted
>>> df_reb_year = y.ef_points
>>> df_reb_year.head(5)
       Risk      CAGR    GLD.US    SPY.US
0  0.159400  0.087763  0.000000  1.000000
1  0.157205  0.088171  0.014261  0.985739
2  0.155007  0.088580  0.028941  0.971059
3  0.152810  0.088988  0.044079  0.955921
4  0.150615  0.089397  0.059713  0.940287

To compare the Efficient Frontiers of annually rebalanced portfolios with not rebalanced portfolios it’s possible to draw 2 charts: rebalancing_period=’year’ and rebalancing_period=’none’.

>>> import matplotlib.pyplot as plt
>>> y.rebalancing_period = 'none'
>>> df_not_reb = y.ef_points
>>> fig = plt.figure()
>>> # Plot the assets points
>>> y.plot_assets(kind='cagr')
>>> ax = plt.gca()
>>> # Plot the Efficient Frontier for annually rebalanced portfolios
>>> ax.plot(df_reb_year.Risk, df_reb_year.CAGR, label='Annually rebalanced')
>>> # Plot the Efficient Frontier for not rebalanced portfolios
>>> ax.plot(df_not_reb.Risk, df_not_reb.CAGR, label='Not rebalanced')
>>> # Set axis labels and the title
>>> ax.set_title('Multi-period Efficient Frontier: 2 assets')
>>> ax.set_xlabel('Risk (Standard Deviation)')
>>> ax.set_ylabel('Return (CAGR)')
>>> ax.legend()
>>> plt.show()