From bead867940f73bb4566db32bed67f5d7575b9db0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 3 Dec 2021 15:08:00 +0100 Subject: [PATCH] Improve some typehints --- freqtrade/exchange/exchange.py | 4 +--- freqtrade/plugins/pairlist/AgeFilter.py | 3 ++- freqtrade/plugins/pairlist/VolatilityFilter.py | 4 +++- freqtrade/plugins/pairlist/VolumePairList.py | 3 ++- freqtrade/plugins/pairlist/rangestabilityfilter.py | 4 +++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 7ebf96619..e8e1f98c8 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1388,8 +1388,7 @@ class Exchange: return pair, timeframe, candle_type, data def refresh_latest_ohlcv(self, pair_list: ListPairsWithTimeframes, *, - since_ms: Optional[int] = None, cache: bool = True, - candle_type: CandleType = CandleType.SPOT_ + since_ms: Optional[int] = None, cache: bool = True ) -> Dict[PairWithTimeframe, DataFrame]: """ Refresh in-memory OHLCV asynchronously and set `_klines` with the result @@ -1398,7 +1397,6 @@ class Exchange: :param pair_list: List of 2 element tuples containing pair, interval to refresh :param since_ms: time since when to download, in milliseconds :param cache: Assign result to _klines. Usefull for one-off downloads like for pairlists - :param candle_type: '', mark, index, premiumIndex, or funding_rate :return: Dict of [{(pair, timeframe): Dataframe}] """ logger.debug("Refreshing candle (OHLCV) data for %d pairs", len(pair_list)) diff --git a/freqtrade/plugins/pairlist/AgeFilter.py b/freqtrade/plugins/pairlist/AgeFilter.py index de7e26336..7c490d920 100644 --- a/freqtrade/plugins/pairlist/AgeFilter.py +++ b/freqtrade/plugins/pairlist/AgeFilter.py @@ -9,6 +9,7 @@ import arrow from pandas import DataFrame from freqtrade.configuration import PeriodicCache +from freqtrade.constants import ListPairsWithTimeframes from freqtrade.enums import CandleType from freqtrade.exceptions import OperationalException from freqtrade.misc import plural @@ -72,7 +73,7 @@ class AgeFilter(IPairList): :param tickers: Tickers (from exchange.get_tickers()). May be cached. :return: new allowlist """ - needed_pairs = [ + needed_pairs: ListPairsWithTimeframes = [ (p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._symbolsChecked and p not in self._symbolsCheckFailed] if not needed_pairs: diff --git a/freqtrade/plugins/pairlist/VolatilityFilter.py b/freqtrade/plugins/pairlist/VolatilityFilter.py index 299ea8c18..bdb7a043a 100644 --- a/freqtrade/plugins/pairlist/VolatilityFilter.py +++ b/freqtrade/plugins/pairlist/VolatilityFilter.py @@ -11,6 +11,7 @@ import numpy as np from cachetools.ttl import TTLCache from pandas import DataFrame +from freqtrade.constants import ListPairsWithTimeframes from freqtrade.enums import CandleType from freqtrade.exceptions import OperationalException from freqtrade.misc import plural @@ -68,7 +69,8 @@ class VolatilityFilter(IPairList): :param tickers: Tickers (from exchange.get_tickers()). May be cached. :return: new allowlist """ - needed_pairs = [(p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._pair_cache] + needed_pairs: ListPairsWithTimeframes = [ + (p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._pair_cache] since_ms = (arrow.utcnow() .floor('day') diff --git a/freqtrade/plugins/pairlist/VolumePairList.py b/freqtrade/plugins/pairlist/VolumePairList.py index 7c9c9933a..b81a5db5c 100644 --- a/freqtrade/plugins/pairlist/VolumePairList.py +++ b/freqtrade/plugins/pairlist/VolumePairList.py @@ -10,6 +10,7 @@ from typing import Any, Dict, List import arrow from cachetools.ttl import TTLCache +from freqtrade.constants import ListPairsWithTimeframes from freqtrade.enums import CandleType from freqtrade.exceptions import OperationalException from freqtrade.exchange import timeframe_to_minutes @@ -160,7 +161,7 @@ class VolumePairList(IPairList): self.log_once(f"Using volume range of {self._lookback_period} candles, timeframe: " f"{self._lookback_timeframe}, starting from {format_ms_time(since_ms)} " f"till {format_ms_time(to_ms)}", logger.info) - needed_pairs = [ + needed_pairs: ListPairsWithTimeframes = [ (p, self._lookback_timeframe, CandleType.SPOT_) for p in [s['symbol'] for s in filtered_tickers] if p not in self._pair_cache diff --git a/freqtrade/plugins/pairlist/rangestabilityfilter.py b/freqtrade/plugins/pairlist/rangestabilityfilter.py index 31d92d41b..3e90400a6 100644 --- a/freqtrade/plugins/pairlist/rangestabilityfilter.py +++ b/freqtrade/plugins/pairlist/rangestabilityfilter.py @@ -9,6 +9,7 @@ import arrow from cachetools.ttl import TTLCache from pandas import DataFrame +from freqtrade.constants import ListPairsWithTimeframes from freqtrade.enums import CandleType from freqtrade.exceptions import OperationalException from freqtrade.misc import plural @@ -66,7 +67,8 @@ class RangeStabilityFilter(IPairList): :param tickers: Tickers (from exchange.get_tickers()). May be cached. :return: new allowlist """ - needed_pairs = [(p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._pair_cache] + needed_pairs: ListPairsWithTimeframes = [ + (p, '1d', CandleType.SPOT_) for p in pairlist if p not in self._pair_cache] since_ms = (arrow.utcnow() .floor('day')