diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index 138c02647..b0c88a51a 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -8,7 +8,7 @@ from freqtrade.exchange.binance import Binance from freqtrade.exchange.bittrex import Bittrex from freqtrade.exchange.bybit import Bybit from freqtrade.exchange.coinbasepro import Coinbasepro -from freqtrade.exchange.exchange import (available_exchanges, ccxt_exchanges, hours_to_time, +from freqtrade.exchange.exchange import (available_exchanges, ccxt_exchanges, is_exchange_known_ccxt, is_exchange_officially_supported, market_is_active, timeframe_to_minutes, timeframe_to_msecs, timeframe_to_next_date, timeframe_to_prev_date, diff --git a/freqtrade/exchange/binance.py b/freqtrade/exchange/binance.py index 9be06e94d..cb18b7f8e 100644 --- a/freqtrade/exchange/binance.py +++ b/freqtrade/exchange/binance.py @@ -6,9 +6,9 @@ import ccxt from datetime import time from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) -from freqtrade.exchange import Exchange, hours_to_time +from freqtrade.exchange import Exchange from freqtrade.exchange.common import retrier - +from freqtrade.utils import hours_to_time logger = logging.getLogger(__name__) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 358fab6c4..df1bf28f3 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1556,15 +1556,6 @@ class Exchange: raise OperationalException(e) from e -def hours_to_time(hours: List[int]) -> List[time]: - ''' - :param hours: a list of hours as a time of day (e.g. [1, 16] is 01:00 and 16:00 o'clock) - :return: a list of datetime time objects that correspond to the hours in hours - ''' - # TODO-lev: These must be utc time - return [datetime.strptime(str(t), '%H').time() for t in hours] - - def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool: return exchange_name in ccxt_exchanges(ccxt_module) diff --git a/freqtrade/exchange/ftx.py b/freqtrade/exchange/ftx.py index 6f5c28e58..5b7a9ffeb 100644 --- a/freqtrade/exchange/ftx.py +++ b/freqtrade/exchange/ftx.py @@ -6,10 +6,10 @@ import ccxt from datetime import time from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) -from freqtrade.exchange import Exchange, hours_to_time +from freqtrade.exchange import Exchange from freqtrade.exchange.common import API_FETCH_ORDER_RETRY_COUNT, retrier from freqtrade.misc import safe_value_fallback2 - +from freqtrade.utils import hours_to_time logger = logging.getLogger(__name__) diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index d69ac9e33..6aaf00214 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -6,9 +6,9 @@ import ccxt from datetime import time from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, OperationalException, TemporaryError) -from freqtrade.exchange import Exchange, hours_to_time +from freqtrade.exchange import Exchange from freqtrade.exchange.common import retrier - +from freqtrade.utils import hours_to_time logger = logging.getLogger(__name__) diff --git a/freqtrade/utils/__init__.py b/freqtrade/utils/__init__.py new file mode 100644 index 000000000..e6e76c589 --- /dev/null +++ b/freqtrade/utils/__init__.py @@ -0,0 +1,2 @@ +# flake8: noqa: F401 +from freqtrade.utils.hours_to_time import hours_to_time diff --git a/freqtrade/utils/hours_to_time.py b/freqtrade/utils/hours_to_time.py new file mode 100644 index 000000000..139fd83a1 --- /dev/null +++ b/freqtrade/utils/hours_to_time.py @@ -0,0 +1,11 @@ +from datetime import datetime, time +from typing import List + + +def hours_to_time(hours: List[int]) -> List[time]: + ''' + :param hours: a list of hours as a time of day (e.g. [1, 16] is 01:00 and 16:00 o'clock) + :return: a list of datetime time objects that correspond to the hours in hours + ''' + # TODO-lev: These must be utc time + return [datetime.strptime(str(t), '%H').time() for t in hours]