Skip to content

Commit

Permalink
Merge pull request #2549 from quantopian/futures-test-data
Browse files Browse the repository at this point in the history
Futures test data
  • Loading branch information
richafrank committed Sep 25, 2019
2 parents cf7f05b + d0aaaae commit 10be68a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions zipline/assets/roll_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ def _active_contract(self, oc, front, back, dt):

class VolumeRollFinder(RollFinder):
"""
The CalendarRollFinder calculates contract rolls based on when
The VolumeRollFinder calculates contract rolls based on when
volume activity transfers from one contract to another.
"""
GRACE_DAYS = 7
THRESHOLD = 0.10

def __init__(self, trading_calendar, asset_finder, session_reader):
self.trading_calendar = trading_calendar
Expand Down
10 changes: 5 additions & 5 deletions zipline/assets/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pandas as pd
from pandas.tseries.offsets import MonthBegin
from six import iteritems

from .futures import CMES_CODE_TO_MONTH

Expand Down Expand Up @@ -255,13 +254,14 @@ def make_future_info(first_sid,
year_strs = list(map(str, years))
years = [pd.Timestamp(s, tz='UTC') for s in year_strs]

# Pairs of string/date like ('K06', 2006-05-01)
# Pairs of string/date like ('K06', 2006-05-01) sorted by year/month
# `MonthBegin(month_num - 1)` since the year already starts at month 1.
contract_suffix_to_beginning_of_month = tuple(
(month_code + year_str[-2:], year + MonthBegin(month_num))
(month_code + year_str[-2:], year + MonthBegin(month_num - 1))
for ((year, year_str), (month_code, month_num))
in product(
zip(years, year_strs),
iteritems(month_codes),
sorted(list(month_codes.items()), key=lambda item: item[1]),
)
)

Expand All @@ -274,7 +274,7 @@ def make_future_info(first_sid,
'symbol': root_sym + suffix,
'start_date': start_date_func(month_begin),
'notice_date': notice_date_func(month_begin),
'expiration_date': notice_date_func(month_begin),
'expiration_date': expiration_date_func(month_begin),
'multiplier': multiplier,
'exchange': "TEST",
})
Expand Down

0 comments on commit 10be68a

Please sign in to comment.