From eb6b7c08fc077d23a91d6cbcb7e209f9f502a9da Mon Sep 17 00:00:00 2001 From: Richard Frank Date: Sun, 24 Mar 2013 11:59:23 -0400 Subject: [PATCH] MAINT: Using zone attribute of tzinfo instead of string --- zipline/finance/trading.py | 2 +- zipline/utils/factory.py | 4 ++-- zipline/utils/tradingcalendar.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zipline/finance/trading.py b/zipline/finance/trading.py index a0ade9cd..dc907ad3 100644 --- a/zipline/finance/trading.py +++ b/zipline/finance/trading.py @@ -219,7 +219,7 @@ Last successful date: %s" % self.market_open) # create a new Delorean with the next_open naive date and # the correct timezone for the exchange. open_delorean = Delorean(next_open, self.exchange_tz) - open_utc = open_delorean.shift("UTC").datetime + open_utc = open_delorean.shift(pytz.utc.zone).datetime market_open = open_utc market_close = market_open + self.get_trading_day_duration(open_utc) diff --git a/zipline/utils/factory.py b/zipline/utils/factory.py index 2e89ea21..a73a091c 100644 --- a/zipline/utils/factory.py +++ b/zipline/utils/factory.py @@ -118,14 +118,14 @@ check treasury and benchmark data in findb, and re-run the test.""" def get_next_trading_dt(current, interval): naive = current.replace(tzinfo=None) - delo = Delorean(naive, "UTC") + delo = Delorean(naive, pytz.utc.zone) ex_tz = trading.environment.exchange_tz next_dt = delo.shift(ex_tz).datetime while True: next_dt = next_dt + interval next_delo = Delorean(next_dt.replace(tzinfo=None), ex_tz) - next_utc = next_delo.shift("UTC").datetime + next_utc = next_delo.shift(pytz.utc.zone).datetime if trading.environment.is_market_hours(next_utc): break diff --git a/zipline/utils/tradingcalendar.py b/zipline/utils/tradingcalendar.py index b2b30cab..77b6caea 100644 --- a/zipline/utils/tradingcalendar.py +++ b/zipline/utils/tradingcalendar.py @@ -22,8 +22,8 @@ from dateutil import rrule from delorean import Delorean start = datetime(1990, 1, 1, tzinfo=pytz.utc) -end_dln = Delorean(datetime.utcnow(), 'UTC') -end_dln.shift('US/Eastern').truncate('day').shift('UTC') +end_dln = Delorean(datetime.utcnow(), pytz.utc.zone) +end_dln.shift('US/Eastern').truncate('day').shift(pytz.utc.zone) end = end_dln.datetime - timedelta(days=1)