Notebook

Below is a modified flowchart that I ran by Dr. Gary to confirm for accuracy. This modification produced higher returns against the flowchart on page 101 for the few backtests that I executed. At his suggestion, I'm posting this to Quantopian to pass this on to anyone interested. It actually simplifies the rebalancing logic in my opinion.

Image of Momentum

Implementation

The modified (and simplified) logic in my_assign_weights(context, data) looks like:

In [ ]:
if returns[context.us] < returns[context.tbill]:
    context.weights[context.agg] = 1

else:
    if returns[context.us] > returns[context.worldExUS]:
        context.weights[context.us] = 1
    else:
        context.weights[context.worldExUS] = 1

context.weights.fillna(0,inplace=True)

This logic also rebalances entirely to AGG when absolute momentum dictates it.