Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Breaking Down Risk Parity Portfolios: A Practic...

Zé Vinícius
January 22, 2020

Breaking Down Risk Parity Portfolios: A Practical Open Source Implementation

In this talk I will explain the behind the scenes of the now very popular risk parity portfolio, its convex and non-convex formulations, and I will present open source implementations of state-of-the-art algorithms with practical examples.

Zé Vinícius

January 22, 2020
Tweet

More Decks by Zé Vinícius

Other Decks in Technology

Transcript

  1. BreakingDownRiskParity Portfolios: APracticalOpen SourceImplementation a talk by Zé Vinícius (in

    collab. with Daniel Palomar) Hong Kong Machine Learning Meetup @CreditSuisse Jan. nd,
  2. whoami made in Brazil electrical engineer by training, computer scientist

    by passion/experience guest researcher at NIST so ware developer for Google summer of code with OpenAstronomy so ware engineer intern NASA since Sept. : phd student at HKUST National Institute of Standards and Technology, Washington DC, US National Aeronautics and Space Administration, Ames Research Center, Silicon Valley, US The Hong Kong University of Science and Technology
  3. Portfolio Optimization / problem: how to allocate B amount of

    money into N assets? Nobel Memorial Prize in Economic Sciences
  4. Portfolio Optimization / problem: how to allocate B amount of

    money into N assets? assume the log-returns r are i.i.d. Gaussian, then for a portfolio w: expected return: E w r = w µ variance: V w r = w Σw Nobel Memorial Prize in Economic Sciences
  5. Portfolio Optimization / problem: how to allocate B amount of

    money into N assets? assume the log-returns r are i.i.d. Gaussian, then for a portfolio w: expected return: E w r = w µ variance: V w r = w Σw Dr. Harry Markowitz ( ): maximize w w µ − λw Σw subject to w 0, 1 w = 1 Nobel Memorial Prize in Economic Sciences
  6. Portfolio Optimization / problem: how to allocate B amount of

    money into N assets? assume the log-returns r are i.i.d. Gaussian, then for a portfolio w: expected return: E w r = w µ variance: V w r = w Σw Dr. Harry Markowitz ( ): maximize w w µ − λw Σw subject to w 0, 1 w = 1 criticisms: . sensitivity to estimation errors in µ and Σ . does not consider risk diversification Nobel Memorial Prize in Economic Sciences
  7. From Capital to Risk Allocation / allocate risk rather than

    capital first risk parity fund ( ): Bridgewater’s All Weather
  8. From Capital to Risk Allocation / allocate risk rather than

    capital first risk parity fund ( ): Bridgewater’s All Weather Bridgewater publishes "Engineering Targeted Returns and Risks" ( )
  9. From Capital to Risk Allocation / allocate risk rather than

    capital first risk parity fund ( ): Bridgewater’s All Weather Bridgewater publishes "Engineering Targeted Returns and Risks" ( ) -onwards: risk parity gains broad adoption
  10. From Capital to Risk Allocation / allocate risk rather than

    capital first risk parity fund ( ): Bridgewater’s All Weather Bridgewater publishes "Engineering Targeted Returns and Risks" ( ) -onwards: risk parity gains broad adoption basic idea: design a portfolio such that the risk is equally distributed among the asset classes (stocks, bonds, real state, etc.)
  11. From Capital to Risk Allocation / Relative risk contribution Weight

    allocation AAPL AMD ADI ABBV AEZS A APD AA CF AAPL AMD ADI ABBV AEZS A APD AA CF 0.0 0.1 0.2 0.3 0.4 0.0 0.1 0.2 0.3 stocks risk parity Markowitz Portfolio capital and risk distribution
  12. Risk Parity: Problem Formulation / risk parity portfolio: RCCi =

    bi , i = 1, 2, . . . , N feasibility problem: find w 0 w subject to wi (Σw) i w Σw = bi , i = 1, 2, . . . , N doesn’t look trivial approximation: Σ is diagonal wi ∝ √ bi √ Σii i.e. inverse volatility portfolio
  13. Solution to Risk Parity / Spinu ( ): change of

    variables x = w √ w Σw , then w = x 1 x problem becomes: Σx = b x minimize x 0 f(x) = 1 2 x Σx − b log(x) optimality condition: ∇f(x) = Σx − b x = 0 then done? it’s not a QP, LP, etc.
  14. Cyclical Coordinate Descent (CCD) / Griveau-Billion ( ): Algorithm :

    CCD to solve risk parity k ← 0, initial x(0) while not converged do for i = 1 to N do xk+1 i ← arg min xi f xk+1 1 , . . . , xk i , . . . , xk N end end closed-form update: xi = − x−i Σ:,i + x−i Σ:,i 2 + 4Σiibi 2Σii , where x−i = [x1, . . . , xi−1, 0, xi+1, . . . , xN ]
  15. Non-convex Formulations / limitations of the previous formulation: w 0,

    1 w = 1 in practice we would like to include l w u, w µ
  16. Non-convex Formulations / limitations of the previous formulation: w 0,

    1 w = 1 in practice we would like to include l w u, w µ Bruder & Roncalli ( ): minimize w N i=1 wi (Σw)i w Σw − bi 2 subject to 1 w = 1, w ∈ W
  17. Non-convex Formulations / limitations of the previous formulation: w 0,

    1 w = 1 in practice we would like to include l w u, w µ Bruder & Roncalli ( ): minimize w N i=1 wi (Σw)i w Σw − bi 2 subject to 1 w = 1, w ∈ W how to "solve" the non-convex formulation?
  18. Non-convex Formulations / limitations of the previous formulation: w 0,

    1 w = 1 in practice we would like to include l w u, w µ Bruder & Roncalli ( ): minimize w N i=1 wi (Σw)i w Σw − bi 2 subject to 1 w = 1, w ∈ W how to "solve" the non-convex formulation? general purpose solvers: slow
  19. Non-convex Formulations / Feng & Palomar ( ): minimize w

    N i=1 [gi (w)]2 + λF(w) subject to 1 w = 1, w ∈ W
  20. Non-convex Formulations / Feng & Palomar ( ): minimize w

    N i=1 [gi (w)]2 + λF(w) subject to 1 w = 1, w ∈ W "convexify" the objective function: fast
  21. Non-convex Formulations / Feng & Palomar ( ): minimize w

    N i=1 [gi (w)]2 + λF(w) subject to 1 w = 1, w ∈ W "convexify" the objective function: fast basic idea: find a "nice" approximation to the non-convex term, solve it, repeat (Scutari et al. )
  22. Non-convex Formulations / Feng & Palomar ( ): minimize w

    N i=1 [gi (w)]2 + λF(w) subject to 1 w = 1, w ∈ W "convexify" the objective function: fast basic idea: find a "nice" approximation to the non-convex term, solve it, repeat (Scutari et al. ) "nice" approximation for gi (w): first order Taylor expansion (Feng & Palomar )
  23. Basic Usage / R version: > library(riskParityPortfolio) > my_portfolio <-

    riskParityPortfolio(Sigma = Sigma, b = b) > names(my_portfolio) [1] "w" "risk_contributions"
  24. Basic Usage / R version: > library(riskParityPortfolio) > my_portfolio <-

    riskParityPortfolio(Sigma = Sigma, b = b) > names(my_portfolio) [1] "w" "risk_contributions" Python version: >>> import riskparityportfolio as rp >>> my_portfolio = rp.RiskParityPortfolio(covariance=Sigma, budget=b) >>> my_portfolio.design() >>> my_portfolio.weights.numpy() >>> my_portfolio.risk_contributions.numpy()
  25. Practical Example / library(portfolioBacktest) library(riskParityPortfolio) # download price data faang_data

    <- stockDataDownload( c("GOOG", "NFLX", "AAPL", "AMZN", "FB"), from = "2014-01-01", to = "2019-06-25") risk_parity <- function(dataset) { prices <- dataset$adjusted log_returns <- diff(log(prices))[-1] return(riskParityPortfolio(cov(log_returns))$w) } bt <- portfolioBacktest( list("risk parity" = risk_parity, "tangency" = max_sharpe_ratio), list(faang_data), T_rolling_window = 12*20, optimize_every = 3*20, rebalance_every = 3*20)
  26. Practical Example / backtestChartStackedBar(bt, portfolio = "tangency", legend = TRUE)

    0.00 0.25 0.50 0.75 1.00 2015 2016 2017 2018 2019 weight Assets GOOG NFLX AAPL AMZN FB Weight allocation over time for tangency portfolio
  27. Practical Example / backtestChartStackedBar(bt, portfolio = "risk parity", legend =

    TRUE) 0.00 0.25 0.50 0.75 1.00 2015 2016 2017 2018 2019 weight Assets GOOG NFLX AAPL AMZN FB Weight allocation over time for risk parity portfolio
  28. Practical Example / backtestChartCumReturns(bt) + theme(legend.position="top") 1 2 3 2015

    2016 2017 2018 2019 risk parity portfolio tangency portfolio Cumulative Return
  29. Testimonials / "I can easily run optimizations across new covariance

    matrices in seconds, which has helped streamline portfolio allocation testing" Jonathan Dane, CFA. Director of Portfolio Strategy & Market Research, The Coury Firm. "riskParityPortfolio provides a state-of-the-art implementation of rpps, otherwise only available at the top quantitative hedge funds" Tharsis Souza, PhD. Director of Strategic Innovation, Axioma Inc. Founder, OpenQuants.com. Disclaimer: views, thoughts, and opinions expressed in the text belong solely to the author, and not necessarily to the author’s employer, organization, committee or other group or individual.
  30. Takeaways / . risk parity represents a shi from capital

    allocation to risk allocation . risk parity portfolios have been praised for their robustness in di erent market "weathers"
  31. Takeaways / . risk parity represents a shi from capital

    allocation to risk allocation . risk parity portfolios have been praised for their robustness in di erent market "weathers" . non-convex? no problem!
  32. Takeaways / . risk parity represents a shi from capital

    allocation to risk allocation . risk parity portfolios have been praised for their robustness in di erent market "weathers" . non-convex? no problem! . GitHub repositories to stay tuned: dppalomar/riskParityPortfolio dppalomar/riskparity.py dppalomar/portfolioBacktest
  33. References / H .M. Markowitz. "Portfolio selection". The Journal of

    Finance. ( ): – , . Y. Feng and D. Palomar, "SCRIP: Successive convex optimization methods for risk parity portfolios design," IEEE Trans. Signal Process., vol. , no. , pp. – , . Scutari et al. "Decomposition by partial linearization: Parallel optimization of multi-agent systems". IEEE Trans. Signal Processing, ( ), – , . B. Bruder and T. Roncalli, "Managing risk exposures using the risk budgeting approach". University Library of Münich, Germany, Tech. Rep., . F. Spinu, "An algorithm for computing risk parity weights". SSRN, . T. Griveau-Billion, "A fast algorithm for computing high-dimensional risk parity portfolios". https://www.thierry-roncalli.com/ download/CCD-Risk-Parity.pdf, . T. Souza, "DIY Ray Dalio ETF: How to build your own Hedge Fund strategy with risk parity portfolios". https://www.openquants.com