From 791328c5adf209ac05cfddc8ab1b87f1420d7113 Mon Sep 17 00:00:00 2001 From: fawce Date: Tue, 19 Feb 2013 00:14:08 -0500 Subject: [PATCH] changing the calendar test for lse to use the last available date rather than the end date. --- tests/test_tradingcalendar.py | 12 ++++++------ zipline/utils/tradingcalendar.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_tradingcalendar.py b/tests/test_tradingcalendar.py index a5416413..a09bf6f7 100644 --- a/tests/test_tradingcalendar.py +++ b/tests/test_tradingcalendar.py @@ -68,18 +68,18 @@ class TestTradingCalendar(TestCase): env_start_index = \ env.trading_days.searchsorted(tradingcalendar_lse.start) env_days = env.trading_days[env_start_index:] - diff = env_days - tradingcalendar_lse.trading_days + end_index = \ + tradingcalendar_lse.trading_days.searchsorted(env.trading_days[-1]) + # pandas series slicing is different. + cal_days = tradingcalendar_lse.trading_days[:end_index+1] + diff = env_days - cal_days self.assertEqual( len(diff), 0, "{diff} should be empty".format(diff=diff) ) - diff2 = tradingcalendar_lse.trading_days - env_days - # depending on the time of day, data for the current day - # may not be available from yahoo, so don't include end - # of the tradingcalendar - diff2 = diff2 - self.end + diff2 = cal_days - env_days self.assertEqual( len(diff2), 0, diff --git a/zipline/utils/tradingcalendar.py b/zipline/utils/tradingcalendar.py index d036bd63..dbf90cf3 100644 --- a/zipline/utils/tradingcalendar.py +++ b/zipline/utils/tradingcalendar.py @@ -17,13 +17,13 @@ import pandas as pd import pytz -from datetime import datetime, timedelta +from datetime import datetime from dateutil import rrule from delorean import Delorean start = datetime(1990, 1, 1, tzinfo=pytz.utc) -end_dln = Delorean(datetime.now() - timedelta(days=1), 'US/Eastern') -end_dln.truncate('day').shift('UTC') +end_dln = Delorean(datetime.now(), 'US/Eastern') +end_dln.shift('UTC').truncate('day') end = end_dln.datetime