
Explore portfolio theory with matrix algebra in Python, learn how matrix operations are implemented, and how to find the optimal portfolio weights for educational and entertainment purposes.
Explore how stock returns are calculated, compared, and accumulated using simple and log returns, including time-additive log returns, and implement these methods in Python with pandas and NumPy.
Pulls price data for assets (S&P 500 and gold), computes daily log returns with numpy, analyzes their correlation, and compares cumulative returns from 2010 onward.
Compare mean returns and volatility of gold versus the S&P 500 using Python tools. Gold shows a lower mean return but also lower standard deviation, indicating lower volatility.
Compute the portfolio's expected return by the dot product of a weights vector and asset returns, using numpy to create flexible equal weight vectors for any number of assets.
Learn how to compute portfolio risk by exact variance using a covariance matrix and weights, from simple two-asset cases to scalable matrix methods.
Compare the portfolio's risk and return with its single components to illustrate diversification. Show 50/50 gold and S&P 500 portfolio has risk lower than either asset and return between them.
Learn to compute the Sharpe ratio as risk-adjusted return, compare asset Sharpe ratios, and note a better return from an equally weighted S&P 500 and gold portfolio.
Add assets like Tesla to a portfolio, analyze correlations with gold and the S&P 500, and evaluate returns, risk, and Sharpe ratios to inform weight optimization for maximum risk-adjusted return.
Explore portfolio construction and optimization with Python by applying matrix algebra to optimize weights, using NumPy, Pandas, and SciPy minimize on assets like the S&P 500 and gold.
Learn to minimize the negative Sharpe ratio by computing portfolio risk from a covariance matrix and expected return from mean returns, using a weights vector for optimization.
Learn to optimize a portfolio by applying an equality constraint that forces weights to sum to one, enabling minimization of the Sharpe ratio via a solver.
Apply a Python optimization to minimize risk and maximize the Sharpe ratio, yielding optimal weights (33% and 67%) that overweight the S&P 500 and beat equal weights.
Learn to code a portfolio optimization from scratch by iterating over weight arrays, computing the Sharpe ratio, and identifying the weight split that minimizes the function.
Explore how train-test splits affect portfolio optimization, comparing train vs test performance and Sharpe ratios, using 70% train data to optimize and unseen test data to evaluate.
Add assets and apply short selling constraints by enforcing 0–1 bounds, compare equal versus optimized weights using train-test splits, and assess portfolio performance and Sharpe ratios.
What is this course about?
In this 1 hour crash course I am going over the whole process of setting up a Portfolio Optimization with Python step by step. I am doing it hands on showing all calculation steps besides to get the best understanding of all steps involved possible.
You will learn:
- How stock returns are calculated and why log returns are used
- How to pull stock prices and calculate relevant metrics
- How to calculate Portfolio Return and Variance (/Portfolio risk)
- How to compare a Portfolio of weighted assets with single assets
- How to build a whole Optimization by minimizing the Sharpe Ratio (risk adjusted return)
- How to build a Optimization from scratch (besides using a solver)
- How to split your dataset so that you optimize on seen data and test on unseen data
Why should I be your constructor?
I got years of experience coding in Python both teaching but also several years of actually working in the field.
Besides currently working in the field I wrote my Master Thesis on a quantitative Finance topic and got a YouTube channel teaching Algorithmic Trading and Data Science hands-on tutorials with over 75.000 subscribers.
Why this course?
This course is giving you a non-time wasting hands-on approach on Portfolio Optimization with Python.
Any questions coming up?
If you got any questions please feel free to reach out! I am happy to hear from you.