I'm trying to impliment this part of a Quantopian algorithm:

returns_overall = Returns(window_length=136) returns_recent = Returns(window_length=10) momentum = returns_overall - returns_recent

And then sort my universe selction by momentum in fine selection.

Is there a simple way to do this in QuantConnect?

I found a momentum indicator that works, but I can't figure out how to subtract a mom(126) from a mom(10) and then sort based on that number...

averages = dict() history = algorithm.History(symbols, 200, Resolution.Daily).close.unstack(0) for symbol in symbols: # Remove NaN: symbol does not have 200 daily data points df = history[symbol].dropna() if df.empty: continue mom = Momentum(136) for time, close in df.iteritems(): mom.Update(time, close) # Adds Momentum to dict only if it is ready if mom.IsReady: averages[symbol] = mom # Update with current data for symbol, mom in averages.items(): c = self.coarse.pop(symbol, None) mom.Update(c.EndTime, c.AdjustedPrice) sortedbyMomentum = sorted(averages.items(), key=lambda x: x[1], reverse=True)

Anyone have an idea? Thanks!

Author