CommencerCommencer gratuitement

Practice with PyPortfolioOpt: returns

Modern Portfolio Theory is the cornerstone of portfolio risk management, because the efficient frontier is a standard method of assessing both investor risk appetite and market risk-return tradeoffs. In this exercise you'll develop powerful tools to explore a portfolio's efficient frontier, using the PyPortfolioOpt pypfopt Python library.

To compute the efficient frontier, both expected returns and the covariance matrix of the portfolio are required.

After some practice loading the investment bank price data, you'll use pypfopt.expected_returns's mean_historical_return method to compute and visualize the annualized average returns of each bank from daily asset prices. The following exercise will then cover the covariance matrix.

Cet exercice fait partie du cours

Quantitative Risk Management in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Load the investment portfolio price data into the price variable.
prices = pd.____("portfolio.csv")

# Convert the 'Date' column to a datetime index
prices['Date'] = pd.to_datetime(____['Date'], format='%d/%m/%Y')
prices.____(['Date'], inplace = True)
Modifier et exécuter le code