I am working on the GLD-GDX example from ‘Mean Reversion Strategies In Python’.
I would appreciate help understanding the logic of how the BB on the spread, is mean reverting. As the BB seems more trending on this example than mean reverting. (attached plot)
Thanks.
Shay.
# Long
df['long_entry'] = df.spread < df.lower_band
df['long_exit'] = df.spread >= df.moving_average
# Short
df['short_entry'] = df.spread > df.upper_band
df['short_exit'] = df.spread <= df.moving_average
df[['spread','moving_average','lower_band','upper_band']].head(100).plot.line(figsize=(20,10)).grid()