From 17e390a379e5ea37378fe16efa36596f87340336 Mon Sep 17 00:00:00 2001 From: Jean Bredeche Date: Tue, 2 Aug 2016 13:52:08 -0400 Subject: [PATCH] ENH: Read asset's exchange directly --- zipline/assets/_assets.pyx | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/zipline/assets/_assets.pyx b/zipline/assets/_assets.pyx index 1fe11e1f..de5011ac 100644 --- a/zipline/assets/_assets.pyx +++ b/zipline/assets/_assets.pyx @@ -40,19 +40,8 @@ from zipline.utils.calendars import get_calendar # IMPORTANT NOTE: You must change this template if you change # Asset.__reduce__, or else we'll attempt to unpickle an old version of this # class -from pandas.tslib import normalize_date - CACHE_FILE_TEMPLATE = '/tmp/.%s-%s.v6.cache' -FUTURE_EXCHANGE_MAPPING = { - "CFE": "CFE", - "CBOT": "CME", - "CME": "CME", - "COMEX": "CME", - "NYMEX": "CME", - "ICEUS": "ICE", - "NYFE": "ICE" -} cdef class Asset: @@ -231,27 +220,9 @@ cdef class Asset: ------- boolean: whether the asset's exchange is open at the given minute. """ - calendar = self.exchange_trading_calendar() + calendar = get_calendar(self.exchange) return calendar.is_open_on_minute(dt_minute) - def exchange_trading_calendar(self): - """ - Get the calendar for this asset's exchange. - - Raises KeyError if the asset's exchange calendar cannot be found. - - Returns - ------- - The asset's exchange's trading calendar. - """ - if isinstance(self, Equity): - # FIXME: probably too Quantopian-specific - return get_calendar("NYSE") - else: - asset_exchange_str = self.exchange - calendar_str = FUTURE_EXCHANGE_MAPPING[asset_exchange_str] - return get_calendar(calendar_str) - cdef class Equity(Asset):