In browsing the work of others I may have encountered a bug related to the ordering of EDV (issue 1)
The presence of a correlated anomaly (issue 2) suggests that a broader algo/backtester problem may exist.
Issue 1: observed anomalous ordering behavior
After years of apparently correct orders the following occurs
2013-05-02 No position in EDV
2013-05-03 Buy order for qty_A shares of EDV
2013-06-03 Sell order for qty_A shares of EDV
2013-06-04 Sell order for qty_B shares of EDV
Issue 2: The leverage may differ significantly from 1.0 at two specific times
June 2009 Leverage = 1.06 after selling EEM and buying IEV
October 2010 Leverage = 0.95 after selling EDV and buying EEM
This issue is observed in test cases in which Issue 1 is present
Conditions under which problems are/are not observed:
- common: $100000 initial cash, daily execution
- present with start date of
- 1/1/06
(qtyB=1239 on 6/3/13), (qtyB=1233 on 8/4/14)
leverage = 1.06 in June 2009, leverage = 0.95 in October 2010
- 1/1/07
(qtyB= 696 on 6/3/13), (qtyB= 396 on 8/4/14)
leverage = 1.06 in June 2009, leverage = 0.95 in October 2010
- 1/1/08
(qtyB =133 on 6/3/13)
leverage = 1.06 in June 2009, leverage = 0.95 in October 2010
- not present with start dates of
- 1/1/09, 1/1/10, 1/1/11, 1/1/12
Base algo:
- Ed Bartosh's "more pythonic" 12/28/2013 implemention of
https://www.quantopian.com/posts/global-market-rotation-strategy-buggy-implementation
Modifications made to base algo:
- added leverage tracking (handle_data)
- added 0.995 multiplier to cash to reduce tendency to be cash negative (handle_data)
- dropped ILF and EPP from stock list (initialize)