Momentum Based ETF Portfolio Rebalancing
Optimizing Portfolio Construction For Optimal Sharpe Ratio
www.quantconnect.com
Jared Broad
CEO and Founder
We’ve built a web algorithm lab where thousands of
people test their ideas on financial data we provide; for free.
LEAN ALGO
TECHNOLOGY
FINANCIAL
DATA
POWER
COMPUTING
What is QuantConnect?
EQUITIES
OPTIONS
FUTURES
FOREX
CRYPTO
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 2
Outline
 Basics of Mean Variance Portfolio Construction
 Defining Optimization Function
 LEAN Algorithm Framework
 Implementing Our Model
 Testing and Researching
 Summary
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 3
Reduce volatility, increase returns by
calculating optimal weight allocation of
a portfolio for minimum volatility.
Core Idea:
1) Create an estimate of portfolio returns and volatility.
2) Build portfolio of assets; allocating to each by weight.
3) Optimize weights to minimize the volatility in portfolio.
Classic Mean Variance Portfolio Construction
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 4
Classic Mean Variance Portfolio Construction
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 5
$-
$5.00
$10.00
$15.00
$20.00
$25.00
$30.00
$35.00
$40.00
Jan-18 Feb-18 Mar-18 Apr-18 May-18 Jun-18 Jul-18 Aug-18 Sep-18 Oct-18
Stock A Stock B
Ideal = 50-50
Classic Mean Variance Portfolio Construction
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 6
$-
$2.00
$4.00
$6.00
$8.00
$10.00
$12.00
Jan-18 Feb-18 Mar-18 Apr-18 May-18 Jun-18 Jul-18 Aug-18 Sep-18 Oct-18
Stock A Stock B Stock C
Stock D Stock E Stock F
Stock G Stock H
Most real world applications have portfolios of many assets. We are seeking
to find best balance of hundreds of assets.
Mean Variance Optimization Function
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 7
Optimizers experiment with portfolios; seeking to
minimize the objective function.
Classic Mean Variance Optimization the objective
function seeks to minimize expected volatility.
Redefining Our Objective
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 8
We will seek to optimize Sharpe Ratio instead of volatility; seeking to
maximize objective function:
𝑥 = m𝑎𝑥(
𝐸𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑃𝑜𝑟𝑡𝑓𝑜𝑙𝑖𝑜 𝑅𝑒𝑡𝑢𝑟𝑛
𝑃𝑜𝑟𝑡𝑓𝑜𝑙𝑖𝑜 𝑉𝑎𝑟𝑖𝑎𝑛𝑐𝑒
)
This target approximates the traditional Sharpe Ratio function.
(We’ll assume the risk free rate of return is zero).
𝑅 𝑝 = (𝑤𝐴, 𝑤 𝐵, 𝑤𝐶)
𝐸(𝑟𝐴)
𝐸(𝑟𝐵)
𝐸(𝑟𝐶)
= 𝑤𝐴 𝐸 𝑟𝐴 + 𝑤 𝐵 𝐸 𝑟𝐵 + 𝑤𝐶 𝐸 𝑟𝐶
With three risk assets in portfolio, the expected return of the portfolio:
We use the variance of each asset, combined with weights to find the variance of the
portfolio:
𝜎 𝑝
2
= 𝑤𝐴, 𝑤 𝐵, 𝑤𝐶
𝑉𝑎𝑟 𝑟𝐴 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐵 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐶
𝑐𝑜𝑣 𝑟𝐵, 𝑟𝐴 𝑉𝑎𝑟 𝑟𝐵 𝑐𝑜𝑣 𝑟𝐵, 𝑟𝐶
𝑐𝑜𝑣 𝑟𝐶, 𝑟𝐴 𝑐𝑜𝑣 𝑟𝐶, 𝑟𝐵 𝑉𝑎𝑟 𝑟𝐶
𝑤𝐴
𝑤 𝐵
𝑤𝐶
= 𝑤𝐴
2 𝑉𝑎𝑟 𝑟𝐴
2 + 𝑤 𝐵
2 𝑉𝑎𝑟 𝑟𝐵
2 + 𝑤𝐶
2 𝑉𝑎𝑟 𝑟𝐶
2
+ 2𝑤𝐴 𝑤 𝐵 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐵 + 2𝑤𝐴 𝑤𝐶 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐶 + 2𝑤 𝐵 𝑤𝐶 𝑐𝑜𝑣 𝑟𝐵, 𝑟𝐶
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 9
Portfolio Variables
Algorithm Framework Modules
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 10
Algorithm Framework Modules
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 11
Assumptions and Limitations
 Mean Variance Optimization requires expected returns and we provide historical
values. We’re making an assumption these returns will continue in the future.
 Most variance approximations assume a normal distribution.
 Any estimation error in the return prediction magnified.
 The resulting portfolios can be concentrated and nonsensical. In practice its more
