Bad calculation of strategy returns for HS Strategy

Course: Price Action Trading Strategies Using Python, Section No: 8 and 10, Unit No: 5 and 11 (respectively)



Hello, in these sections when we're doing the calculation of the strategies returns for Head and Shoulders Strategy (normal and inversed) the way we're calculating the strategy returns it's not correct. We're calculating the returns like this:







Which is correct but the problem is in the "signal" column. As you know this column must have "-1" in all the days the strategy is shorting the asset. As you can see in the trade book dataframe called "trades" these are the dates where we're short in the asset:





However, the column signal is -1 ONLY in the entry dates:





So for the strategy returns calculation we're calculating the returns ONLY for this days. We must change the column "signal" to correctly reflect the whole period when we're short/long to correctly calculate and display all the metrics related to this. I fixed this in this way:





I'm sure you know another way to fix it using a more efficient code.



Please, check these two notebooks as this need to be corrected in both places: Section No: 8 and 10, Unit No: 5 and 11 (respectively).



Thanks in advance!



 

Hi Daniel,



We are checking this and will get back to you.

Hello, any new about this?

Hello Daniel,

Your observation is right. The notebooks have been updated accordingly. You can find the updated notebooks in the relevant units and zip file too. Thanks for pointing this out.

Thanks! I've been checking in other sections there are notebooks without this error fixed. Example: Section 20, Notebook 6:





I think all the backtests in this course needs to fix this issue.



Thanks!

Hi Daniel,



The notebooks are being updated. We will let you know once the updates are done. Thanks.