diff --git a/tests/test_algorithm_gen.py b/tests/test_algorithm_gen.py index c23de829..cac74447 100644 --- a/tests/test_algorithm_gen.py +++ b/tests/test_algorithm_gen.py @@ -108,7 +108,7 @@ class AlgorithmGeneratorTestCase(TestCase): # May 7, 2012 was an LSE holiday, confirm the 4th trading # day was May 8. self.assertEqual(results[4]['daily_perf']['period_open'], - datetime(2012, 5, 8, 8, 30, tzinfo=pytz.utc)) + datetime(2012, 5, 8, 8, 31, tzinfo=pytz.utc)) @timed(DEFAULT_TIMEOUT) def test_generator_dates(self): diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index e2aa588b..0378220d 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -72,7 +72,7 @@ class TestDividendPerformance(unittest.TestCase): def test_market_hours_calculations(self): with trading.TradingEnvironment(): # DST in US/Eastern began on Sunday March 14, 2010 - before = datetime.datetime(2010, 3, 12, 14, 30, tzinfo=pytz.utc) + before = datetime.datetime(2010, 3, 12, 14, 31, tzinfo=pytz.utc) after = factory.get_next_trading_dt( before, datetime.timedelta(days=1) diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index 25522c00..6502a68f 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -187,7 +187,7 @@ Last successful date: %s" % self.market_open) # shift the time between EST and UTC. next_open = next_open.replace( hour=9, - minute=30, + minute=31, second=0, microsecond=0, tzinfo=None @@ -197,7 +197,9 @@ Last successful date: %s" % self.market_open) open_utc = self.exchange_dt_in_utc(next_open) market_open = open_utc - market_close = market_open + self.get_trading_day_duration(open_utc) + market_close = (market_open + + self.get_trading_day_duration(open_utc) + - datetime.timedelta(minutes=1)) return market_open, market_close