Improve price handling in priceFilter

This commit is contained in:
Matthias 2022-10-11 19:33:05 +00:00
parent afaca2167c
commit 35f3f988d4

View File

@ -77,11 +77,13 @@ class PriceFilter(IPairList):
"ticker['last'] is empty (Usually no trade in the last 24h).", "ticker['last'] is empty (Usually no trade in the last 24h).",
logger.info) logger.info)
return False return False
else:
price: float = ticker['last']
# Perform low_price_ratio check. # Perform low_price_ratio check.
if self._low_price_ratio != 0: if self._low_price_ratio != 0:
compare = self._exchange.price_get_one_pip(pair, ticker['last']) compare = self._exchange.price_get_one_pip(pair, price)
changeperc = compare / ticker['last'] changeperc = compare / price
if changeperc > self._low_price_ratio: if changeperc > self._low_price_ratio:
self.log_once(f"Removed {pair} from whitelist, " self.log_once(f"Removed {pair} from whitelist, "
f"because 1 unit is {changeperc:.3%}", logger.info) f"because 1 unit is {changeperc:.3%}", logger.info)
@ -89,7 +91,6 @@ class PriceFilter(IPairList):
# Perform low_amount check # Perform low_amount check
if self._max_value != 0: if self._max_value != 0:
price = ticker['last']
market = self._exchange.markets[pair] market = self._exchange.markets[pair]
limits = market['limits'] limits = market['limits']
if (limits['amount']['min'] is not None): if (limits['amount']['min'] is not None):
@ -114,14 +115,14 @@ class PriceFilter(IPairList):
# Perform min_price check. # Perform min_price check.
if self._min_price != 0: if self._min_price != 0:
if ticker['last'] < self._min_price: if price < self._min_price:
self.log_once(f"Removed {pair} from whitelist, " self.log_once(f"Removed {pair} from whitelist, "
f"because last price < {self._min_price:.8f}", logger.info) f"because last price < {self._min_price:.8f}", logger.info)
return False return False
# Perform max_price check. # Perform max_price check.
if self._max_price != 0: if self._max_price != 0:
if ticker['last'] > self._max_price: if price > self._max_price:
self.log_once(f"Removed {pair} from whitelist, " self.log_once(f"Removed {pair} from whitelist, "
f"because last price > {self._max_price:.8f}", logger.info) f"because last price > {self._max_price:.8f}", logger.info)
return False return False