Introduction to Portfolio Analysis in Python

Analyze and optimize investment portfolios with Python

Duration 4h Rating (4.9) Price Included with subscription on DataCamp
Created by Charlotte Werger, Hillary Green-Lerman, Ruanne Van Der Walt
Platform: DataCamp Topic: Investing & Trading Skills: Portfolio Optimization Python Risk Management

Introduction to Portfolio Analysis in Python is a code‑first course that explains how to evaluate, compare, and optimize investment portfolios using historical market data and standard Python libraries.

It teaches practical workflows to compute returns and risk, interpret risk‑adjusted metrics, run factor‑based performance attribution, and implement portfolio optimization (Markowitz efficient frontier) with tools such as Pyfolio and PyPortfolioOpt. Geared toward finance professionals and data‑savvy investors with intermediate Python and time‑series familiarity, the course emphasizes measurable skills like annualized returns, variance and downside risk measures, Sharpe and Sortino ratios, and Fama–French regression for attribution.

At a Glance

Introduction to Portfolio Analysis in Python is a DataCamp course led by Charlotte Werger with additional collaborators that introduces core portfolio concepts and practical Python techniques for investment analysis. It focuses on portfolio construction, measuring risk and return, performance attribution, and optimization using hands-on analysis with historical stock data.

Level Intermediate
Rating 4.9 out of 5
Duration 4+ hours
Languages English
Certificate Certificate of Completion (Statement of Accomplishment)
Access Access for as long as your subscription is active
Course includes
  • Interactive Python exercises and code practice
  • Downloadable datasets
  • Hands-on code examples
  • Certificate of Completion
Price Subscription-based, monthly or annual plans

What This Course Teaches

Learners will gain measurable competencies in constructing, measuring, and optimizing investment portfolios using Python tools. Outcomes focus on calculating returns and risk, attributing performance to investment factors, and implementing portfolio optimization workflows.

Portfolio Returns
Calculate asset and portfolio returns, including annualized and cumulative return measures.
Risk Measurement
Measure portfolio risk using variance, standard deviation, skewness, kurtosis, and downside metrics.
Risk‑Adjusted Metrics
Compute and interpret risk‑adjusted performance metrics such as Sharpe and Sortino ratios.
Performance Attribution
Analyze portfolio returns with factor models like the Fama–French framework and linear regression.
Pyfolio Analysis
Apply Pyfolio to generate performance tear sheets and benchmark comparisons.
Portfolio Optimization
Implement Markowitz optimization to derive maximum‑Sharpe and minimum‑volatility portfolios and map the efficient frontier.
Alternative Estimators
Implement alternative expected return and risk estimators such as exponentially weighted approaches.
Method Comparison
Compare optimization approaches and evaluate trade‑offs between different weighting and estimation methods.

How the Course Is Structured

The course is organized into four sequential chapters that group interactive exercises and short lessons by topic. Overall, learners complete four chapters comprising a total of 52 interactive exercises and the course runs about 4+ hours in total.

Curriculum overview

01 Introduction to Portfolio Analysis

Explains how portfolios are constructed from individual assets and how to compute portfolio returns and basic risk measures.

  • Welcome to Portfolio Analysis!
  • Why invest in portfolios
  • The effect of diversification
  • Portfolio returns
  • Portfolio losses and gaining it back
  • Calculate mean returns
  • Portfolio cumulative returns
  • Measuring risk of a portfolio
  • Portfolio variance
  • Standard deviation versus variance
02 Risk and Return

Covers accurate measurement of returns and risk, plus distributional characteristics and downside-focused metrics.

  • Annualized returns
  • Annualizing portfolio returns
  • Comparing annualized rates of return
  • Risk adjusted returns
  • Interpreting the Sharpe ratio
  • S&P500 Sharpe ratio
  • Portfolio Sharpe ratio
  • Non-normal distribution of returns
  • Skewness of the S&P500
  • Calculating skewness and kurtosis
  • Comparing distributions of stock returns
  • Alternative measures of risk
  • Sortino ratio
  • Maximum draw-down portfolio
03 Performance Attribution

Introduces factor-based attribution and practical tools for breaking down portfolio returns versus benchmarks.

  • Comparing against a benchmark
  • Active return
  • Industry attribution
  • Risk factors
  • Size factor
  • Momentum factor
  • Value factor
  • Factor models
  • Fama French factor correlations
  • Linear regression model
  • Fama French Factor model
  • Portfolio analysis tools
  • Performance tear sheet
  • Industry exposures with Pyfolio
04 Portfolio Optimization

Teaches Markowitz optimization and alternative estimation methods to derive efficient portfolios for different risk–return objectives.

  • Modern portfolio theory
  • Understanding the efficient frontier
  • Calculating expected risk and returns
  • PyPortfolioOpt risk functions
  • Optimal portfolio performance
  • Maximum Sharpe vs. minimum volatility
  • Portfolio optimization: Max Sharpe
  • Minimum volatility optimization
  • Comparing max Sharpe to min vol
  • Alternative portfolio optimization
  • Exponentially weighted returns and risk
  • Comparing approaches
  • Changing the span
  • Recap

Audience & Requirements

This course is intended for finance professionals and quantitatively minded investors who want to apply Python to portfolio construction, evaluation, and optimization.

It is suitable for portfolio analysts, quantitative researchers, data-savvy individual investors, and students seeking hands-on, code-first training in risk, return, attribution, and optimization.

Who It's For
  • Portfolio analysts and investment professionals applying data-driven evaluation.
  • Quantitative analysts and researchers building factor and attribution models.
  • Data‑savvy individual investors who analyze and optimize personal portfolios.
  • Students in finance or data science seeking practical Python portfolio workflows.
What You'll Need
  • Intermediate Python skills and comfort with pandas and time‑series manipulation.
  • Completion of prerequisite courses such as Manipulating Time Series Data in Python or Intermediate Python for Finance (recommended).
  • Basic statistical literacy, including familiarity with variance, regression, and distribution concepts.

Final Verdict

Given its strong learner feedback and wide adoption, this course is a practical, hands‑on choice for finance professionals and quantitatively minded investors who already have intermediate Python skills. The syllabus and exercises target measurable portfolio‑analysis competencies, and the platform certificate plus ongoing access under a subscription make it a sensible upskill for those who will apply these techniques on the job.

It is less appropriate as a first introduction to programming or statistics — learners without the recommended prerequisites should complete foundational Python and time‑series modules before enrolling to get full value from the material.