add mode to set the pairlist to blacklist additional to whitelist
adhere to _number_pairs
This commit is contained in:
@@ -184,6 +184,7 @@ The RemotePairList is defined in the pairlists section of the configuration sett
|
|||||||
"pairlists": [
|
"pairlists": [
|
||||||
{
|
{
|
||||||
"method": "RemotePairList",
|
"method": "RemotePairList",
|
||||||
|
"mode": "whitelist",
|
||||||
"pairlist_url": "https://example.com/pairlist",
|
"pairlist_url": "https://example.com/pairlist",
|
||||||
"number_assets": 10,
|
"number_assets": 10,
|
||||||
"refresh_period": 1800,
|
"refresh_period": 1800,
|
||||||
@@ -194,6 +195,8 @@ The RemotePairList is defined in the pairlists section of the configuration sett
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `mode` option specifies if the pairlist should be used as a `blacklist` or as a `whitelist`. The default value is "whitelist".
|
||||||
|
|
||||||
The `pairlist_url` option specifies the URL of the remote server where the pairlist is located, or the path to a local file (if file:/// is prepended). This allows the user to use either a remote server or a local file as the source for the pairlist.
|
The `pairlist_url` option specifies the URL of the remote server where the pairlist is located, or the path to a local file (if file:/// is prepended). This allows the user to use either a remote server or a local file as the source for the pairlist.
|
||||||
|
|
||||||
The user is responsible for providing a server or local file that returns a JSON object with the following structure:
|
The user is responsible for providing a server or local file that returns a JSON object with the following structure:
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class RemotePairList(IPairList):
|
|||||||
'`pairlist_url` not specified. Please check your configuration '
|
'`pairlist_url` not specified. Please check your configuration '
|
||||||
'for "pairlist.config.pairlist_url"')
|
'for "pairlist.config.pairlist_url"')
|
||||||
|
|
||||||
|
self._mode = self._pairlistconfig.get('mode', 'whitelist')
|
||||||
self._number_pairs = self._pairlistconfig['number_assets']
|
self._number_pairs = self._pairlistconfig['number_assets']
|
||||||
self._refresh_period: int = self._pairlistconfig.get('refresh_period', 1800)
|
self._refresh_period: int = self._pairlistconfig.get('refresh_period', 1800)
|
||||||
self._keep_pairlist_on_failure = self._pairlistconfig.get('keep_pairlist_on_failure', True)
|
self._keep_pairlist_on_failure = self._pairlistconfig.get('keep_pairlist_on_failure', True)
|
||||||
@@ -250,6 +251,25 @@ class RemotePairList(IPairList):
|
|||||||
:return: new whitelist
|
:return: new whitelist
|
||||||
"""
|
"""
|
||||||
rpl_pairlist = self.gen_pairlist(tickers)
|
rpl_pairlist = self.gen_pairlist(tickers)
|
||||||
merged_list = pairlist + rpl_pairlist
|
merged_list = []
|
||||||
merged_list = sorted(set(merged_list), key=merged_list.index)
|
filtered = []
|
||||||
|
|
||||||
|
if self._mode == "whitelist":
|
||||||
|
merged_list = pairlist + rpl_pairlist
|
||||||
|
merged_list = sorted(set(merged_list), key=merged_list.index)
|
||||||
|
elif self._mode == "blacklist":
|
||||||
|
for pair in pairlist:
|
||||||
|
if pair not in rpl_pairlist:
|
||||||
|
merged_list.append(pair)
|
||||||
|
else:
|
||||||
|
filtered.append(pair)
|
||||||
|
if filtered:
|
||||||
|
self.log_once(f"Blacklist - Filtered out pairs: {filtered}", logger.info)
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise OperationalException(
|
||||||
|
'`mode` not configured correctly. Supported Modes: '
|
||||||
|
'are "whitelist","blacklist"')
|
||||||
|
|
||||||
|
merged_list = merged_list[:self._number_pairs]
|
||||||
return merged_list
|
return merged_list
|
||||||
|
|||||||
Reference in New Issue
Block a user