Improve some typehints

This commit is contained in:
Matthias 2021-12-03 15:08:00 +01:00
parent 9421e6e61c
commit bead867940
5 changed files with 11 additions and 7 deletions

View File

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

View File

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

View File

@ -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')

View File

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

View File

@ -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')