mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-06 05:14:38 +08:00
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:
@@ -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
|
||||
])
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user