In lecture 39 we see the following:
class MyFactor(CustomFactor):
""" Momentum factor """
inputs = [USEquityPricing.close,
Returns(window_length=126)]
window_length = 252
def compute(self, today, assets, out, prices, returns):
out[:] = ((prices[-21] - prices[-252])/prices[-252] -
(prices[-1] - prices[-21])/prices[-21]) / np.nanstd(returns, axis=0)
Then we see this description.
"This momentum factor takes the change in price over the past year, up until a month ago, and standardizes it over the the change in price over the last month. This allows it to account for any changes over the past month and use them to temper its expectations of future movement." (Emphasis are mine.)
However, the second input is Returns(window_length=126)
. Is that supposed to be 21
or 20
or is there some nuance about this factor and it really should be 126
. And if it should 126
, is it more generically window_length/2
?