📉
OMSCS Notes
  • OMSCS Lecture Notes
  • information-security
    • Firewalls
    • Database Security
    • Operating System Security
    • Access Control
    • Cyber Security
    • Law, Ethics, and Privacy
    • Security Protocols
    • Introduction to Cryptography
    • Software Security
    • Midterm 2 Study Guide
    • Mandatory Access Control
    • Modern Malware
    • Udacity Quizzes
    • Midterm 1 Study Guide
    • IPSec and TLS
    • Wireless and Mobile Security
    • Welcome
    • Malicious Code
    • Intrusion Detection
    • Public-Key Cryptography
    • The Security Mindset
    • Hashes
    • Symmetric Encryption
    • Web Security
    • Authentication
  • machine-learning-trading
    • The Fundamental Law of Active Portfolio Management
    • So You Want to be a Hedge Fund Manager
    • Dealing With Data
    • Technical Analysis
    • Sharpe Ratio and Other Portfolio Statistics
    • Incomplete Data
    • Dyna
    • Portfolio Optimization and the Efficient Frontier
    • Histograms and Scatter Plots
    • How Hedge Funds Use the CAPM
    • The Power of NumPy
    • Regression
    • Market Mechanics
    • Optimizers: How to Optimize a Portfolio
    • Efficient Markets Hypothesis
    • The Capital Assets Pricing Model (CAPM)
    • Optimizers: Building a Parameterized Model
    • Reinforcement Learning
    • Q-Learning
    • Statistical Analysis of Time Series
    • What Is a Company Worth
    • Udacity Quizzes - ML4T
    • Textbook Information
    • Welcome
    • How Machine Learning is Used at a Hedge Fund
    • Ensemble Learners, Bagging, and Boosting
    • Reading and Plotting Stock Data
    • Assessing a Learning Algorithm
    • Working with Multiple Stocks
  • computer-networks
    • Congestion Control & Streaming
    • Programming SDNs
    • Spam
    • Network Security
    • Switching
    • DNS
    • Content Distribution
    • Naming, Addressing & Forwarding
    • Architecture and Principles
    • Routing
    • Internet Worms
    • Traffic Engineering
    • Denial of Service Attacks
    • Welcome
    • Router Design Basics
    • Rate Limiting & Traffic Shaping
    • Software Defined Networking
  • operating-systems
    • Threads And Concurrency
    • Introduction To Operating Systems
    • Datacenter Technologies
    • Synchronization Constructs
    • Thread Performance Considerations
    • Threads Case Study - PThreads
    • Processes and Process Management
    • Thread Design Considerations
    • Final Exam Review Questions
    • Memory Management
    • Midterm Exam Review Questions
    • Distributed File Systems
    • IO Management
    • Virtualization
    • Inter-Process Communication
    • Scheduling
    • Welcome
    • Remote Procedure Calls
    • Distributed Shared Memory
  • simulation
    • Course Tour
    • Arena, Continued
    • Arena
    • Output Data Analysis
    • Welcome
    • Random Variate Generation
    • Calculus, Probability, and Statistics Primers, Continued
    • Hand and Spreadsheet Simulations
    • Comparing Systems
    • General Simulation Principles
    • Comparing Systems, Continued
    • Generating Uniform Random Numbers
    • Calculus, Probability, and Statistics Primers
    • Random Variate Generation, Continued
    • Input Analysis
  • secure-computer-systems
    • Welcome to SCS
    • Getting Started
    • Design Principles for Secure Computer Systems
    • Protecting the TCB from Untrusted Applications
    • Virtualization and Security
    • Authentication
    • Discretionary Access Control
    • Mandatory Access Control
    • Midterm Exam Review
  • .github
    • ISSUE_TEMPLATE
      • bug_report
      • typo-report
Powered by GitBook
On this page
  • What is Portfolio Optimization
  • The Difference Optimization can Make
  • Which Criteria is Easiest to Solve For Quiz
  • Which Criteria is Easiest to Solve For Quiz Solution
  • Framing the Problem
  • Ranges and Constraints

Was this helpful?

  1. machine-learning-trading

Optimizers: How to Optimize a Portfolio

PreviousMarket MechanicsNextEfficient Markets Hypothesis

Last updated 4 years ago

Was this helpful?

What is Portfolio Optimization

Given a set of assets and a time period, portfolio optimization seeks to find an allocation of funds to assets that maximize performance. We can choose to optimize for one of several different performance metrics, such as cumulative return, volatility/risk, or Sharpe ratio.

The Difference Optimization can Make

Consider this portfolio, which contains equal allocations to four stocks - GOOG, AAPL, GLD, and XOM - held from the beginning to the end of 2010.

Note that the performance of this unoptimized portfolio, plotted in blue, outperforms SPY, plotted in green.

Let's optimize this portfolio for Sharpe ratio and see how the returns change.

We can see that this optimized portfolio outperforms both SPY and the previous, unoptimized portfolio.

Note the blend of asset allocations required for this performance. Whereas before we had equal allocations between assets, here we have a 40/60 split between AAPL and GLD, with GOOG and XOM receiving no allocation.

Of course, it's easy to go into the past and optimize for values that we know. The important question is: does this type of optimization help us in the future? Indeed, if we optimize our portfolio for Sharpe ratio and reoptimize, or rebalance, our allocations month by month, we often see higher returns than we would have if we stuck with equal allocations.

Which Criteria is Easiest to Solve For Quiz

Let's assume we have a portfolio of four stocks, and we want to find the optimal allocations that maximize some performance metric. Which of the following metrics would be easiest to optimize for?

Which Criteria is Easiest to Solve For Quiz Solution

It would be easiest to write an optimizer for cumulative return. To do so, all we need to do is allocate 100% of our portfolio into whichever stock had the highest cumulative return.

Optimizing for minimum volatility or Sharpe ratio involves evaluating various combinations of stocks, which is more complicated than simply putting all our eggs in one basket.

Framing the Problem

As we've said, we want to optimize our portfolio such that we maximize Sharpe ratio. We've solved optimization problems using minimizers in the past, and so we need to reframe our Sharpe ratio maximization task as a minimization problem.

Recall that using a minimizer involves three steps. First, we define a function $f(x)$ that we want to minimize. Second, we define an initial guess for $x$. Finally, we pass $f(x)$ and $x$ to the optimizer and let it find the value of $x$ that minimizes $f(x)$.

In this case, $x$ is a list of the asset allocations in our portfolio. We want the optimizer to vary these values to discover the set of allocations that minimizes $f(x)$.

We might think to set $f(x)$ equal to the Sharpe ratio expression, but this is incorrect. Remember that the minimizer minimizes $f(x)$, so setting $f(x)$ equal to the Sharpe ratio results in an allocation that produces the smallest Sharpe ratio. We can fix this by instead setting $f(x)$ equal to the negative Sharpe ratio.

Ranges and Constraints

Before we start tweaking our portfolio allocations, we have to consider two other concepts: ranges and constraints.

We need to tell the optimizer that it should only look for candidate values of $x$ within specific ranges. For example, for each of the various allocations in $x$, it only makes sense to look at values between 0 and 1. We can't have a negative allocation, and we can't allocate more than 100% of our portfolio to a particular asset.

Limiting the range of values the optimizer has to search over allows the optimizer to converge much more quickly to the solution.

Additionally, we can give the optimizer constraints: properties of $x$ that must be true for that $x$ to be considered a solution. In our case, we have the constraint that the sum of our allocations - the values in $x$ - must equal 1.