Portfolio Optimization

Posted on Feb 22, 2020




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.
Efficient Frontier

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 minimum volatility portfolio (leftmost portfolio) and maximum Sharpe portfolio (top-right corner) generated by optimization are represented by the two larger stars.

About Author

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp