mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-11 02:33:55 +00:00
Merge pull request #292 from jblestang/fix_pair_black_list
Bug in blacklist pair handling
This commit is contained in:
commit
208d3770da
|
@ -35,9 +35,12 @@ def refresh_whitelist(whitelist: List[str]) -> List[str]:
|
||||||
known_pairs = set()
|
known_pairs = set()
|
||||||
for status in health:
|
for status in health:
|
||||||
pair = '{}_{}'.format(_CONF['stake_currency'], status['Currency'])
|
pair = '{}_{}'.format(_CONF['stake_currency'], status['Currency'])
|
||||||
known_pairs.add(pair)
|
# pair is not int the generated dynamic market, or in the blacklist ... ignore it
|
||||||
if pair not in whitelist or pair in _CONF['exchange'].get('pair_blacklist', []):
|
if pair not in whitelist or pair in _CONF['exchange'].get('pair_blacklist', []):
|
||||||
continue
|
continue
|
||||||
|
# else the pair is valid
|
||||||
|
known_pairs.add(pair)
|
||||||
|
# Market is not active
|
||||||
if not status['IsActive']:
|
if not status['IsActive']:
|
||||||
sanitized_whitelist.remove(pair)
|
sanitized_whitelist.remove(pair)
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from freqtrade.main import refresh_whitelist
|
from freqtrade.main import refresh_whitelist, gen_pair_whitelist
|
||||||
|
|
||||||
# whitelist, blacklist, filtering, all of that will
|
# whitelist, blacklist, filtering, all of that will
|
||||||
# eventually become some rules to run on a generic ACL engine
|
# eventually become some rules to run on a generic ACL engine
|
||||||
|
@ -23,18 +23,65 @@ def whitelist_conf():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_market_summaries():
|
||||||
|
return [{
|
||||||
|
"MarketName": "BTC-TKN",
|
||||||
|
"High": 0.00000919,
|
||||||
|
"Low": 0.00000820,
|
||||||
|
"Volume": 74339.61396015,
|
||||||
|
"Last": 0.00000820,
|
||||||
|
"BaseVolume": 1664,
|
||||||
|
"TimeStamp": "2014-07-09T07:19:30.15",
|
||||||
|
"Bid": 0.00000820,
|
||||||
|
"Ask": 0.00000831,
|
||||||
|
"OpenBuyOrders": 15,
|
||||||
|
"OpenSellOrders": 15,
|
||||||
|
"PrevDay": 0.00000821,
|
||||||
|
"Created": "2014-03-20T06:00:00",
|
||||||
|
"DisplayMarketName": ""
|
||||||
|
}, {
|
||||||
|
"MarketName": "BTC-ETH",
|
||||||
|
"High": 0.00000072,
|
||||||
|
"Low": 0.00000001,
|
||||||
|
"Volume": 166340678.42280999,
|
||||||
|
"Last": 0.00000005,
|
||||||
|
"BaseVolume": 42,
|
||||||
|
"TimeStamp": "2014-07-09T07:21:40.51",
|
||||||
|
"Bid": 0.00000004,
|
||||||
|
"Ask": 0.00000005,
|
||||||
|
"OpenBuyOrders": 18,
|
||||||
|
"OpenSellOrders": 18,
|
||||||
|
"PrevDay": 0.00000002,
|
||||||
|
"Created": "2014-05-30T07:57:49.637",
|
||||||
|
"DisplayMarketName": ""
|
||||||
|
}, {
|
||||||
|
"MarketName": "BTC-BLK",
|
||||||
|
"High": 0.00000072,
|
||||||
|
"Low": 0.00000001,
|
||||||
|
"Volume": 166340678.42280999,
|
||||||
|
"Last": 0.00000005,
|
||||||
|
"BaseVolume": 3,
|
||||||
|
"TimeStamp": "2014-07-09T07:21:40.51",
|
||||||
|
"Bid": 0.00000004,
|
||||||
|
"Ask": 0.00000005,
|
||||||
|
"OpenBuyOrders": 18,
|
||||||
|
"OpenSellOrders": 18,
|
||||||
|
"PrevDay": 0.00000002,
|
||||||
|
"Created": "2014-05-30T07:57:49.637",
|
||||||
|
"DisplayMarketName": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_health():
|
def get_health():
|
||||||
return [{'Currency': 'ETH',
|
return [{'Currency': 'ETH',
|
||||||
'IsActive': True,
|
'IsActive': True
|
||||||
'BaseVolume': 42
|
|
||||||
},
|
},
|
||||||
{'Currency': 'TKN',
|
{'Currency': 'TKN',
|
||||||
'IsActive': True,
|
'IsActive': True
|
||||||
'BaseVolume': 1664
|
|
||||||
},
|
},
|
||||||
{'Currency': 'BLK',
|
{'Currency': 'BLK',
|
||||||
'IsActive': True,
|
'IsActive': True
|
||||||
'BaseVolume': 4096
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -72,9 +119,11 @@ def test_refresh_whitelist_dynamic(mocker):
|
||||||
mocker.patch.dict('freqtrade.main._CONF', conf)
|
mocker.patch.dict('freqtrade.main._CONF', conf)
|
||||||
mocker.patch.multiple('freqtrade.main.exchange',
|
mocker.patch.multiple('freqtrade.main.exchange',
|
||||||
get_wallet_health=get_health)
|
get_wallet_health=get_health)
|
||||||
|
mocker.patch.multiple('freqtrade.main.exchange',
|
||||||
|
get_market_summaries=get_market_summaries)
|
||||||
# argument: use the whitelist dynamically by exchange-volume
|
# argument: use the whitelist dynamically by exchange-volume
|
||||||
whitelist = ['BTC_TKN', 'BTC_ETH']
|
whitelist = ['BTC_TKN', 'BTC_ETH']
|
||||||
refreshedwhitelist = refresh_whitelist(whitelist)
|
refreshedwhitelist = refresh_whitelist(gen_pair_whitelist(conf['stake_currency']))
|
||||||
assert whitelist == refreshedwhitelist
|
assert whitelist == refreshedwhitelist
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user