BUG: for issue #159, improved frequency validation in live mode

This commit is contained in:
Frederic Fortier
2018-01-12 17:39:49 -05:00
parent 8a9b4e2df7
commit 020ec50258
3 changed files with 18 additions and 1 deletions
+10 -1
View File
@@ -18,7 +18,8 @@ from catalyst.exchange.exchange import Exchange
from catalyst.exchange.exchange_bundle import ExchangeBundle
from catalyst.exchange.exchange_errors import InvalidHistoryFrequencyError, \
ExchangeSymbolsNotFound, ExchangeRequestError, InvalidOrderStyle, \
ExchangeNotFoundError, CreateOrderError, InvalidHistoryTimeframeError
ExchangeNotFoundError, CreateOrderError, InvalidHistoryTimeframeError, \
UnsupportedHistoryFrequencyError
from catalyst.exchange.exchange_execution import ExchangeLimitOrder
from catalyst.exchange.utils.exchange_utils import mixin_market_params, \
from_ms_timestamp, get_epoch, get_exchange_folder, get_catalyst_symbol, \
@@ -378,6 +379,14 @@ class CCXT(Exchange):
symbols = self.get_symbols(assets)
timeframe = CCXT.get_timeframe(freq)
if timeframe not in self.api.timeframes:
freqs = [CCXT.get_frequency(t) for t in self.api.timeframes]
raise UnsupportedHistoryFrequencyError(
exchange=self.name,
freq=freq,
freqs=freqs,
)
ms = None
if start_dt is not None:
delta = start_dt - get_epoch()
@@ -291,6 +291,7 @@ class DataPortalExchangeBacktest(DataPortalExchangeBase):
DataFrame
"""
# TODO: verify that the exchange supports the timeframe
bundle = self.exchange_bundles[exchange_name] # type: ExchangeBundle
freq, candle_size, unit, adj_data_frequency = get_frequency(
+7
View File
@@ -100,6 +100,13 @@ class InvalidHistoryFrequencyError(ZiplineError):
).strip()
class UnsupportedHistoryFrequencyError(ZiplineError):
msg = (
'{exchange} does not support candle frequency {freq}, please choose '
'from: {freqs}.'
).strip()
class InvalidHistoryTimeframeError(ZiplineError):
msg = (
'CCXT timeframe {timeframe} not supported by the exchange.'