Mistake in code Cross Sectional Momentum notebook

Course Name: Momentum Trading Strategies, Section No: 14, Unit No: 10, Unit type: Notebook



Hello,

I believe there is a mistake in this line of  code since it does not remove the last line of hold_returns that is NaN.

stocks_returns = hold_returns[lookback_days::hold_days] * \
        lookback_signal[::hold_days]

The code should be this one:

stocks_returns = hold_returns[lookback_days:-1:hold_days] * \
        lookback_signal[::hold_days]

Am I correct?

Best,

Raimondo

Hi Raimondo,



You can drop the NaN values if you want to do so. But it won't change the calculations as anything multiplied by NaN is NaN. Hence, those will be automatically ignored in the calculations.



Thanks,

Akshay