From 4c9cf1321de88d0955c191d10d4ec89de5b5bf57 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Thu, 26 Jun 2014 17:17:08 -0400 Subject: [PATCH] PERF: Replace .ix usages with with .loc in TradingEnvironment. Replace usage of .ix in TradingEnvironment with .loc when we know that we're using an index key. DataFrame.ix can be used with either integer or key-based indices, and as such it incurs an overhead for figuring out which you meant. --- zipline/finance/trading.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index 62f392a0..8330bfca 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -125,7 +125,7 @@ class TradingEnvironment(object): self.early_closes = get_early_closes(self.first_trading_day, self.last_trading_day) - self.open_and_closes = env_trading_calendar.open_and_closes.ix[ + self.open_and_closes = env_trading_calendar.open_and_closes.loc[ self.trading_days] def __enter__(self, *args, **kwargs): @@ -256,7 +256,7 @@ Last successful date: %s" % self.last_trading_day) return self.previous_open_and_close(start)[1] def get_open_and_close(self, day): - todays_minutes = self.open_and_closes.ix[day.date()] + todays_minutes = self.open_and_closes.loc[day.date()] return todays_minutes['market_open'], todays_minutes['market_close']