I am very new to the community as well as to coding. I have a very simple question but it has been confusing me for the past several days.
I am trying to use the UsEquity data set and compute the daily return for all stocks: Below is how I define it:
inputs = [USEquityPricing.close]
window_length = 2
def compute(self, today, assets, out, close):
out[:] = close/close[-1]*100
Basically, I am using the current period's closing price and divide it by previous period's closing price. Then I magnify it by 100 just for the ease of reading the result.
After running through several back tests, I found that the return calculated using this formula seems to be wrong (stocks that have losses on a particular day have return calculated to be above 100 in my case). Can anyone here shed a light on where I might be wrong?
Thanks in advance.