Calendar effect strategy code

Course Name: undefined, Section No: 4, Unit No: 2, Unit type: undefined



Hi Quantra team,



Going through the Juypter note book for the calendar effect, I have the below two questions:



1.) running_max[running_max < 1] = 1 - why does the running maximum need to be at least 1?



2.) spy_prices['sma_signal'] = np.where(spy_prices['Adjusted Close'] > spy_prices['sma_200'], 1, 0) - why do we compare the previous day's adjusted close to current day SMA 200? Shouldn't we be comparing today's adjusted close to previous day's SMA 200 to determine wheter to enter into a position today?



Many thanks,

Ryan

Hi Ryan,



1. running_max is accumulating the cumulative returns. The running_max can never be less than one because, at the beginning of the strategy run, the net portfolio returns is 1 (the baseline level).



2. We use shift(1) because we need to know if the price was above SMA at the close of the previous day. If the price is above SMA value, place value of 1 to our SMA signal. That's how this particular indicator is designed. You may tweak different indicators for different events.



Hope this helps!