Skip to main content

Introduction to Portfolio Analysis in Python

Learn how to calculate meaningful measures of risk and performance, and how to compile an optimal portfolio for the desired risk and return trade-off.

Start Course for Free
4 Hours15 Videos52 Exercises9,900 Learners4200 XPFinance Fundamentals Track

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

Have you ever had wondered whether an investment fund is actually a good investment? Or compared two investment options and asked what the difference between the two is? What does the risk indicator of these funds even mean? Or do you frequently work with financial data in your daily job and you want to get an edge? In this course, you’re going to get familiar with the exciting world of investing, by learning about portfolios, risk and return, and how to critically analyze them. By working on actual historical stock data, you’ll learn how to calculate meaningful measures of risk, how to break-down performance, and how to calculate an optimal portfolio for the desired risk and return trade-off. After this course, you’ll be able to make data-driven decisions when it comes to investing and have a better understanding of investment portfolios.

  1. 1

    Introduction to Portfolio Analysis


    In the first chapter, you’ll learn how a portfolio is build up out of individual assets and corresponding weights. The chapter also covers how to calculate the main characteristics of a portfolio: returns and risk.

    Play Chapter Now
    Welcome to Portfolio Analysis!
    50 xp
    Why invest in portfolios
    50 xp
    The effect of diversification
    100 xp
    Portfolio returns
    50 xp
    Portfolio losses and gaining it back
    50 xp
    Calculate mean returns
    100 xp
    Portfolio cumulative returns
    100 xp
    Measuring risk of a portfolio
    50 xp
    Portfolio variance
    100 xp
    Standard deviation versus variance
    100 xp
  2. 2

    Risk and Return

    Chapter 2 goes deeper into how to measure returns and risk accurately. The two most important measures of return, annualized returns, and risk-adjusted returns, are covered in the first part of the chapter. In the second part, you’ll learn how to look at risk from different perspectives. This part focuses on skewness and kurtosis of a distribution, as well as downside risk.

    Play Chapter Now
  3. 3

    Performance Attribution

    In chapter 3, you’ll learn about investment factors and how they play a role in driving risk and return. You’ll learn about the Fama French factor model, and use that to break down portfolio returns into explainable, common factors. This chapter also covers how to use Pyfolio, a public portfolio analysis tool.

    Play Chapter Now
  4. 4

    Portfolio Optimization

    In this last chapter, you learn how to create optimal portfolio weights, using Markowitz’ portfolio optimization framework. You’ll learn how to find the optimal weights for the desired level of risk or return. Lastly, you’ll learn alternative ways to calculate expected risk and return, using the most recent data only.

    Play Chapter Now

In the following tracks

Finance Fundamentals


ruannevdwaltRuanne Van Der Walthillary-green-lermanHillary Green-Lerman
Charlotte Werger Headshot

Charlotte Werger

Director of Advanced Analytics at Nike

Dr. Charlotte Werger currently works at Nike as a Director of Advanced Analytics. Charlotte is a data scientist with a background in econometrics and finance. She loves applying Machine Learning to a broad variety of problems, ranging from image recognition to fraud detection, to customer recommender systems. Charlotte has previously worked in finance as Head of Data Science at Van Lanschot Kempen, and as a quantitative researcher and portfolio manager for BlackRock and Man AHL. In those roles, she specialized in using data science to predict movements in stock markets. As the former Head of Education at Faculty, she loves teaching data science on- and off-line. Charlotte is also active as a Data Science mentor for the Springboard program. Charlotte holds a P.h.D from the European University Institute.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA