Simplify precision_filter code
This commit is contained in:
parent
466a3b87fc
commit
4ff035537b
@ -55,7 +55,7 @@
|
|||||||
"config": {
|
"config": {
|
||||||
"number_assets": 20,
|
"number_assets": 20,
|
||||||
"sort_key": "quoteVolume",
|
"sort_key": "quoteVolume",
|
||||||
"precision_filter": false
|
"precision_filter": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exchange": {
|
"exchange": {
|
||||||
|
@ -423,8 +423,7 @@ section of the configuration.
|
|||||||
* `VolumePairList`
|
* `VolumePairList`
|
||||||
* It selects `number_assets` top pairs based on `sort_key`, which can be one of
|
* It selects `number_assets` top pairs based on `sort_key`, which can be one of
|
||||||
`askVolume`, `bidVolume` and `quoteVolume`, defaults to `quoteVolume`.
|
`askVolume`, `bidVolume` and `quoteVolume`, defaults to `quoteVolume`.
|
||||||
* There is a possibility to filter low-value coins that would not allow setting a stop loss
|
* 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).
|
||||||
(set `precision_filter` parameter to `true` for this).
|
|
||||||
* `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.
|
||||||
|
|
||||||
@ -440,7 +439,7 @@ Example:
|
|||||||
"config": {
|
"config": {
|
||||||
"number_assets": 20,
|
"number_assets": 20,
|
||||||
"sort_key": "quoteVolume",
|
"sort_key": "quoteVolume",
|
||||||
"precision_filter": false
|
"precision_filter": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
@ -26,7 +26,7 @@ class VolumePairList(IPairList):
|
|||||||
'for "pairlist.config.number_assets"')
|
'for "pairlist.config.number_assets"')
|
||||||
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', False)
|
self._precision_filter = self._whitelistconf.get('precision_filter', True)
|
||||||
|
|
||||||
if not self._freqtrade.exchange.exchange_has('fetchTickers'):
|
if not self._freqtrade.exchange.exchange_has('fetchTickers'):
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
@ -76,18 +76,19 @@ class VolumePairList(IPairList):
|
|||||||
valid_tickers = [t for t in sorted_tickers if t["symbol"] in valid_pairs]
|
valid_tickers = [t for t in sorted_tickers if t["symbol"] in valid_pairs]
|
||||||
|
|
||||||
if self._freqtrade.strategy.stoploss is not None and self._precision_filter:
|
if self._freqtrade.strategy.stoploss is not None and self._precision_filter:
|
||||||
|
# Precalculate correct stoploss value
|
||||||
|
stoploss = 1 - abs(self._freqtrade.strategy.stoploss)
|
||||||
|
|
||||||
stop_prices = [self._freqtrade.get_target_bid(t["symbol"], t)
|
|
||||||
* (1 - abs(self._freqtrade.strategy.stoploss)) for t in valid_tickers]
|
|
||||||
rates = [sp * 0.99 for sp in stop_prices]
|
|
||||||
logger.debug("\n".join([f"{sp} : {r}" for sp, r in zip(stop_prices[:10], rates[:10])]))
|
|
||||||
for i, t in enumerate(valid_tickers):
|
for i, t in enumerate(valid_tickers):
|
||||||
sp = self._freqtrade.exchange.symbol_price_prec(t["symbol"], stop_prices[i])
|
stop_price = (self._freqtrade.get_target_bid(t["symbol"], t) * stoploss)
|
||||||
r = self._freqtrade.exchange.symbol_price_prec(t["symbol"], rates[i])
|
# Adjust stop-prices to precision
|
||||||
logger.debug(f"{t['symbol']} - {sp} : {r}")
|
sp = self._freqtrade.exchange.symbol_price_prec(t["symbol"], stop_price)
|
||||||
if sp <= r:
|
stop_gap_price = self._freqtrade.exchange.symbol_price_prec(t["symbol"],
|
||||||
|
stop_price * 0.99)
|
||||||
|
logger.debug(f"{t['symbol']} - {sp} : {stop_gap_price}")
|
||||||
|
if sp <= stop_gap_price:
|
||||||
logger.info(f"Removed {t['symbol']} from whitelist, "
|
logger.info(f"Removed {t['symbol']} from whitelist, "
|
||||||
f"because stop price {sp} would be <= stop limit {r}")
|
f"because stop price {sp} would be <= stop limit {stop_gap_price}")
|
||||||
valid_tickers.remove(t)
|
valid_tickers.remove(t)
|
||||||
|
|
||||||
pairs = [s['symbol'] for s in valid_tickers]
|
pairs = [s['symbol'] for s in valid_tickers]
|
||||||
|
Loading…
Reference in New Issue
Block a user