Simplify tests
This commit is contained in:
parent
8e89802b2d
commit
0e416dc4f5
@ -202,21 +202,21 @@ def test_VolumePairList_refresh_empty(mocker, markets_empty, whitelist_conf):
|
|||||||
assert set(whitelist) == set(pairslist)
|
assert set(whitelist) == set(pairslist)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("pairlists,base_currency,whitelist_result,operational_exception", [
|
@pytest.mark.parametrize("pairlists,base_currency,whitelist_result", [
|
||||||
# VolumePairList only
|
# VolumePairList only
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}],
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC', 'HOT/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC', 'HOT/BTC']),
|
||||||
# Different sorting depending on quote or bid volume
|
# Different sorting depending on quote or bid volume
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "bidVolume"}],
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "bidVolume"}],
|
||||||
"BTC", ['HOT/BTC', 'FUEL/BTC', 'XRP/BTC', 'LTC/BTC', 'TKN/BTC'], False),
|
"BTC", ['HOT/BTC', 'FUEL/BTC', 'XRP/BTC', 'LTC/BTC', 'TKN/BTC']),
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}],
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}],
|
||||||
"USDT", ['ETH/USDT', 'NANO/USDT', 'ADAHALF/USDT'], False),
|
"USDT", ['ETH/USDT', 'NANO/USDT', 'ADAHALF/USDT']),
|
||||||
# No pair for ETH, VolumePairList
|
# No pair for ETH, VolumePairList
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}],
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}],
|
||||||
"ETH", [], False),
|
"ETH", []),
|
||||||
# No pair for ETH, StaticPairList
|
# No pair for ETH, StaticPairList
|
||||||
([{"method": "StaticPairList"}],
|
([{"method": "StaticPairList"}],
|
||||||
"ETH", [], False),
|
"ETH", []),
|
||||||
# No pair for ETH, all handlers
|
# No pair for ETH, all handlers
|
||||||
([{"method": "StaticPairList"},
|
([{"method": "StaticPairList"},
|
||||||
{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
@ -224,87 +224,87 @@ def test_VolumePairList_refresh_empty(mocker, markets_empty, whitelist_conf):
|
|||||||
{"method": "PriceFilter", "low_price_ratio": 0.03},
|
{"method": "PriceFilter", "low_price_ratio": 0.03},
|
||||||
{"method": "SpreadFilter", "max_spread_ratio": 0.005},
|
{"method": "SpreadFilter", "max_spread_ratio": 0.005},
|
||||||
{"method": "ShuffleFilter"}],
|
{"method": "ShuffleFilter"}],
|
||||||
"ETH", [], False),
|
"ETH", []),
|
||||||
# Precisionfilter and quote volume
|
# Precisionfilter and quote volume
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "PrecisionFilter"}],
|
{"method": "PrecisionFilter"}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC']),
|
||||||
# Precisionfilter bid
|
# Precisionfilter bid
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "bidVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "bidVolume"},
|
||||||
{"method": "PrecisionFilter"}],
|
{"method": "PrecisionFilter"}],
|
||||||
"BTC", ['FUEL/BTC', 'XRP/BTC', 'LTC/BTC', 'TKN/BTC'], False),
|
"BTC", ['FUEL/BTC', 'XRP/BTC', 'LTC/BTC', 'TKN/BTC']),
|
||||||
# PriceFilter and VolumePairList
|
# PriceFilter and VolumePairList
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "PriceFilter", "low_price_ratio": 0.03}],
|
{"method": "PriceFilter", "low_price_ratio": 0.03}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC']),
|
||||||
# PriceFilter and VolumePairList
|
# PriceFilter and VolumePairList
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "PriceFilter", "low_price_ratio": 0.03}],
|
{"method": "PriceFilter", "low_price_ratio": 0.03}],
|
||||||
"USDT", ['ETH/USDT', 'NANO/USDT'], False),
|
"USDT", ['ETH/USDT', 'NANO/USDT']),
|
||||||
# Hot is removed by precision_filter, Fuel by low_price_filter.
|
# Hot is removed by precision_filter, Fuel by low_price_filter.
|
||||||
([{"method": "VolumePairList", "number_assets": 6, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 6, "sort_key": "quoteVolume"},
|
||||||
{"method": "PrecisionFilter"},
|
{"method": "PrecisionFilter"},
|
||||||
{"method": "PriceFilter", "low_price_ratio": 0.02}],
|
{"method": "PriceFilter", "low_price_ratio": 0.02}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC']),
|
||||||
# HOT and XRP are removed because below 1250 quoteVolume
|
# HOT and XRP are removed because below 1250 quoteVolume
|
||||||
([{"method": "VolumePairList", "number_assets": 5,
|
([{"method": "VolumePairList", "number_assets": 5,
|
||||||
"sort_key": "quoteVolume", "min_value": 1250}],
|
"sort_key": "quoteVolume", "min_value": 1250}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC']),
|
||||||
# StaticPairlist only
|
# StaticPairlist only
|
||||||
([{"method": "StaticPairList"}],
|
([{"method": "StaticPairList"}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC', 'HOT/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'HOT/BTC']),
|
||||||
# Static Pairlist before VolumePairList - sorting changes
|
# Static Pairlist before VolumePairList - sorting changes
|
||||||
([{"method": "StaticPairList"},
|
([{"method": "StaticPairList"},
|
||||||
{"method": "VolumePairList", "number_assets": 5, "sort_key": "bidVolume"}],
|
{"method": "VolumePairList", "number_assets": 5, "sort_key": "bidVolume"}],
|
||||||
"BTC", ['HOT/BTC', 'TKN/BTC', 'ETH/BTC'], False),
|
"BTC", ['HOT/BTC', 'TKN/BTC', 'ETH/BTC']),
|
||||||
# SpreadFilter
|
# SpreadFilter
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "SpreadFilter", "max_spread_ratio": 0.005}],
|
{"method": "SpreadFilter", "max_spread_ratio": 0.005}],
|
||||||
"USDT", ['ETH/USDT'], False),
|
"USDT", ['ETH/USDT']),
|
||||||
# ShuffleFilter
|
# ShuffleFilter
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "ShuffleFilter", "seed": 77}],
|
{"method": "ShuffleFilter", "seed": 77}],
|
||||||
"USDT", ['ETH/USDT', 'ADAHALF/USDT', 'NANO/USDT'], False),
|
"USDT", ['ETH/USDT', 'ADAHALF/USDT', 'NANO/USDT']),
|
||||||
# ShuffleFilter, other seed
|
# ShuffleFilter, other seed
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "ShuffleFilter", "seed": 42}],
|
{"method": "ShuffleFilter", "seed": 42}],
|
||||||
"USDT", ['NANO/USDT', 'ETH/USDT', 'ADAHALF/USDT'], False),
|
"USDT", ['NANO/USDT', 'ETH/USDT', 'ADAHALF/USDT']),
|
||||||
# ShuffleFilter, no seed
|
# ShuffleFilter, no seed
|
||||||
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"},
|
||||||
{"method": "ShuffleFilter"}],
|
{"method": "ShuffleFilter"}],
|
||||||
"USDT", 3, False),
|
"USDT", 3), # whitelist_result is integer -- check only lenght of randomized pairlist
|
||||||
# PrecisionFilter after StaticPairList
|
# PrecisionFilter after StaticPairList
|
||||||
([{"method": "StaticPairList"},
|
([{"method": "StaticPairList"},
|
||||||
{"method": "PrecisionFilter"}],
|
{"method": "PrecisionFilter"}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC']),
|
||||||
# PrecisionFilter only
|
# PrecisionFilter only
|
||||||
([{"method": "PrecisionFilter"}],
|
([{"method": "PrecisionFilter"}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC'], True),
|
"BTC", None), # OperationalException expected
|
||||||
# PriceFilter after StaticPairList
|
# PriceFilter after StaticPairList
|
||||||
([{"method": "StaticPairList"},
|
([{"method": "StaticPairList"},
|
||||||
{"method": "PriceFilter", "low_price_ratio": 0.02}],
|
{"method": "PriceFilter", "low_price_ratio": 0.02}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC']),
|
||||||
# PriceFilter only
|
# PriceFilter only
|
||||||
([{"method": "PriceFilter", "low_price_ratio": 0.02}],
|
([{"method": "PriceFilter", "low_price_ratio": 0.02}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC'], True),
|
"BTC", None), # OperationalException expected
|
||||||
# ShuffleFilter after StaticPairList
|
# ShuffleFilter after StaticPairList
|
||||||
([{"method": "StaticPairList"},
|
([{"method": "StaticPairList"},
|
||||||
{"method": "ShuffleFilter", "seed": 42}],
|
{"method": "ShuffleFilter", "seed": 42}],
|
||||||
"BTC", ['TKN/BTC', 'ETH/BTC', 'HOT/BTC'], False),
|
"BTC", ['TKN/BTC', 'ETH/BTC', 'HOT/BTC']),
|
||||||
# ShuffleFilter only
|
# ShuffleFilter only
|
||||||
([{"method": "ShuffleFilter", "seed": 42}],
|
([{"method": "ShuffleFilter", "seed": 42}],
|
||||||
"BTC", ['TKN/BTC', 'ETH/BTC', 'HOT/BTC'], True),
|
"BTC", None), # OperationalException expected
|
||||||
# SpreadFilter after StaticPairList
|
# SpreadFilter after StaticPairList
|
||||||
([{"method": "StaticPairList"},
|
([{"method": "StaticPairList"},
|
||||||
{"method": "SpreadFilter", "max_spread_ratio": 0.005}],
|
{"method": "SpreadFilter", "max_spread_ratio": 0.005}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC'], False),
|
"BTC", ['ETH/BTC', 'TKN/BTC']),
|
||||||
# SpreadFilter only
|
# SpreadFilter only
|
||||||
([{"method": "SpreadFilter", "max_spread_ratio": 0.005}],
|
([{"method": "SpreadFilter", "max_spread_ratio": 0.005}],
|
||||||
"BTC", ['ETH/BTC', 'TKN/BTC'], True),
|
"BTC", None), # OperationalException expected
|
||||||
])
|
])
|
||||||
def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, tickers,
|
def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, tickers,
|
||||||
pairlists, base_currency, whitelist_result,
|
pairlists, base_currency, whitelist_result,
|
||||||
operational_exception, caplog) -> None:
|
caplog) -> None:
|
||||||
whitelist_conf['pairlists'] = pairlists
|
whitelist_conf['pairlists'] = pairlists
|
||||||
whitelist_conf['stake_currency'] = base_currency
|
whitelist_conf['stake_currency'] = base_currency
|
||||||
|
|
||||||
@ -316,7 +316,8 @@ def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, t
|
|||||||
markets=PropertyMock(return_value=shitcoinmarkets),
|
markets=PropertyMock(return_value=shitcoinmarkets),
|
||||||
)
|
)
|
||||||
|
|
||||||
if operational_exception:
|
# Set whitelist_result to None if pairlist is invalid and should produce exception
|
||||||
|
if whitelist_result is None:
|
||||||
with pytest.raises(OperationalException,
|
with pytest.raises(OperationalException,
|
||||||
match=r"This Pairlist Handler should not be used at the first position "
|
match=r"This Pairlist Handler should not be used at the first position "
|
||||||
r"in the list of Pairlist Handlers."):
|
r"in the list of Pairlist Handlers."):
|
||||||
|
Loading…
Reference in New Issue
Block a user