common to use Black-Litterman method.
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 12
Code and Implementation
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 13
Backtest
Summary
 Using portfolio construction techniques we can automatically assign weights
to our portfolio assets.
 This reduces the number of variables we manually define; can improve
returns and lower volatility.
Next Steps – Investigate more robust portfolio construction techniques!
(E.g. Black-Litterman).
Total Trades Drawdown Net Profit Sharpe Ratio
270 12.9% 34% 0.555
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 14
www.quantconnect.com
Thank you.
Appendix
Our Research Environment
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 17
Coding the Idea, The Algorithm Lab
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 18
Going Live, Deploying to Live Trading
April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 19

QuantConnect ETF Momentum Asset Allocation

  • 1.
    Momentum Based ETFPortfolio Rebalancing Optimizing Portfolio Construction For Optimal Sharpe Ratio www.quantconnect.com Jared Broad CEO and Founder
  • 2.
    We’ve built aweb algorithm lab where thousands of people test their ideas on financial data we provide; for free. LEAN ALGO TECHNOLOGY FINANCIAL DATA POWER COMPUTING What is QuantConnect? EQUITIES OPTIONS FUTURES FOREX CRYPTO April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 2
  • 3.
    Outline  Basics ofMean Variance Portfolio Construction  Defining Optimization Function  LEAN Algorithm Framework  Implementing Our Model  Testing and Researching  Summary April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 3
  • 4.
    Reduce volatility, increasereturns by calculating optimal weight allocation of a portfolio for minimum volatility. Core Idea: 1) Create an estimate of portfolio returns and volatility. 2) Build portfolio of assets; allocating to each by weight. 3) Optimize weights to minimize the volatility in portfolio. Classic Mean Variance Portfolio Construction April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 4
  • 5.
    Classic Mean VariancePortfolio Construction April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 5 $- $5.00 $10.00 $15.00 $20.00 $25.00 $30.00 $35.00 $40.00 Jan-18 Feb-18 Mar-18 Apr-18 May-18 Jun-18 Jul-18 Aug-18 Sep-18 Oct-18 Stock A Stock B Ideal = 50-50
  • 6.
    Classic Mean VariancePortfolio Construction April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 6 $- $2.00 $4.00 $6.00 $8.00 $10.00 $12.00 Jan-18 Feb-18 Mar-18 Apr-18 May-18 Jun-18 Jul-18 Aug-18 Sep-18 Oct-18 Stock A Stock B Stock C Stock D Stock E Stock F Stock G Stock H Most real world applications have portfolios of many assets. We are seeking to find best balance of hundreds of assets.
  • 7.
    Mean Variance OptimizationFunction April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 7 Optimizers experiment with portfolios; seeking to minimize the objective function. Classic Mean Variance Optimization the objective function seeks to minimize expected volatility.
  • 8.
    Redefining Our Objective April-2018QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 8 We will seek to optimize Sharpe Ratio instead of volatility; seeking to maximize objective function: 𝑥 = m𝑎𝑥( 𝐸𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑃𝑜𝑟𝑡𝑓𝑜𝑙𝑖𝑜 𝑅𝑒𝑡𝑢𝑟𝑛 𝑃𝑜𝑟𝑡𝑓𝑜𝑙𝑖𝑜 𝑉𝑎𝑟𝑖𝑎𝑛𝑐𝑒 ) This target approximates the traditional Sharpe Ratio function. (We’ll assume the risk free rate of return is zero).
  • 9.
    𝑅 𝑝 =(𝑤𝐴, 𝑤 𝐵, 𝑤𝐶) 𝐸(𝑟𝐴) 𝐸(𝑟𝐵) 𝐸(𝑟𝐶) = 𝑤𝐴 𝐸 𝑟𝐴 + 𝑤 𝐵 𝐸 𝑟𝐵 + 𝑤𝐶 𝐸 𝑟𝐶 With three risk assets in portfolio, the expected return of the portfolio: We use the variance of each asset, combined with weights to find the variance of the portfolio: 𝜎 𝑝 2 = 𝑤𝐴, 𝑤 𝐵, 𝑤𝐶 𝑉𝑎𝑟 𝑟𝐴 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐵 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐶 𝑐𝑜𝑣 𝑟𝐵, 𝑟𝐴 𝑉𝑎𝑟 𝑟𝐵 𝑐𝑜𝑣 𝑟𝐵, 𝑟𝐶 𝑐𝑜𝑣 𝑟𝐶, 𝑟𝐴 𝑐𝑜𝑣 𝑟𝐶, 𝑟𝐵 𝑉𝑎𝑟 𝑟𝐶 𝑤𝐴 𝑤 𝐵 𝑤𝐶 = 𝑤𝐴 2 𝑉𝑎𝑟 𝑟𝐴 2 + 𝑤 𝐵 2 𝑉𝑎𝑟 𝑟𝐵 2 + 𝑤𝐶 2 𝑉𝑎𝑟 𝑟𝐶 2 + 2𝑤𝐴 𝑤 𝐵 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐵 + 2𝑤𝐴 𝑤𝐶 𝑐𝑜𝑣 𝑟𝐴, 𝑟𝐶 + 2𝑤 𝐵 𝑤𝐶 𝑐𝑜𝑣 𝑟𝐵, 𝑟𝐶 April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 9 Portfolio Variables
  • 10.
    Algorithm Framework Modules April-2018QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 10
  • 11.
    Algorithm Framework Modules April-2018QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 11
  • 12.
    Assumptions and Limitations Mean Variance Optimization requires expected returns and we provide historical values. We’re making an assumption these returns will continue in the future.  Most variance approximations assume a normal distribution.  Any estimation error in the return prediction magnified.  The resulting portfolios can be concentrated and nonsensical. In practice its more common to use Black-Litterman method. April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 12
  • 13.
    Code and Implementation April-2018QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 13 Backtest
  • 14.
    Summary  Using portfolioconstruction techniques we can automatically assign weights to our portfolio assets.  This reduces the number of variables we manually define; can improve returns and lower volatility. Next Steps – Investigate more robust portfolio construction techniques! (E.g. Black-Litterman). Total Trades Drawdown Net Profit Sharpe Ratio 270 12.9% 34% 0.555 April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 14
  • 15.
  • 16.
  • 17.
    Our Research Environment April-2018QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 17
  • 18.
    Coding the Idea,The Algorithm Lab April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 18
  • 19.
    Going Live, Deployingto Live Trading April-2018 QuantConnect – Momentum Based ETF Portfolio Rebalancing Page 19

