From 88398236ff5637b5aca0038c5911a98bf0e2b78c Mon Sep 17 00:00:00 2001 From: Andrew Daniels Date: Tue, 25 Apr 2017 11:58:03 -0400 Subject: [PATCH] MAINT: Use March quarterly cycle for JY, CD, AD, & BP continuous futures The March, June, September, and December contracts for these futures contain most of the trading activity, so we exclude the other more sparsely traded contracts from the chain. --- zipline/assets/continuous_futures.pyx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/zipline/assets/continuous_futures.pyx b/zipline/assets/continuous_futures.pyx index 3a631d10..3e71c8b8 100644 --- a/zipline/assets/continuous_futures.pyx +++ b/zipline/assets/continuous_futures.pyx @@ -47,10 +47,23 @@ def delivery_predicate(codes, contract): delivery_code = contract.symbol[-3] return delivery_code in codes +march_cycle_delivery_predicate = partial(delivery_predicate, + set(['H', 'M', 'U', 'Z'])) + CHAIN_PREDICATES = { - 'ME': partial(delivery_predicate, set(['H', 'M', 'U', 'Z'])), + 'ME': march_cycle_delivery_predicate, 'PL': partial(delivery_predicate, set(['F', 'J', 'N', 'V'])), - 'PA': partial(delivery_predicate, set(['H', 'M', 'U', 'Z'])) + 'PA': march_cycle_delivery_predicate, + + # The majority of trading in these currency futures is done on a + # March quarterly cycle (Mar, Jun, Sep, Dec) but contracts are + # listed for the first 3 consecutive months from the present day. We + # want the continuous futures to be composed of just the quarterly + # contracts. + 'JY': march_cycle_delivery_predicate, + 'CD': march_cycle_delivery_predicate, + 'AD': march_cycle_delivery_predicate, + 'BP': march_cycle_delivery_predicate, } ADJUSTMENT_STYLES = {'add', 'mul', None}