mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-06 05:14:38 +08:00
BUG: for issue #159, improved frequency validation in live mode
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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.'
|
||||
|
||||
Reference in New Issue
Block a user