okama.EfficientFrontier.plot_pair_ef
- EfficientFrontier.plot_pair_ef(tickers='tickers', figsize=None)
Plot Efficient Frontier of every pair of assets.
Efficient Frontier is a set of portfolios which satisfy the condition that no other portfolio exists with a higher expected return but with the same risk (standard deviation of return).
Arithmetic mean (expected return) is used for optimized portfolios.
- Parameters:
- tickers{‘tickers’, ‘names’} or list of str, default ‘tickers’
Annotation type for assets. ‘tickers’ - assets symbols are shown in form of ‘SPY.US’ ‘names’ - assets names are used like - ‘SPDR S&P 500 ETF Trust’ To show custom annotations for each asset pass the list of names.
- figsize: (float, float), optional
Figure size: width, height in inches. If None default matplotlib size is taken: [6.4, 4.8]
- Returns:
- Axes‘matplotlib.axes._subplots.AxesSubplot’
Notes
It should be at least 3 assets.
Examples
>>> import matplotlib.pyplot as plt >>> ls4 = ['SPY.US', 'BND.US', 'GLD.US', 'VNQ.US'] >>> curr = 'USD' >>> last_date = '07-2021' >>> ef = ok.EfficientFrontier(ls4, ccy=curr, last_date=last_date) >>> ef.plot_pair_ef() >>> plt.show()
It can be useful to plot the full Efficent Frontier (EF) with optimized 4 assets portfolios together with the EFs for each pair of assets.
>>> ef4 = ok.EfficientFrontier(assets=ls4, ccy=curr, n_points=100) >>> df4 = ef4.ef_points >>> fig = plt.figure() >>> # Plot Efficient Frontier of every pair of assets. Optimized portfolios will have 2 assets. >>> ef4.plot_pair_ef() # mean return is used for optimized portfolios. >>> ax = plt.gca() >>> # Plot the full Efficient Frontier for 4 asset portfolios. >>> ax.plot(df4['Risk'], df4['Mean return'], color = 'black', linestyle='--') >>> plt.show()