From 339fa21c3592cbe3003a58b5e23e99b91d6b6b7e Mon Sep 17 00:00:00 2001 From: fredfortier Date: Wed, 18 Oct 2017 17:23:33 -0400 Subject: [PATCH] Fixed an issue with the backtest get_history_window method. --- catalyst/examples/simple_loop.py | 4 ++-- catalyst/exchange/data_portal_exchange.py | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/catalyst/examples/simple_loop.py b/catalyst/examples/simple_loop.py index 77415429..84ed01c5 100644 --- a/catalyst/examples/simple_loop.py +++ b/catalyst/examples/simple_loop.py @@ -7,7 +7,7 @@ from catalyst.api import symbol def initialize(context): print('initializing') - context.asset = symbol('wings_eth') + context.asset = symbol('etc_eth') def handle_data(context, data): @@ -35,7 +35,7 @@ run_algorithm( initialize=initialize, handle_data=handle_data, analyze=None, - exchange_name='bittrex', + exchange_name='poloniex', algo_namespace='simple_loop', base_currency='eth' ) diff --git a/catalyst/exchange/data_portal_exchange.py b/catalyst/exchange/data_portal_exchange.py index d7b163ac..b1b13dbc 100644 --- a/catalyst/exchange/data_portal_exchange.py +++ b/catalyst/exchange/data_portal_exchange.py @@ -24,7 +24,8 @@ from catalyst.exchange.exchange_errors import ( ExchangeRequestError, ExchangeBarDataError, PricingDataBeforeTradingError, - PricingDataNotLoadedError, InvalidHistoryFrequencyError) + PricingDataNotLoadedError, InvalidHistoryFrequencyError, + BundleNotFoundError) log = Logger('DataPortalExchange') @@ -297,13 +298,19 @@ class DataPortalExchangeBacktest(DataPortalExchangeBase): else: raise InvalidHistoryFrequencyError(frequency=data_frequency) + reader = bundle.get_reader(data_frequency) + if reader is None: + raise BundleNotFoundError( + exchange=exchange.name, + data_frequency=data_frequency + ) + try: - values = bundle.get_raw_arrays( - assets=assets, + values = reader.load_raw_arrays( + sids=[asset.sid for asset in assets], fields=[field], start_dt=dts[0], - end_dt=dts[-1], - data_frequency=data_frequency + end_dt=dts[-1] )[0] except Exception: