Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Where is the cash going?

I wrote this algorithm and in periods where it is holding only cash, a portion of the cash is disappearing, can anyone tell me why this is? I'd assume it's because the backtest has some model for the cost of borrowing stock but as far as I was aware that isn't implemented.

1 response

I think this is a result of using daily data and being short an ETF when the dividend comes out.

E.g. your algo shorts SPY on 2012-06-13 (which it only gets on 2012-06-14 due to daily data). SPY had a dividend on 2012-06-15 (ex div date), which you have to pay, and that money comes out about 6 weeks later on 2012-07-31. I see the algo tries to close that short position on 2012-06-14, but I think with daily data that gets counted as being on the Register for that day (hmm, confusing)

IVV also has dividends, so that may be interacting with the cash flow too.

I think if you switch to minute mode and use schedule_function you'll get close to what you want (you'll still have to pay dividends though)