Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
What am I doing wrong with using Relative Strength Indicator for a Universe of Stocks -94287607.6% Return

Hi Guys,

Written an algorithm which uses Relative Strength Indicator on a universe of stocks to buy or sell stocks.I am getting a crazy return of -94287607.6%.I am not able to get a hang of the problem.

3 responses

I don't know if this is it but you have now context.min notational

Cool idea but you are allowing your algo to borrow a bunch of $$$. That means your cash goes negative and when you buy your really shorting the stock and going further in the hole. You need to weight your investment per stock and use absolute values just in case your cash goes negative somehow. I added a couple lines to evenly weight your portfolio and recorded your cash and positions.
The back test lets you borrow whatever you want, it's on you to make sure you don't.

Thanks David.I did not know that the backtest can borrow as much dollars as it wants.