Fixes dates used in test factory for batch transforms.

The test factory was creating non-market days.
i.e. the date range spanned the weekend.

Using pandas' BDay frequency so that only business days are created.

This specific date range doesn't have holidays, so not accounting
for holidays in the factory.

Also, widens the range of the trading calendar to cover the test dates
generated by the factory which include 1990.
Previously the trading calendar began with 2002, meaning that holiday
and weekend adjustments with the data exercised by the factory did
not trigger when run with data in 1990.

This does increase the memory footprint of the tradingcalendar module.
However, only by a couple MB, so taking the hit there to enable
correct behavior.
This commit is contained in:
Eddie Hebert
2013-01-30 14:06:56 -05:00
parent 2587cd6512
commit 44140d2de7
3 changed files with 12 additions and 4 deletions
+10 -2
View File
@@ -389,5 +389,13 @@ class TestBatchTransform(TestCase):
expected_item = ((1, ), {'kwarg': 'str'})
self.assertEqual(
algo.history_return_args,
[None, None, None, expected_item, expected_item,
expected_item])
[
# 1990-01-03 - window not full
None,
# 1990-01-04 - window not full
None,
# 1990-01-05 - window not full, 3rd event
None,
# 1990-01-08 - window now full
expected_item
])
+1 -1
View File
@@ -282,7 +282,7 @@ def create_test_df_source(trading_calendar=None):
end = trading_calendar.last_close \
if trading_calendar else pd.datetime(1990, 1, 8, 0, 0, 0, 0, pytz.utc)
index = pd.DatetimeIndex(start=start, end=end, freq=pd.datetools.day)
index = pd.DatetimeIndex(start=start, end=end, freq=pd.datetools.BDay())
x = np.arange(0, len(index))
df = pd.DataFrame(x, index=index, columns=[0])
+1 -1
View File
@@ -20,7 +20,7 @@ from datetime import datetime
from dateutil import rrule
from zipline.utils.date_utils import utcnow
start = datetime(2002, 1, 1, tzinfo=pytz.utc)
start = datetime(1990, 1, 1, tzinfo=pytz.utc)
end = utcnow()
non_trading_rules = []