Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Automate Portfolio Metrics Calculation | Advanced Analysis and Automation for Investors
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Investors

bookChallenge: Automate Portfolio Metrics Calculation

Tarefa

Swipe to start coding

You are given a DataFrame of daily closing prices for several assets and a list of portfolio weights. Your task is to automate the calculation of three key portfolio metrics:

  • Calculate the expected annual return of the portfolio (assume 252 trading days in a year);
  • Calculate the annualized volatility (standard deviation) of the portfolio;
  • Calculate the Sharpe Ratio of the portfolio (assume the risk-free rate is 0).

Implement the function calculate_portfolio_metrics(prices_df, weights) to return a dictionary with keys 'expected_annual_return', 'annual_volatility', and 'sharpe_ratio', each mapped to the corresponding float value.

Use only the allowed libraries. The function will be tested with different price data and weights.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 3
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Automate Portfolio Metrics Calculation

Deslize para mostrar o menu

Tarefa

Swipe to start coding

You are given a DataFrame of daily closing prices for several assets and a list of portfolio weights. Your task is to automate the calculation of three key portfolio metrics:

  • Calculate the expected annual return of the portfolio (assume 252 trading days in a year);
  • Calculate the annualized volatility (standard deviation) of the portfolio;
  • Calculate the Sharpe Ratio of the portfolio (assume the risk-free rate is 0).

Implement the function calculate_portfolio_metrics(prices_df, weights) to return a dictionary with keys 'expected_annual_return', 'annual_volatility', and 'sharpe_ratio', each mapped to the corresponding float value.

Use only the allowed libraries. The function will be tested with different price data and weights.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 3
single

single

some-alt