Editor's Notes

  • #2 Welcome everyone! Thank you for joining today! My name is Jared Broad and I am the CEO and Founder of QuantConnect. QuantConnect is a website platform which empowers you build automated investment strategies. We believe all investors deserve access to powerful investment tools and are trying to make it as easy as possible. We take care of all of the boring and mechanical aspects and leave you to focus on building and testing your investment strategy. Through our website community we’re finding the best and brightest minds from around the world and connecting them with the capital they need. Please not all examples discussed in this presentation are for purposes only we’ll be using are for illustration and research purposes only. Historical backtests do not guarantee future results. You should always research methods for your investments
  • #3 We have a web based algorithm development environment with free financial data for equities, futures, options, forex and crypto currencies. You can explore and create new algorithms! Behind the scenes we provide terabytes of financial data, covering US Equities, Options, Crypto, Futures and FX markets from tick to daily resolution. We make all of that data available for free for you to analyze and test out your ideas for investment opportunities. Our platform runs on LEAN; our open-source algorithmic trading engine. Lean is the core technology behind QuantConnect and drives all of the strategy modelling and live trading. Being open source means you can download our core technology and run it on your own servers without being locked into our service.
  • #4 In this webinar we’re going to give you a high level overview of mean variance portfolio construction; and then adjust it for our purposes to build a portfolio with momentum based weighting. We’ll build it in the QuantConnect LEAN Algorithm Framework – a modular approach for designing algorithms. This lets you plug in work of other people to quickly experiment! We’ll review the code implementation and perform some backtests on the results.
  • #6 Classic Mean Variance optimization suggests given two assets with very low correlations we can find the optimal combination of the two which cancels out and gives us the ideal portfolio. We’ve illustrated this here with two relatively simple assets (sine-stocks) which are perfect opposites. The combined portfolio is a near straight line.
  • #7 In reality we work with portfolio’s of more than 2 assets; and so finding the “perfect portfolio” takes a little work. To do this work we employ an optimizer library which with hundreds of portfolios to find the optimal balance of each one. These portfolios assign various weights to each asset; and then test the final portfolio against an objective function – the measure of our success. In Mean Variance optimization this objective function is the with the lowest volatility possible!
  • #10  Return of Portfolio = Return of each Asset * Weight.
  • #11 We have designed a framework for the foundation of the algorithm. This guides you in the best implementation of the algorithm. First we select the assets in the universe we’d like to trade with the Universe Selection Model; Once selected we generate trading signals on these assets with the Alpha Model; Finally we pipe these signals into the Portfolio Construction Model to generate the weighting for the assets. In this webinar we’re building a sharpe-weighted portfolio construction model. The universe is a fixed list of popular liquid ETF’s. We are assuming a constant Alpha Model for this case as it is ignored and we’re just using the historical returns for the signals. Next we’ll guide you through the code for how we implemented this in the website IDE.
  • #19 Here is where you take the code from your research environment and code it up into an algorithm.