Volume reversal strategy - error in python

Hi,

when running the code, I'm getting a KeyError: -1 in the For loop, the conditional statement "if((data['signal'][i]!=0) & (data['signal'][i]== data['c_signal'][i-1]))" makes a comparison with data['c_signal'][i-1], but in the first iteration i=0, so i-1 equals -1 and is giving an error.



Somebody has this error? Am' I missing anything in the coding?



Thanks

German

We recently updated the downloadable code. You might be getting the error if you are using the old code. Please let us know if this helps.

I’ve just downloaded the code from the end of the course in the Downloable Respurces, zip file; the error is still there. Howver, I’ve made a fix to my code and in the start of the loop, I wrote "for i in range(1,len(data)):: so to start the analysis from the second record

Can you share the downloadable resources with us on quantra@quantinsti.com? We will try to debug your problem and get back to you.