From 581e81760309320d38c06e9fe23e898d7512872b Mon Sep 17 00:00:00 2001 From: jfkirk Date: Thu, 26 May 2016 15:58:48 -0400 Subject: [PATCH] MAINT: Rebase reconciliation --- tests/data/test_minute_bars.py | 17 ++++++++--------- tests/test_algorithm.py | 8 ++++---- tests/test_commissions.py | 2 +- tests/test_perf_tracking.py | 6 ++++-- zipline/gens/tradesimulation.py | 4 +++- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/tests/data/test_minute_bars.py b/tests/data/test_minute_bars.py index 7a233a8b..68e740c3 100644 --- a/tests/data/test_minute_bars.py +++ b/tests/data/test_minute_bars.py @@ -45,7 +45,11 @@ from zipline.data.minute_bars import ( ) from zipline.utils.calendars import get_calendar -from zipline.testing.fixtures import WithTradingSchedule, ZiplineTestCase +from zipline.testing.fixtures import ( + WithInstanceTmpDir, + WithTradingSchedule, + ZiplineTestCase, +) # Calendar is set to cover several half days, to check a case where half # days would be read out of order in cases of windows which spanned over @@ -54,7 +58,8 @@ TEST_CALENDAR_START = Timestamp('2014-06-02', tz='UTC') TEST_CALENDAR_STOP = Timestamp('2015-12-31', tz='UTC') -class BcolzMinuteBarTestCase(WithTradingSchedule, ZiplineTestCase): +class BcolzMinuteBarTestCase(WithTradingSchedule, WithInstanceTmpDir, + ZiplineTestCase): @classmethod def init_class_fixtures(cls): @@ -67,16 +72,10 @@ class BcolzMinuteBarTestCase(WithTradingSchedule, ZiplineTestCase): cls.test_calendar_start = cls.market_opens.index[0] cls.test_calendar_stop = cls.market_opens.index[-1] - def dir_cleanup(self): - self.dir_.cleanup() - def init_instance_fixtures(self): super(BcolzMinuteBarTestCase, self).init_instance_fixtures() - self.dir_ = TempDirectory() - self.dir_.create() - self.add_instance_callback(callback=self.dir_cleanup) - self.dest = self.dir_.getpath('minute_bars') + self.dest = self.instance_tmpdir.getpath('minute_bars') os.makedirs(self.dest) self.writer = BcolzMinuteBarWriter( TEST_CALENDAR_START, diff --git a/tests/test_algorithm.py b/tests/test_algorithm.py index 5d522a2d..99bb0604 100644 --- a/tests/test_algorithm.py +++ b/tests/test_algorithm.py @@ -1944,7 +1944,7 @@ class TestCapitalChanges(WithLogger, @classmethod def make_minute_bar_data(cls): - minutes = cls.env.minutes_for_days_in_range( + minutes = cls.trading_schedule.execution_minutes_for_days_in_range( pd.Timestamp('2006-01-03', tz='UTC'), pd.Timestamp('2006-01-09', tz='UTC') ) @@ -1956,14 +1956,14 @@ class TestCapitalChanges(WithLogger, [10000] * len(minutes), timedelta(minutes=1), cls.sim_params, - cls.env), + cls.trading_schedule), }, index=pd.DatetimeIndex(minutes), ) @classmethod def make_daily_bar_data(cls): - days = cls.env.days_in_range( + days = cls.trading_schedule.execution_days_in_range( pd.Timestamp('2006-01-03', tz='UTC'), pd.Timestamp('2006-01-09', tz='UTC') ) @@ -1975,7 +1975,7 @@ class TestCapitalChanges(WithLogger, [10000] * len(days), timedelta(days=1), cls.sim_params, - cls.env), + cls.trading_schedule), }, index=pd.DatetimeIndex(days), ) diff --git a/tests/test_commissions.py b/tests/test_commissions.py index 91bef5b3..a36d0d28 100644 --- a/tests/test_commissions.py +++ b/tests/test_commissions.py @@ -141,7 +141,7 @@ class CommissionAlgorithmTests(WithDataPortal, WithSimParams, ZiplineTestCase): [100.0] * num_days, timedelta(days=1), cls.sim_params, - cls.env, + trading_schedule=cls.trading_schedule, ), }, index=cls.sim_params.trading_days, diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index c1fcecfa..0fbd17a6 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -2234,11 +2234,12 @@ shares in position" [100, 100, 100, 100], oneday, self.sim_params, - env=self.env + trading_schedule=self.trading_schedule, ) data_portal = create_data_portal_from_trade_history( self.env, + self.trading_schedule, self.instance_tmpdir, self.sim_params, {1: trades}) @@ -2278,11 +2279,12 @@ shares in position" [100, 100, 100, 100], oneday, self.sim_params, - env=self.env + trading_schedule=self.trading_schedule, ) data_portal = create_data_portal_from_trade_history( self.env, + self.trading_schedule, self.instance_tmpdir, self.sim_params, {1: trades}) diff --git a/zipline/gens/tradesimulation.py b/zipline/gens/tradesimulation.py index 58381085..bcc23063 100644 --- a/zipline/gens/tradesimulation.py +++ b/zipline/gens/tradesimulation.py @@ -215,7 +215,9 @@ class AlgorithmSimulator(object): # perspective as we have technically not "advanced" to the # current dt yet. algo.perf_tracker.position_tracker.sync_last_sale_prices( - self.env.previous_market_minute(dt), + self.algo.trading_schedule.previous_execution_minute( + dt + ), False, self.data_portal )