diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index 4b971394..a53b5f87 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -183,13 +183,21 @@ class TradingEnvironment(object): self.period_trading_days = None self.max_drawdown = max_drawdown + assert self.period_start <= self.period_end, \ + "Period start falls after period end." + for bm in benchmark_returns: self.trading_days.append(bm.date) self.trading_day_map[bm.date] = bm + assert self.period_start <= self.trading_days[-1], \ + "Period start falls after the last known trading day." + assert self.period_end >= self.trading_days[0], \ + "Period end falls before the first known trading day." + self.first_open = self.calculate_first_open() self.last_close = self.calculate_last_close() - + self.prior_day_open = self.calculate_prior_day_open() def calculate_first_open(self): diff --git a/zipline/gens/transform.py b/zipline/gens/transform.py index 33827448..c19501ee 100644 --- a/zipline/gens/transform.py +++ b/zipline/gens/transform.py @@ -161,9 +161,6 @@ class EventWindow: "Market-aware mode only works with full-day windows." self.all_holidays = deque(non_trading_days) self.cur_holidays = deque() - # Keeping a copy of days as a timedelta makes it easier - # to track holidays. - self.delta = timedelta(days=self.days) # Non-market-aware mode requires a timedelta. else: diff --git a/zipline/lines.py b/zipline/lines.py index 5bf786f3..419c5e93 100644 --- a/zipline/lines.py +++ b/zipline/lines.py @@ -181,7 +181,7 @@ class SimulatedTrading(object): else: log.warning("Sending SIGINT") os.kill(ppid, SIGINT) - + def handle_exception(self, exc): if isinstance(exc, CancelSignal): # signal from monitor of an orderly shutdown, @@ -208,9 +208,8 @@ class SimulatedTrading(object): exc_type.__name__, exc_value.message ) - + self.results_socket.send(msg) - except: log.exception("Exception while reporting simulation exception.")