Premium Project

Risk and Returns: The Sharpe Ratio

Use pandas to calculate and compare profitability and risk of different investments using the Sharpe Ratio.

  • 11 tasks
  • 3,804 participants
  • 1,500 XP

Project Description

When you assess whether to invest in an asset, you want to look not only at how much money you could make but also at how much risk you are taking. The Sharpe Ratio, developed by Nobel Prize winner William Sharpe some 50 years ago, does precisely this: it compares the return of an investment to that of an alternative and relates the relative return to the risk of the investment, measured by the standard deviation of returns.

In this project, you will apply the Sharpe ratio to real financial data using pandas. Before starting this project you, should have completed the DataCamp course Importing and Managing Financial Data using Python.

Project Tasks

  • 1 Meet Professor William Sharpe
  • 2 A first glance at the data
  • 3 Plot & summarize daily prices for Amazon and Facebook
  • 4 Visualize & summarize daily values for the S&P 500
  • 5 The inputs for the Sharpe Ratio: Starting with Daily Stock Returns
  • 6 Daily S&P 500 returns
  • 7 Calculating Excess Returns for Amazon and Facebook vs. S&P 500
  • 8 The Sharpe Ratio, Step 1: The Average Difference in Daily Returns Stocks vs S&P 500
  • 9 The Sharpe Ratio, Step 2: Standard Deviation of the Return Difference
  • 10 Putting it all together
  • 11 Conclusion
Stefan Jansen
Stefan Jansen

Founder & Lead Data Scientist at Applied Artificial Intelligence

Stefan is Lead Data Scientist at Applied AI where he advises Fortune 500 companies and startups on translating business goals into a data & AI strategy, building data science teams, and developing machine learning solutions. Prior to his current venture, he was a partner and managing director at an international investment firm where he built the predictive analytics and investment research practice. Stefan holds Master degrees from Harvard and Free University Berlin, and a CFA Charter. He is the author for ‘Machine Learning for Algorithmic Trading’ and teaches data science at General Assembly.

See More
  • Python
  • Icon Icon Icon professional info