Long Only - Defensive Adaptive Asset Allocation - Manual Universe

Long Only - Defensive Adaptive Asset Allocation - Manual Universe

Here's a FREE ALGO for you, simply hit the CLONE ALGORITHM button below!

This is a QuantConnect implementation of the Adaptive Asset Allocation strategy presented by Ilya Kipnis in this post.

Universe: The universe consists of ETFs from different asset classes: SPY (US equities), VGK (European equities),  EWJ  (Japanese equities), EEM (Emerging market equities), VNQ (US REITs), RWX (International REITs), TLT (US 30-year Treasuries), IEF (US 10-year Treasuries), DBC (Commodities) and GLD (Gold).

Alpha: Every N days, we compute the 1-3-6-12 momentum filter for the whole Universe (i.e. the sum of 12 * 1-month momentum, 4 * 3-month momentum, 2 * 6-month momentum and 12-month momentum) and rank them. The final selection is based on Dual Momentum: a combination of Positive Absolute Momentum (momentum score above 0) and Relative Momentum (keeping the Top N assets in the ranking).

In the original strategy, the proposed rebalancing period is monthly. However, this type of strategies are very sensitive to timing (when you launch the strategy), and rebalancing at the end or start of each month can have a huge impact on results. In this implementation, we're proposing using a parameter daysToRecalculate to select the number of trading days to perform the momentum calculations and rebalancing regardless of when the strategy is deployed, thus reducing the timing biais.


  • We apply portfolio optimization to the top assets in a particular way. We compute the covariance matrix using one-month volatility estimates, and a correlation matrix that is the weighted average of the same parameters used for the momentum filter (12 * 1-month correlation + 4 * 3-month correlation + 2 * 6-month correlation + 12-month correlation, all divided by 19). In the original strategy, the proposed optimization is Minimum Variance. However, in this implementation we're adding the possibility to choose between: Minimize Portfolio Variance, Maximize Portfolio Return and Maximize Portfolio Sharpe Ratio.
  • This strategy also uses two Canary Assets: VWO (Vanguard FTSE Emerging Markets ETF) and BND (Vanguard Total Bond Market ETF), to determine the level of exposure to "risky assets". We compute the 1-3-6-12 momentum for the Canary Assets and our exposure to "risky assets" will be:
    • 100% if both have Positive Absolute Momentum.
    • 50% if only one has Positive Absolute Momentum.
    • 0% if none has Positive Absolute Momentum.
    • The remaining % from the above calculation will go to IEF if this asset also has Positive Absolute Momentum. Otherwise, we stay in cash.

Execution: Immediate Execution with Market Orders.

Research: Research notebook containing:

  • A step by step walk-through of the Momentum Score calculation.
  • A step by step walk-through on how to calculate the Covariance Matrix using a custom correlation matrix (like the one in our algorithm, computed as a weighted average of multiple period correlations).


Ideas to try (user-defined inputs in the main.py script):

  • Play with the SetStartDate and SetEndDate dates to change the period of backtest.
  • Select a different number of top assets to trade. For example, do topMomentum = 3 to only keep the top 3 momentum assets.
  • Select a different number of trading days to re-calculate momentum and rebalance portfolio. For example, use daysToRecalculate = 10 to recalculate every 10 trading days.
  • Perform a different type of portfolio optimization technique. For example, do objectiveFunction = 'sharpe' to calculate the weights that maximize the portfolio sharpe ratio.
Do you have a strategy of your own that you would like to backtest and automate? Learn about our consulting services and get in touch at

    Found this product useful? You can support this site by making a donation using the link below!