move from name to name_list

This commit is contained in:
Matthias 2019-11-09 14:00:32 +01:00
parent 37985310d5
commit c74d766275
6 changed files with 27 additions and 17 deletions

View File

@ -67,7 +67,7 @@ class VolumePairList(IPairList):
""" """
# Generate dynamic whitelist # Generate dynamic whitelist
if self._last_refresh + self._ttl < datetime.now().timestamp(): if self._last_refresh + self._ttl < datetime.now().timestamp():
self._last_refresh = datetime.now().timestamp() self._last_refresh = int(datetime.now().timestamp())
return self._gen_pair_whitelist(pairlist, return self._gen_pair_whitelist(pairlist,
tickers, tickers,
self._config['stake_currency'], self._config['stake_currency'],

View File

@ -7,6 +7,7 @@ Provides lists as configured in config.json
import logging import logging
from typing import Dict, List from typing import Dict, List
from freqtrade import OperationalException
from freqtrade.pairlist.IPairList import IPairList from freqtrade.pairlist.IPairList import IPairList
from freqtrade.resolvers import PairListResolver from freqtrade.resolvers import PairListResolver
@ -22,12 +23,17 @@ class PairListManager():
self._blacklist = self._config['exchange'].get('pair_blacklist', []) self._blacklist = self._config['exchange'].get('pair_blacklist', [])
self._pairlists: List[IPairList] = [] self._pairlists: List[IPairList] = []
self._tickers_needed = False self._tickers_needed = False
for pl in self._config.get('pairlists', [{'method': "StaticPairList"}]): pairlists = self._config.get('pairlists', None)
if not pairlists:
pairlists = [{'method': "StaticPairList"}]
for pl in pairlists:
pairl = PairListResolver(pl.get('method'), pairl = PairListResolver(pl.get('method'),
exchange, self, config, exchange, self, config,
pl.get('config')).pairlist pl.get('config')).pairlist
self._tickers_needed = pairl.needstickers or self._tickers_needed self._tickers_needed = pairl.needstickers or self._tickers_needed
self._pairlists.append(pairl) self._pairlists.append(pairl)
if not self._pairlists:
raise OperationalException("No Pairlist defined!!")
@property @property
def whitelist(self) -> List[str]: def whitelist(self) -> List[str]:
@ -45,10 +51,11 @@ class PairListManager():
return self._blacklist return self._blacklist
@property @property
def name(self) -> str: def name_list(self) -> List[str]:
""" """
Get list of loaded pairlists names
""" """
return str([p.name for p in self._pairlists]) return [p.name for p in self._pairlists]
def short_desc(self) -> List[Dict]: def short_desc(self) -> List[Dict]:
""" """

View File

@ -469,7 +469,7 @@ class RPC:
def _rpc_whitelist(self) -> Dict: def _rpc_whitelist(self) -> Dict:
""" Returns the currently active whitelist""" """ Returns the currently active whitelist"""
res = {'method': self._freqtrade.pairlists.name, res = {'method': self._freqtrade.pairlists.name_list,
'length': len(self._freqtrade.active_pair_whitelist), 'length': len(self._freqtrade.active_pair_whitelist),
'whitelist': self._freqtrade.active_pair_whitelist 'whitelist': self._freqtrade.active_pair_whitelist
} }
@ -484,7 +484,7 @@ class RPC:
and pair not in self._freqtrade.pairlists.blacklist): and pair not in self._freqtrade.pairlists.blacklist):
self._freqtrade.pairlists.blacklist.append(pair) self._freqtrade.pairlists.blacklist.append(pair)
res = {'method': self._freqtrade.pairlists.name, res = {'method': self._freqtrade.pairlists.name_list,
'length': len(self._freqtrade.pairlists.blacklist), 'length': len(self._freqtrade.pairlists.blacklist),
'blacklist': self._freqtrade.pairlists.blacklist, 'blacklist': self._freqtrade.pairlists.blacklist,
} }

View File

@ -199,7 +199,7 @@ def test_pairlist_class(mocker, whitelist_conf, markets, pairlist):
) )
freqtrade = get_patched_freqtradebot(mocker, whitelist_conf) freqtrade = get_patched_freqtradebot(mocker, whitelist_conf)
assert freqtrade.pairlists.name == str([pairlist]) assert freqtrade.pairlists.name_list == [pairlist]
assert pairlist in str(freqtrade.pairlists.short_desc()) assert pairlist in str(freqtrade.pairlists.short_desc())
assert isinstance(freqtrade.pairlists.whitelist, list) assert isinstance(freqtrade.pairlists.whitelist, list)
assert isinstance(freqtrade.pairlists.blacklist, list) assert isinstance(freqtrade.pairlists.blacklist, list)

View File

