From c7b422d46529626e49501d56bc7e1d8e925cf924 Mon Sep 17 00:00:00 2001 From: fredfortier Date: Sun, 22 Oct 2017 18:14:35 -0400 Subject: [PATCH] Fix to work around empty bundles --- catalyst/exchange/exchange_bundle.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/catalyst/exchange/exchange_bundle.py b/catalyst/exchange/exchange_bundle.py index 7aab5dc6..80fbf719 100644 --- a/catalyst/exchange/exchange_bundle.py +++ b/catalyst/exchange/exchange_bundle.py @@ -24,11 +24,13 @@ from catalyst.utils.paths import ensure_directory log = Logger('exchange_bundle', level=LOG_LEVEL) -BUNDLE_NAME_TEMPLATE = os.path.join('{root}','{frequency}_bundle') +BUNDLE_NAME_TEMPLATE = os.path.join('{root}', '{frequency}_bundle') + def _cachpath(symbol, type_): return '-'.join([symbol, type_]) + class ExchangeBundle: def __init__(self, exchange): self.exchange = exchange @@ -224,12 +226,18 @@ class ExchangeBundle: if reader is None: raise TempBundleNotFoundError(path=path) - arrays = reader.load_raw_arrays( - sids=[asset.sid], - fields=['open', 'high', 'low', 'close', 'volume'], - start_dt=start_dt, - end_dt=end_dt - ) + arrays = None + try: + arrays = reader.load_raw_arrays( + sids=[asset.sid], + fields=['open', 'high', 'low', 'close', 'volume'], + start_dt=start_dt, + end_dt=end_dt + ) + except Exception as e: + log.warn('skipping ctable for {} from {} to {}: {}'.format( + asset.symbol, start_dt, end_dt, e + )) if not arrays: return path @@ -318,8 +326,8 @@ class ExchangeBundle: except NoDataAvailableOnExchange: continue - start_dt = max(start_dt, self.calendar.first_trading_session) - start_dt = max(start_dt, asset_start) + # start_dt = max(start_dt, self.calendar.first_trading_session) + # start_dt = max(start_dt, asset_start) # Aligning start / end dates with the daily calendar sessions = get_periods_range(start_dt, end_dt, data_frequency) \