num_assets should be optional

This commit is contained in:
Matthias 2022-09-25 09:38:20 +02:00
parent 4940fa7be3
commit 527fd36134

View File

@ -32,7 +32,7 @@ class ProducerPairList(IPairList):
pairlist_pos: int) -> None: pairlist_pos: int) -> None:
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos) super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
self._num_assets = self._pairlistconfig.get('number_assets') self._num_assets: int = self._pairlistconfig.get('number_assets', 0)
self._producer_name = self._pairlistconfig.get('producer_name', 'default') self._producer_name = self._pairlistconfig.get('producer_name', 'default')
if config.get('external_message_consumer').get('enabled') is False: if config.get('external_message_consumer').get('enabled') is False:
raise ValueError("ProducerPairList requires external_message_consumer to be enabled.") raise ValueError("ProducerPairList requires external_message_consumer to be enabled.")
@ -60,7 +60,9 @@ class ProducerPairList(IPairList):
if pairlist is None: if pairlist is None:
pairlist = self._pairlistmanager._dataprovider.get_producer_pairs(self._producer_name) pairlist = self._pairlistmanager._dataprovider.get_producer_pairs(self._producer_name)
pairs = list(dict.fromkeys(upstream_pairlist + pairlist))[:self._num_assets] pairs = list(dict.fromkeys(upstream_pairlist + pairlist))
if self._num_assets:
pairs = pairs[:self._num_assets]
return pairs return pairs