Portfolio Optimization: Relationship between Risk vs. Reward
The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.
LinkedIn | GitHub | Email | Data | Web App
Introduction
The main motivation behind this web scraping project is based on Modern Portfolio Theory (MPT), a quantitative framework applied to investment portfolios that optimizes the relationship between risk vs. reward. This financial theory was founded by Harry Markowitz in the 1950s, and at the time, mathematics were severely underused in the economic and financial world, and Markowitz's approach replaced the world's reliance of judgement with statistical models for several decades.
Background (MPT)
The underlying assumption underlying Markowitz's portfolio theory is normal distribution of stock returns, and only three variables are analyzed for relevant decision making: i.) mean returns ; ii.) variance of the returns (volatility) ; iii.) covariance between each security.
Modern Portfolio Theory remains a pillar of finance, despite the emergence of artificial intelligence in today's investment landscape and the ability to deploy complex portfolio modeling that goes outside the scope of statistical normality. Large financial institutions (pension funds, hedge funds, high-frequency trading firms) with abundant capital deploy complex strategies to optimize their holdings, and most overlook the foundations of Markowitz's framework.
The Project Data
The data was scraped using BeautifulSoup from the websites Yahoo Finance and Quandl in demonstrate i.) portfolio optimization ; ii.) A visual roadmap of macroeconomic relationships and asset classes. Historical 10-year daily closing prices for 10 stocks were used as the sample data for the portfolio, and 3-year daily closing prices of economic data were used for the visual roadmap.
An optimal portfolio is defined as the portfolio with either minimum volatility (risk) for a given target return level, or maximum return for a given risk level. Of paramount interest to investors is the risk-return profiles that are possible for a given set of securities and their statistical characteristics.
Portfolio Optimization
I.) Monte Carlo Simulation
- Simulation generates thousands of vectors with random portfolio weights.
- For every simulated allocation, we record the resulting portfolio variance and mean return.
- Optimization Constraints:
- All position weights add to 100%
- Short Sale is not allowed

II.) Maximize Return-Volatility / Minimize Portfolio Variance
- Two optimization methods were utilized to generate optimal portfolios :
- #1 - Maximize Risk-Reward ratio (Sharpe)
- #2 - Minimize Portfolio Variance
- Mean-Variance Optimization is performed with a minimization function from SciPy module, and ptimal portfolio under both methods.
III.) Efficient Frontier
- The efficient frontier is a derivation of all optimal portfolios (minimum volatility for target return or maximum return for a given level of volatility) - and is similar to the previous optimization
- The only difference is that the efficient frontier iterates over multiple starting conditions. The approach we take is that we fix a target return level and derive for each such level those portfolio weights that lead to the minimum volatility value.
- For the optimization, this leads to two conditions:
1.) target return level (trets)
2.) sum of portfolio weights.

To illustrate, the plotted dots represent all portfolio combinations generated from the Monte Carlo simulation. The crosses that form a hyperbola represent the optimal mean-variance portfolios.
The leftmost portfolio and top-right corner generated by optimization are represented by the two larger stars.