reduce complexity of start_download_data() for flake8

This commit is contained in:
robcaulk 2022-09-25 21:34:58 +02:00
parent aca03e38f6
commit c31f322349

View File

@ -11,7 +11,7 @@ from freqtrade.data.history import (convert_trades_to_ohlcv, refresh_backtest_oh
refresh_backtest_trades_data)
from freqtrade.enums import CandleType, RunMode, TradingMode
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import market_is_active, timeframe_to_minutes
from freqtrade.exchange import Exchange, market_is_active, timeframe_to_minutes
from freqtrade.freqai.utils import setup_freqai_spice_rack
from freqtrade.plugins.pairlist.pairlist_helpers import dynamic_expand_pairlist, expand_pairlist
from freqtrade.resolvers import ExchangeResolver
@ -68,7 +68,19 @@ def start_download_data(args: Dict[str, Any]) -> None:
exchange.validate_timeframes(timeframe)
try:
pairs_not_available = download_trades(exchange, expanded_pairs, config, timerange)
except KeyboardInterrupt:
sys.exit("SIGINT received, aborting ...")
finally:
if pairs_not_available:
logger.info(f"Pairs [{','.join(pairs_not_available)}] not available "
f"on exchange {exchange.name}.")
def download_trades(exchange: Exchange, expanded_pairs: list,
config: Dict[str, Any], timerange: TimeRange) -> list:
if config.get('download_trades'):
if config.get('trading_mode') == 'futures':
raise OperationalException("Trade download not supported for futures.")
@ -100,13 +112,7 @@ def start_download_data(args: Dict[str, Any]) -> None:
prepend=config.get('prepend_data', False)
)
except KeyboardInterrupt:
sys.exit("SIGINT received, aborting ...")
finally:
if pairs_not_available:
logger.info(f"Pairs [{','.join(pairs_not_available)}] not available "
f"on exchange {exchange.name}.")
return pairs_not_available
def start_convert_trades(args: Dict[str, Any]) -> None: