From d803d86f4d846ba8e67c2bde84b0de5efaea1ee6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 29 Oct 2019 06:53:26 +0100 Subject: [PATCH] Add low_price_percent_filter --- config_full.json.example | 3 ++- docs/configuration.md | 5 ++++- freqtrade/pairlist/VolumePairList.py | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/config_full.json.example b/config_full.json.example index a5af0f7a6..5ae8021d5 100644 --- a/config_full.json.example +++ b/config_full.json.example @@ -55,7 +55,8 @@ "config": { "number_assets": 20, "sort_key": "quoteVolume", - "precision_filter": true + "precision_filter": true, + "low_price_percent_filter": null } }, "exchange": { diff --git a/docs/configuration.md b/docs/configuration.md index 03f15e07d..c7e0dac31 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -426,6 +426,8 @@ section of the configuration. * By default, low-value coins that would not allow setting a stop loss are filtered out. (set `precision_filter` parameter to `false` to disable this behaviour). * `VolumePairList` does not consider `pair_whitelist`, but builds this automatically based the pairlist configuration. * Pairs in `pair_blacklist` are not considered for VolumePairList, even if all other filters would match. + * `low_price_percent_filter` allows filtering of pairs where a raise of 1 price unit is below the `low_price_percent_filter` ratio. + Calculation example: Min price precision is 8 decimals. If price is 0.00000011 - one step would be 0.00000012 - which is almost 10% higher than the previous value. Example: @@ -439,7 +441,8 @@ Example: "config": { "number_assets": 20, "sort_key": "quoteVolume", - "precision_filter": true + "precision_filter": true, + "low_price_percent_filter": 0.03 } }, ``` diff --git a/freqtrade/pairlist/VolumePairList.py b/freqtrade/pairlist/VolumePairList.py index 44dbd0ecf..4a6768efa 100644 --- a/freqtrade/pairlist/VolumePairList.py +++ b/freqtrade/pairlist/VolumePairList.py @@ -27,6 +27,8 @@ class VolumePairList(IPairList): self._number_pairs = self._whitelistconf['number_assets'] self._sort_key = self._whitelistconf.get('sort_key', 'quoteVolume') self._precision_filter = self._whitelistconf.get('precision_filter', True) + self._low_price_percent_filter = self._whitelistconf.get('low_price_percent_filter', None) + print(self._whitelistconf) if not self._freqtrade.exchange.exchange_has('fetchTickers'): raise OperationalException( @@ -77,6 +79,23 @@ class VolumePairList(IPairList): return False return True + def _validate_precision_filter_lowprice(self, ticker) -> bool: + """ + Check if if one price-step is > than a certain barrier. + :param ticker: ticker dict as returned from ccxt.load_markets() + :param precision: Precision + :return: True if the pair can stay, false if it should be removed + """ + precision = self._freqtrade.exchange.markets[ticker['symbol']]['precision']['price'] + + compare = ticker['last'] + 1 / pow(10, precision) + changeperc = (compare - ticker['last']) / ticker['last'] + if changeperc > self._low_price_percent_filter: + logger.info(f"Removed {ticker['symbol']} from whitelist, " + f"because 1 unit is {changeperc * 100:.3f}%") + return False + return True + @cached(TTLCache(maxsize=1, ttl=1800)) def _gen_pair_whitelist(self, base_currency: str, key: str) -> List[str]: """ @@ -106,6 +125,10 @@ class VolumePairList(IPairList): if (stoploss and self._precision_filter and not self._validate_precision_filter(t, stoploss)): valid_tickers.remove(t) + continue + if self._low_price_percent_filter and not self._validate_precision_filter_lowprice(t,): + valid_tickers.remove(t) + continue pairs = [s['symbol'] for s in valid_tickers] logger.info(f"Searching pairs: {pairs[:self._number_pairs]}")