Improve ticker type
This commit is contained in:
parent
35f3f988d4
commit
52e9528361
@ -11,6 +11,7 @@ from freqtrade.enums import CandleType, MarginMode, TradingMode
|
||||
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.types import Tickers
|
||||
from freqtrade.misc import deep_merge_dicts, json_load
|
||||
|
||||
|
||||
@ -59,7 +60,7 @@ class Binance(Exchange):
|
||||
)
|
||||
))
|
||||
|
||||
def get_tickers(self, symbols: Optional[List[str]] = None, cached: bool = False) -> Dict:
|
||||
def get_tickers(self, symbols: Optional[List[str]] = None, cached: bool = False) -> Tickers:
|
||||
tickers = super().get_tickers(symbols=symbols, cached=cached)
|
||||
if self.trading_mode == TradingMode.FUTURES:
|
||||
# Binance's future result has no bid/ask values.
|
||||
|
@ -1,5 +1,16 @@
|
||||
from typing import Any, Dict
|
||||
from typing import Dict, Optional, TypedDict
|
||||
|
||||
|
||||
class Ticker(TypedDict):
|
||||
symbol: str
|
||||
ask: Optional[float]
|
||||
askVolume: Optional[float]
|
||||
bid: Optional[float]
|
||||
bidVolume: Optional[float]
|
||||
last: Optional[float]
|
||||
quoteVolume: Optional[float]
|
||||
baseVolume: Optional[float]
|
||||
# Several more - only listing required.
|
||||
|
||||
|
||||
Ticker = Dict[str, Any]
|
||||
Tickers = Dict[str, Ticker]
|
||||
|
@ -72,13 +72,13 @@ class PriceFilter(IPairList):
|
||||
:param ticker: ticker dict as returned from ccxt.fetch_ticker
|
||||
:return: True if the pair can stay, false if it should be removed
|
||||
"""
|
||||
if not ticker or ticker.get('last', None) is None or ticker.get('last') == 0:
|
||||
if ticker and 'last' in ticker and ticker['last'] is not None and ticker.get('last') != 0:
|
||||
price: float = ticker['last']
|
||||
else:
|
||||
self.log_once(f"Removed {pair} from whitelist, because "
|
||||
"ticker['last'] is empty (Usually no trade in the last 24h).",
|
||||
logger.info)
|
||||
return False
|
||||
else:
|
||||
price: float = ticker['last']
|
||||
|
||||
# Perform low_price_ratio check.
|
||||
if self._low_price_ratio != 0:
|
||||
|
Loading…
Reference in New Issue
Block a user