separated hours_to_time to utils folder

This commit is contained in:
Sam Germain 2021-09-08 14:50:30 -06:00
parent 8bcd444775
commit cdefd15b28
7 changed files with 20 additions and 16 deletions

View File

@ -8,7 +8,7 @@ from freqtrade.exchange.binance import Binance
from freqtrade.exchange.bittrex import Bittrex from freqtrade.exchange.bittrex import Bittrex
from freqtrade.exchange.bybit import Bybit from freqtrade.exchange.bybit import Bybit
from freqtrade.exchange.coinbasepro import Coinbasepro 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, is_exchange_known_ccxt, is_exchange_officially_supported,
market_is_active, timeframe_to_minutes, timeframe_to_msecs, market_is_active, timeframe_to_minutes, timeframe_to_msecs,
timeframe_to_next_date, timeframe_to_prev_date, timeframe_to_next_date, timeframe_to_prev_date,

View File

@ -6,9 +6,9 @@ import ccxt
from datetime import time from datetime import time
from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException,
OperationalException, TemporaryError) OperationalException, TemporaryError)
from freqtrade.exchange import Exchange, hours_to_time from freqtrade.exchange import Exchange
from freqtrade.exchange.common import retrier from freqtrade.exchange.common import retrier
from freqtrade.utils import hours_to_time
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -1556,15 +1556,6 @@ class Exchange:
raise OperationalException(e) from e 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: def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool:
return exchange_name in ccxt_exchanges(ccxt_module) return exchange_name in ccxt_exchanges(ccxt_module)

View File

@ -6,10 +6,10 @@ import ccxt
from datetime import time from datetime import time
from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException,
OperationalException, TemporaryError) 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.exchange.common import API_FETCH_ORDER_RETRY_COUNT, retrier
from freqtrade.misc import safe_value_fallback2 from freqtrade.misc import safe_value_fallback2
from freqtrade.utils import hours_to_time
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -6,9 +6,9 @@ import ccxt
from datetime import time from datetime import time
from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException, from freqtrade.exceptions import (DDosProtection, InsufficientFundsError, InvalidOrderException,
OperationalException, TemporaryError) OperationalException, TemporaryError)
from freqtrade.exchange import Exchange, hours_to_time from freqtrade.exchange import Exchange
from freqtrade.exchange.common import retrier from freqtrade.exchange.common import retrier
from freqtrade.utils import hours_to_time
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -0,0 +1,2 @@
# flake8: noqa: F401
from freqtrade.utils.hours_to_time import hours_to_time

View File

@ -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]