Leveraged risk-parity strategy, help please!

I am interested in backtesting and automating my risk-parity strategy with futures (UB, ES, GC) while holding the cash in 3 month t-bills. I currently use about 2.5x leverage and a risk allocation of 50%, 40% and 10% respectively, with quarterly rollovers and yearly rebalancing. I need a template where I can tweak and backtest with varying degrees of leverage and rebalancing frequencies. If too difficult to get futures data, TLT, SPY and GLD are good approximations. Can anyone help?

Update Backtest

On the face of it, with a few compromises, it sounds like what you want isn't terribly difficult to acheive. I have cut a few corners and adapted the basic template algorithm.

If this is any help perhaps you can explain the underlying assertions of the strategy. How are the risk allocations arrived at? What is the preference of holding t-bills?


Thank you James, this was very helpful. This is not a true risk-parity strategy strictly speaking, as risk-parity would be based on constantly adjusting risk allocation against changing correlations. It’s purely quantitative. My strategy is rather just to have a very basic balanced portfolio based on key asset class allocation that, as with any balanced portfolio, offers better risk-adjusted returns than most 100% equities or 100% bonds portfolio and this can be back-tested for over 100 years, in all macroeconomic scenarios, with rising or falling inflation, growth and interest rates. In the long-term almost any average balanced portfolio is good enough, the leverage takes care of the rest. Regarding t-bills, if I am implementing my strategy with futures rather than ETFs, I would rather not leave excess cash hanging around in the brokerage account as the SIPC insurance is very low for cash, in case the broker goes bust. I would rather own us govt securities that I can get my hands on independent of my brokerage’s fate.


Thanks. As you say, this is not risk adjusted, (and without a stop loss) which means it's a fairly simple strategy. I believe there are methods exposed to the algorithm to calculate correlations on the fly, but when you're talking about long timescales, this is not particularly useful. What approach would you take if you wanted to convert this into a full risk parity strategy? Would you require an additional hedging strategy or are the risks already adequately hedged? I suppose if you hard code the risk allocations you would want to hedge against the correlations falling out of expectation.

As you’ll see I’ve diverged in a few areas from your description, and am fairly sure I’ve transposed your risk allocations. You should be able to tweak the main parameters you mentioned with the months and leverage variables. If you need to rebalance at a frequency less than annually or more than monthly, wider changes will be needed.

I'm intrigued by the consistent performance up until the middle of last year and am wondering what steps could be taken to avoid the drawdown.


I don't know how I would convert this into a full risk-parity strategy, I am not really a quant trader. I have more of an economics mind and I like the strategy because I understand it from a macroeconomics perspective, hence, I know that the correlations there can break down only up to a certain point. This helps a lot psychologically during the inevitable drawdowns. I already thought a lot about how to reduce them, but its really difficult without compromising long-term returns, I am not a fan of stop-losses as you are just too often shaked off from your position just to see the market rally afterwards. In this strategy, the allocation is you stop loss. What you can do is increase leverage and rebalancing frequency and try to find the sweet spot.

I also thought of replacing the ETFs for long dated options strategies. This is a way that you definitely could improve the risk reward profile, but it would be hell to backtest. SPY options have a lot of skew, you could place a risk-reversal with SPY, SPX or ES options instead of owning the ETF. On the other hand, collars on treasury futures tend to have a good payoff profile. Another way would be to sell long dated atm puts and roll them over yearly, but I have not clue whatsoever on how to backtest these strategies, but I am sure they would be good. You could increase the leverage while naturally limiting risk.

I’ve been working on a project that allows genetic optimization of algorithm parameters. I ran this strategy in the optimizer and as it is low resolution with only two parameters, it decided an optimum fairly quickly:

  • start: 2017-01-26 11:56:34Z
  • end: 2017-01-26 12:14:54Z
  • leverage: 2.0
  • monthKey: 5 (rebalance every 12 months)
  • sharpe: 1.007

I then extended the parameters to include asset allocations for the ETF’s. This was still a fairly simple solution which resulted in the following optimum:

  • start: 2017-01-26 12:58:19Z
  • end: 2017-01-26 13:14:35Z
  • leverage: 2.1
  • monthKey: 2 (rebalance every 2 months)
  • tlt: 0.4
  • spy: 0.6
  • sharpe: 1.191

These results aren’t of great practical significance given the timescale of the test data (and some other caveats). You’ll notice that the GLD event last year contributes to an optimum excluding this asset. I’m wondering how these findings compare to your expectations based on macroeconomic or other factors?




I tested various asset class allocations on a freely available website, you can go back to the 70's and also can see the efficient frontier between 2 assets, i.e. the highest sharpe. I just tested a lot around on the longest data I could find and honestly, anything between 40 and 50% US equities and the rest on long term treasuries will give you very decent risk adjusted returns. So that's pretty much in line with your findings. A bit of gold helped during inflation shocks like early 80s, but costs you money on the long term so its best keeping it to a minimum. The point is making the portfolio more stable in any possible scenario in order to allow you to increase leverage. So on the allocation side, is broadly speaking just building a balanced portfolio for life. Curiously, the allocations are more or less in line with the current bond/ equities weightings in the whole of the investable universe.

Regarding leverage, there were some margin calls using over 3x. I think one would definitely get better returns using about 3.5x but rebalancing would need to happen weekly or maybe even daily. I don't know how to change that. Lastly, I don't know what brokerage model the algo is currently using, but mine is a portfolio margin with IB brokers. I suppose making these adjustments would allow backtesting with more leverage and get good results.

I have rejigged this slightly for a longer timescale and required a minimum 10% of each etf. Rebalancing can now occur every n>7 days.  Slippage and fees will likely preclude rebalancing too frequently on IB, and this will be accounted for by the backtests.

When run through the optimizer, there was no way to survive 2008 without a margin call event. This means the trading engine may detect an imminent margin call and offload the culprit to bring the portfolio back within limit. Whether this would work in (freefall) live trading is anyone’s guess. The eventual optimum was found to be:

start: 2017-01-27 14:44:11Z

end: 2017-01-27 16:17:35Z

leverage: 2

days: 330

tlt: 0.3

spy: 0.4

sharpe: 0.618


To investigate the effect of higher leverage, I changed the default IB leverage to a maximum of x4. I also changed the start date to late 2004 as the Yahoo data does not extend any earlier for the GLD ETF. As results were nearing the 365 days rebalancing ceiling I increased the maximum, to encourage the optimizer to explore higher values. This is still using the default (optimistic) slippage, which will bias towards more frequent rebalancing. If you’d like to suggest a slippage estimation, this can be included in the model.

start: 2017-01-30 09:58:05Z

end: 2017-01-30 10:14:27Z

leverage: 3.8

days: 391

tlt: 0.3

spy: 0.5

sharpe: 0.84


This should yield very decent results. I think the slippage doesn’t play a big role, these are very liquid instruments. I wasn’t able to see the new version with your changes, can you share it here again?




Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed