The efficient frontier and the financial crisis
Previously you examined the covariance matrix of the investment bank portfolio before, during and after the financial crisis. Now you will visualize the changes that took place in the efficient frontier, showing how the crisis created a much higher baseline risk for any given return.
Using the PyPortfolioOpt pypfopt library's Critical Line Algorithm (CLA) object, you will derive and visualize the efficient frontier during the crisis period, and add it to a scatterplot already displaying the efficient frontiers before and after the crisis.
Expected returns returns_during and the efficient covariance matrix ecov_during are available, as is the CLA object from pypfopt. (Remember that DataCamp plots can be expanded to their own window, which can increase readability.)
Diese Übung ist Teil des Kurses
Quantitative Risk Management in Python
Anleitung zur Übung
- Create the critical line algorithm (
CLA) objectefficient_portfolio_during, using expected returns and the efficient covariance of returns. - Print the minimum variance portfolio of 
efficient_portfolio_during. - Calculate the efficient frontier of 
efficient_portfolio_during. - Add the efficient frontier results to the already displayed scatterplots of the efficient frontiers from before and after the crisis.
 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Initialize the Crtical Line Algorithm object
efficient_portfolio_during = CLA(____, ecov_during)
# Find the minimum volatility portfolio weights and display them
print(efficient_portfolio_during.____)
# Compute the efficient frontier
(ret, vol, weights) = efficient_portfolio_during.____
# Add the frontier to the plot showing the 'before' and 'after' frontiers
plt.scatter(vol, ____, s = 4, c = 'g', marker = '.', label = 'During')
plt.legend()
plt.show()