@ -719,21 +719,23 @@ def test_rpc_whitelist(mocker, default_conf) -> None:
freqtradebot = get_patched_freqtradebot(mocker, default_conf) freqtradebot = get_patched_freqtradebot(mocker, default_conf)
rpc = RPC(freqtradebot) rpc = RPC(freqtradebot)
ret = rpc._rpc_whitelist() ret = rpc._rpc_whitelist()
assert ret['method'] == 'StaticPairList' assert len(ret['method']) == 1
assert 'StaticPairList' in ret['method']
assert ret['whitelist'] == default_conf['exchange']['pair_whitelist'] assert ret['whitelist'] == default_conf['exchange']['pair_whitelist']
def test_rpc_whitelist_dynamic(mocker, default_conf) -> None: def test_rpc_whitelist_dynamic(mocker, default_conf) -> None:
default_conf['pairlist'] = {'method': 'VolumePairList', default_conf['pairlists'] = [{'method': 'VolumePairList',
'config': {'number_assets': 4} 'config': {'number_assets': 4}
} }]
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock()) mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
freqtradebot = get_patched_freqtradebot(mocker, default_conf) freqtradebot = get_patched_freqtradebot(mocker, default_conf)
rpc = RPC(freqtradebot) rpc = RPC(freqtradebot)
ret = rpc._rpc_whitelist() ret = rpc._rpc_whitelist()
assert ret['method'] == 'VolumePairList' assert len(ret['method']) == 1
assert 'VolumePairList' in ret['method']
assert ret['length'] == 4 assert ret['length'] == 4
assert ret['whitelist'] == default_conf['exchange']['pair_whitelist'] assert ret['whitelist'] == default_conf['exchange']['pair_whitelist']
@ -744,13 +746,14 @@ def test_rpc_blacklist(mocker, default_conf) -> None:
freqtradebot = get_patched_freqtradebot(mocker, default_conf) freqtradebot = get_patched_freqtradebot(mocker, default_conf)
rpc = RPC(freqtradebot) rpc = RPC(freqtradebot)
ret = rpc._rpc_blacklist(None) ret = rpc._rpc_blacklist(None)
assert ret['method'] == 'StaticPairList' assert len(ret['method']) == 1
assert 'StaticPairList' in ret['method']
assert len(ret['blacklist']) == 2 assert len(ret['blacklist']) == 2
assert ret['blacklist'] == default_conf['exchange']['pair_blacklist'] assert ret['blacklist'] == default_conf['exchange']['pair_blacklist']
assert ret['blacklist'] == ['DOGE/BTC', 'HOT/BTC'] assert ret['blacklist'] == ['DOGE/BTC', 'HOT/BTC']
ret = rpc._rpc_blacklist(["ETH/BTC"]) ret = rpc._rpc_blacklist(["ETH/BTC"])
assert ret['method'] == 'StaticPairList' assert 'StaticPairList' in ret['method']
assert len(ret['blacklist']) == 3 assert len(ret['blacklist']) == 3
assert ret['blacklist'] == default_conf['exchange']['pair_blacklist'] assert ret['blacklist'] == default_conf['exchange']['pair_blacklist']
assert ret['blacklist'] == ['DOGE/BTC', 'HOT/BTC', 'ETH/BTC'] assert ret['blacklist'] == ['DOGE/BTC', 'HOT/BTC', 'ETH/BTC']

View File

@ -456,7 +456,7 @@ def test_api_blacklist(botclient, mocker):
assert_response(rc) assert_response(rc)
assert rc.json == {"blacklist": ["DOGE/BTC", "HOT/BTC"], assert rc.json == {"blacklist": ["DOGE/BTC", "HOT/BTC"],
"length": 2, "length": 2,
"method": "StaticPairList"} "method": ["StaticPairList"]}
# Add ETH/BTC to blacklist # Add ETH/BTC to blacklist
rc = client_post(client, f"{BASE_URI}/blacklist", rc = client_post(client, f"{BASE_URI}/blacklist",
@ -464,7 +464,7 @@ def test_api_blacklist(botclient, mocker):
assert_response(rc) assert_response(rc)
assert rc.json == {"blacklist": ["DOGE/BTC", "HOT/BTC", "ETH/BTC"], assert rc.json == {"blacklist": ["DOGE/BTC", "HOT/BTC", "ETH/BTC"],
"length": 3, "length": 3,
"method": "StaticPairList"} "method": ["StaticPairList"]}
def test_api_whitelist(botclient): def test_api_whitelist(botclient):
@ -474,7 +474,7 @@ def test_api_whitelist(botclient):
assert_response(rc) assert_response(rc)
assert rc.json == {"whitelist": ['ETH/BTC', 'LTC/BTC', 'XRP/BTC', 'NEO/BTC'], assert rc.json == {"whitelist": ['ETH/BTC', 'LTC/BTC', 'XRP/BTC', 'NEO/BTC'],
"length": 4, "length": 4,
"method": "StaticPairList"} "method": ["StaticPairList"]}
def test_api_forcebuy(botclient, mocker, fee): def test_api_forcebuy(botclient, mocker, fee):