Hello team,
In the module Quantitative Trading Strategies and Models Section 2 Unit 13, could you confirm we need to drop the rows where the signal is equal to 0 and where we have same consecutive signals.
In my opinion if the signal is continuous for example on day 1 we have signal = 1 as well as on days 2, 3, 4 then we should take those lines (days 2,3,4) into consideration when calculating the return of the strategy and not drop them.
Thanks!
Adrien
# drop or remove all the rows which have a signal value equal to 0.
df = df.drop((df[(df['Signal'] == 0)].index))
# drop all the rows which have same consecutive signals.
df = df.drop(df[df['Signal'] == df['Signal'].shift(1)].index)
df['Return'] = df['Close'].pct_change()
df['Str_Return'] = df['Return']*df['Signal'].shift(1)
# Calculate the cumulative returns
df['cumulative_returns'] = (df['Str_Return']+1).cumprod()