Add low_price_percent_filter

This commit is contained in:
Matthias 2019-10-29 06:53:26 +01:00
parent d706571e6f
commit d803d86f4d
3 changed files with 29 additions and 2 deletions

View File

@ -55,7 +55,8 @@
"config": { "config": {
"number_assets": 20, "number_assets": 20,
"sort_key": "quoteVolume", "sort_key": "quoteVolume",
"precision_filter": true "precision_filter": true,
"low_price_percent_filter": null
} }
}, },
"exchange": { "exchange": {

View File

@ -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). * 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. * `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. * 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: Example:
@ -439,7 +441,8 @@ Example:
"config": { "config": {
"number_assets": 20, "number_assets": 20,
"sort_key": "quoteVolume", "sort_key": "quoteVolume",
"precision_filter": true "precision_filter": true,
"low_price_percent_filter": 0.03
} }
}, },
``` ```

View File

@ -27,6 +27,8 @@ class VolumePairList(IPairList):
self._number_pairs = self._whitelistconf['number_assets'] self._number_pairs = self._whitelistconf['number_assets']
self._sort_key = self._whitelistconf.get('sort_key', 'quoteVolume') self._sort_key = self._whitelistconf.get('sort_key', 'quoteVolume')
self._precision_filter = self._whitelistconf.get('precision_filter', True) 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'): if not self._freqtrade.exchange.exchange_has('fetchTickers'):
raise OperationalException( raise OperationalException(
@ -77,6 +79,23 @@ class VolumePairList(IPairList):
return False return False
return True 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)) @cached(TTLCache(maxsize=1, ttl=1800))
def _gen_pair_whitelist(self, base_currency: str, key: str) -> List[str]: 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 if (stoploss and self._precision_filter
and not self._validate_precision_filter(t, stoploss)): and not self._validate_precision_filter(t, stoploss)):
valid_tickers.remove(t) 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] pairs = [s['symbol'] for s in valid_tickers]
logger.info(f"Searching pairs: {pairs[:self._number_pairs]}") logger.info(f"Searching pairs: {pairs[:self._number_pairs]}")