Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Anomalous appearance of cash during backtest.

Hello,

I noticed strange behavior on December 2nd/3rd, 2013 in a handful of backtests. From 12/02/13 to 12/03/13 the value of my account increased by 60%. Since I was roughly equally invested in 200 securities, this cannot be the result of any realistic corporate event. I've examined the daily positions and transactions, and can't determine the source of this additional money. The appearance of cash is somewhat robust, but the relative magnitude is much less during backtests with a restricted time period.

I am new to the site (just the past week), and don't have access to the research platform yet. Has anyone noticed similar behavior before or have an idea about what might be happening/or ideas for better tracking during backtests? I am also somewhat worried that smaller magnitude changes in cash would go unnoticed by me, and would like to be able to detect them to make sure that everything is working correctly.

The algorithm is very simple (sort of a toy for me to learn more about Quantopian). It justs ranks all stocks according to some valuation metrics (in this case EV/EBITDA and rebalances monthly (choosing 200 securities from Morningstar's databse). There are some controls to sell stocks shortly before they become delisted, etc. I may try slight variations on the algorithm to see how 'stable' the behavior is to perturbations. I attached the backtest, and any comments are appreciated.

8 responses

I have seen similar weirdness, for me, October 30/31st 2006. Did you find any resolution?

Wouldnt this be related to a company being merged or acquired?

Try to check for the end_date field on your positions.

Thanks for the replies,

I have yet to look into the issue further, but I plan to.

It is exceedingly unlikely that a corporate event was responsible because my largest position size was roughly 1/200th my account size.

Ditto - 1/200th size positions on $100M, but I am seeing cashflows of $25M, $6M... if I didn't know better, I'd think there was still a problem with split-adjusting historical dividends...

@GH One thing: Try making the buys after delaying a bar or two after the bunch of selling, then that cash will be available, it is sort of selling out and then trying to buy in right away in the same frame, with little cash, the sells were ordered and not filled yet.

The problem is bad dividend data for BCOM. See attached backtest, where a position of $103K yields a cash inflow of $1.9M on 12/3/2013.

That does look like bad data, we'll take a look at that dividend

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

@garyha - Thanks for the suggestion, I am sure that will help me write less 'clunky' algorithms.

Thanks to others on this thread for looking at this problem, I think it is clear that the dividends at are at fault.