Hey folks!
We've fixed a bug in Zipline, our backtesting engine, that was causing dividends to pay out repeatedly in long-running backtests. Some members noticed that, when they ran very long backtests, they began to see anomalous cash flows entering their results. The root of the issue was that, when an asset was removed from the algorithm's universe, the dividend information was being left behind. If the algorithm then re-added the asset to the tradeable universe, the dividend information would be added a second time. This could happen repeatedly, stacking identical dividends on top of each other and causing an anomalous pay-out when the dividend's pay_date actually arrived.
Your algo would have been affected if:
1. Your algo frequently adds/subtracts assets from its universe
2. Those assets pay dividends
3. You run long backtests (long enough to add/subtract repeatedly)
An analysis run using our internal testing harness suggests that only ~1% of backtests were impacted by this issue, and most of those were minorly impacted. The bug was caught because some members' algos traded symbols with very large dividends, and the duplication of these divdends was very noticeable. Thanks are due to Simon Thornington, Mingran Wang, and others for noticing these anomalies and sharing their findings with us.
We've fixed how Zipline handles the removal of an asset from the universe, and this issue should no longer be present in newly-generated backtests.
I was a little bit bummed when I figured out this bug - I hated that we'd had a bug like this for so long and not noticed it. But talking about it with other people here at Quantopian, I was cheered up. They reminded me that the backtester is very good, and every time we find a bug like this, it gets better. We're finding these bugs because the backtester is being used and scrutinized by thousands of people. We've got more than 4 million years of backtesting already done. So yes, I hate this bug, but on the other hand, we're making a great backtester even better. It's good improvement.
Separately, I've dug into a number of underlying data issues that were causing problems with splits and dividends. We have corrected a number of splits and dividends that were not properly rendered. The list of those fixes is below:
Splits:
SID 34010 - COV - Should have been 1:1 (1:100, 100:1) on 3/21/11
SID 25805 - TZOO - Should have been 1:1 (1:25, 25:1) on 11/7/13
SID 6900 - SJI - Should have been 2:1 on 5/08/15
SID 32269 - DDM - Should have been 2:1 on 5/20/15
SID 32270 - SSO - Should have been 2:1 on 5/20/15
SID 32272 - QLD - Should have been 2:1 on 5/20/15
SID 33209 - SAA - Should have been 2:1 on 5/20/15
SID 33262 - ROM - Should have been 2:1 on 5/20/15
SID 33265 - UYG - Should have been 2:1 on 5/20/15
SID 33270 - RXL - Should have been 2:1 on 5/20/15
SID 38533 - UPRO - Should have been 2:1 on 5/20/15
SID 38583 - CSM - Should have been 2:1 on 5/20/15
SID 39215 - UDOW - Should have been 2:1 on 5/20/15
SID 39216 - UMDD - Should have been 2:1 on 5/20/15
SID 39479 - BIB - Should have been 2:1 on 5/20/15
SID 47404 - SYTL - Should have been 2:1 on 5/20/15
SID 39129 - IBME - Should have been 2:1 on 5/21/15
SID 39132 - IBMF - Should have been 2:1 on 5/21/15
SID 18417 - EXPO - Should have been 2:1 on 6/05/15
SID 40515 - TVIX - Should have been 1:10 on 6/23/15
SID 19894 - INFY - Should have been 2:1 on 6/25/15
Dividends:
SID 34977 - BCOM - Should have been $.97 on 12/03/13
SID 26578 - GOOG_L - Should have been ex_date of 4/03/14
Most of these were found because members noticed anomalous behavior in their backtests. If you notice any anomalous dividends, splits, or other behavior, please let us know!
-James