Skip to content

Commit

Permalink
add mode to set the pairlist to blacklist additional to whitelist
Browse files Browse the repository at this point in the history
adhere to _number_pairs
  • Loading branch information
Bloodhunter4rc committed Jun 24, 2023
1 parent 6e143d4 commit 36b33fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/includes/pairlists.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ The RemotePairList is defined in the pairlists section of the configuration sett
"pairlists": [
{
"method": "RemotePairList",
"mode": "whitelist",
"pairlist_url": "https://example.com/pairlist",
"number_assets": 10,
"refresh_period": 1800,
Expand All @@ -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 user is responsible for providing a server or local file that returns a JSON object with the following structure:
Expand Down
24 changes: 22 additions & 2 deletions freqtrade/plugins/pairlist/RemotePairList.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, exchange, pairlistmanager,
'`pairlist_url` not specified. Please check your configuration '
'for "pairlist.config.pairlist_url"')

self._mode = self._pairlistconfig.get('mode', 'whitelist')
self._number_pairs = self._pairlistconfig['number_assets']
self._refresh_period: int = self._pairlistconfig.get('refresh_period', 1800)
self._keep_pairlist_on_failure = self._pairlistconfig.get('keep_pairlist_on_failure', True)
Expand Down Expand Up @@ -250,6 +251,25 @@ def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
:return: new whitelist
"""
rpl_pairlist = self.gen_pairlist(tickers)
merged_list = pairlist + rpl_pairlist
merged_list = sorted(set(merged_list), key=merged_list.index)
merged_list = []
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

0 comments on commit 36b33fb

Please sign in to comment.