From ede847166373b9eac9c562ed9efff71f63a4cd92 Mon Sep 17 00:00:00 2001 From: fawce Date: Tue, 7 May 2013 18:44:44 -0400 Subject: [PATCH] BUG: Fix next trading calculation. If we are in a day beyond the historical data use the last close, instead. Relevant for trading current data. --- zipline/finance/performance.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index c5aa5bbc..b459d819 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -362,8 +362,11 @@ class PerformanceTracker(object): # increment the day counter before we move markers forward. self.day_count += 1.0 # move the market day markers forward - self.market_open, self.market_close = \ - trading.environment.next_open_and_close(self.market_open) + if self.market_close < trading.environment.last_trading_day: + _, self.market_close = \ + trading.environment.next_open_and_close(self.market_open) + else: + self.market_close = self.sim_params.last_close def handle_market_close(self): # add the return results from today to the list of DailyReturn objects.