Skip to content

Course Notes

Use this workspace to take notes, store code snippets, or build your own interactive cheatsheet! The datasets used in this course are available in the datasets folder.

pip install PyPortfolioOpt
# Import any packages you want to use here
# Import the EfficientCVaR class
import PyPortfolioOpt
#from pypfopt.EfficientCVaR import EfficientCVaR
# Import data
# Load the data from a CSV file
data = pd.read_csv('./monthly_returns.csv', index_col='Date')
data
# Create the efficient frontier for CVaR minimization
ec = pypfopt.efficient_frontier.EfficientCVaR(None, returns)

# Find the cVaR-minimizing portfolio weights at the default 95% confidence level
optimal_weights = ec.min_cvar()

# Map the values in optimal_weights to the bank names
optimal_weights = { names[i] : optimal_weights[i] for i in optimal_weights}

# Display the optimal weights
print(optimal_weights)

Take Notes

Add notes here about the concepts you've learned and code cells with code you want to keep.

Add your notes here

# Add your code snippets here