switch "mode" into "pairs_exist_on"
This commit is contained in:
@@ -20,7 +20,7 @@ class CrossMarketPairList(IPairList):
|
|||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self._mode: str = self._pairlistconfig.get("mode", "whitelist")
|
self._pairs_exist_on: str = self._pairlistconfig.get("pairs_exist_on", "both_markets")
|
||||||
self._stake_currency: str = self._config["stake_currency"]
|
self._stake_currency: str = self._config["stake_currency"]
|
||||||
self._target_mode = "spot" if self._config["trading_mode"] == "futures" else "futures"
|
self._target_mode = "spot" if self._config["trading_mode"] == "futures" else "futures"
|
||||||
self._refresh_period = self._pairlistconfig.get("refresh_period", 1800)
|
self._refresh_period = self._pairlistconfig.get("refresh_period", 1800)
|
||||||
@@ -39,24 +39,23 @@ class CrossMarketPairList(IPairList):
|
|||||||
"""
|
"""
|
||||||
Short whitelist method description - used for startup-messages
|
Short whitelist method description - used for startup-messages
|
||||||
"""
|
"""
|
||||||
mode = self._mode
|
pairs_exist_on = self._pairs_exist_on
|
||||||
target_mode = self._target_mode
|
msg = f"{self.name} - Pairs that exists on {pairs_exist_on.capitalize()}."
|
||||||
msg = f"{self.name} - {mode.capitalize()} pairs that exists on {target_mode} market."
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def description() -> str:
|
def description() -> str:
|
||||||
return "Filter pairs if they exist on another market."
|
return "Filter pairs if they exist or not on another market."
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def available_parameters() -> dict[str, PairlistParameter]:
|
def available_parameters() -> dict[str, PairlistParameter]:
|
||||||
return {
|
return {
|
||||||
"mode": {
|
"pairs_exist_on": {
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"default": "whitelist",
|
"default": "both_markets",
|
||||||
"options": ["whitelist", "blacklist"],
|
"options": ["current_market_only", "both_markets"],
|
||||||
"description": "Mode of operation",
|
"description": "Mode of operation",
|
||||||
"help": "Mode of operation (whitelist/blacklist)",
|
"help": "Mode of operation (current_market_only/both_markets)",
|
||||||
},
|
},
|
||||||
**IPairList.refresh_period_parameter(),
|
**IPairList.refresh_period_parameter(),
|
||||||
}
|
}
|
||||||
@@ -67,7 +66,7 @@ class CrossMarketPairList(IPairList):
|
|||||||
futures_only = True if target_mode == "futures" else False
|
futures_only = True if target_mode == "futures" else False
|
||||||
bases = [
|
bases = [
|
||||||
v.get("base", "")
|
v.get("base", "")
|
||||||
for k, v in self._exchange.get_markets(
|
for _, v in self._exchange.get_markets(
|
||||||
quote_currencies=[self._stake_currency],
|
quote_currencies=[self._stake_currency],
|
||||||
tradable_only=False,
|
tradable_only=False,
|
||||||
active_only=True,
|
active_only=True,
|
||||||
@@ -108,7 +107,8 @@ class CrossMarketPairList(IPairList):
|
|||||||
|
|
||||||
def filter_pairlist(self, pairlist: list[str], tickers: Tickers) -> list[str]:
|
def filter_pairlist(self, pairlist: list[str], tickers: Tickers) -> list[str]:
|
||||||
bases = self.get_base_list()
|
bases = self.get_base_list()
|
||||||
is_whitelist_mode = self._mode == "whitelist"
|
pairs_exist_on = self._pairs_exist_on
|
||||||
|
is_whitelist_mode = pairs_exist_on == "both_markets"
|
||||||
whitelisted_pairlist: list[str] = []
|
whitelisted_pairlist: list[str] = []
|
||||||
filtered_pairlist = pairlist.copy()
|
filtered_pairlist = pairlist.copy()
|
||||||
|
|
||||||
|
|||||||
@@ -2589,68 +2589,68 @@ def test_MarketCapPairList_exceptions(mocker, default_conf_usdt, caplog):
|
|||||||
[
|
[
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# Whitelist mode on spot
|
# Spot pairs that exist on both markets
|
||||||
{"method": "StaticPairList", "allow_inactive": True},
|
{"method": "StaticPairList", "allow_inactive": True},
|
||||||
{"method": "CrossMarketPairList", "mode": "whitelist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"},
|
||||||
],
|
],
|
||||||
"spot",
|
"spot",
|
||||||
["ETH/USDT"],
|
["ETH/USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# Blacklist mode on spot
|
# Spot pairs that exist only on spot market
|
||||||
{"method": "StaticPairList", "allow_inactive": True},
|
{"method": "StaticPairList", "allow_inactive": True},
|
||||||
{"method": "CrossMarketPairList", "mode": "blacklist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "current_market_only"},
|
||||||
],
|
],
|
||||||
"spot",
|
"spot",
|
||||||
["LTC/USDT", "XRP/USDT", "NEO/USDT", "TKN/USDT", "BTC/USDT"],
|
["LTC/USDT", "XRP/USDT", "NEO/USDT", "TKN/USDT", "BTC/USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# Whitelist mode on futures
|
# Futures pairs that exist on both markets
|
||||||
{"method": "StaticPairList", "allow_inactive": True},
|
{"method": "StaticPairList", "allow_inactive": True},
|
||||||
{"method": "CrossMarketPairList", "mode": "whitelist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"},
|
||||||
],
|
],
|
||||||
"futures",
|
"futures",
|
||||||
["ETH/USDT:USDT"],
|
["ETH/USDT:USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# Blacklist mode on futures
|
# Futures pairs that exist only on futures market
|
||||||
{"method": "StaticPairList", "allow_inactive": True},
|
{"method": "StaticPairList", "allow_inactive": True},
|
||||||
{"method": "CrossMarketPairList", "mode": "blacklist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "current_market_only"},
|
||||||
],
|
],
|
||||||
"futures",
|
"futures",
|
||||||
["ADA/USDT:USDT"],
|
["ADA/USDT:USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# CrossMarketPairList as generator, whitelist mode, spot market
|
# CrossMarketPairList as generator, spot market, pairs that exist on both markets
|
||||||
{"method": "CrossMarketPairList", "mode": "whitelist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"},
|
||||||
],
|
],
|
||||||
"spot",
|
"spot",
|
||||||
["ETH/USDT"],
|
["ETH/USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# CrossMarketPairList as generator, blacklist mode, spot market
|
# CrossMarketPairList as generator, spot pairs that exist only on spot market
|
||||||
{"method": "CrossMarketPairList", "mode": "blacklist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "current_market_only"},
|
||||||
],
|
],
|
||||||
"spot",
|
"spot",
|
||||||
["BTC/USDT", "XRP/USDT", "NEO/USDT", "TKN/USDT"],
|
["BTC/USDT", "XRP/USDT", "NEO/USDT", "TKN/USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# CrossMarketPairList as generator, whitelist mode, futures market
|
# CrossMarketPairList as generator, futures pairs that exist on both markets
|
||||||
{"method": "CrossMarketPairList", "mode": "whitelist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"},
|
||||||
],
|
],
|
||||||
"futures",
|
"futures",
|
||||||
["ETH/USDT:USDT"],
|
["ETH/USDT:USDT"],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
# CrossMarketPairList as generator, blacklist mode, futures market
|
# CrossMarketPairList as generator, futures pairs that exist only on futures market
|
||||||
{"method": "CrossMarketPairList", "mode": "blacklist"},
|
{"method": "CrossMarketPairList", "pairs_exist_on": "current_market_only"},
|
||||||
],
|
],
|
||||||
"futures",
|
"futures",
|
||||||
["ADA/USDT:USDT"],
|
["ADA/USDT:USDT"],
|
||||||
@@ -2687,7 +2687,9 @@ def test_CrossMarketPairlist_filter(
|
|||||||
|
|
||||||
def test_CrossMarketPairlist_gen_pairlist_uses_cache(mocker, default_conf_usdt, markets):
|
def test_CrossMarketPairlist_gen_pairlist_uses_cache(mocker, default_conf_usdt, markets):
|
||||||
default_conf_usdt["trading_mode"] = "spot"
|
default_conf_usdt["trading_mode"] = "spot"
|
||||||
default_conf_usdt["pairlists"] = [{"method": "CrossMarketPairList", "mode": "whitelist"}]
|
default_conf_usdt["pairlists"] = [
|
||||||
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"}
|
||||||
|
]
|
||||||
|
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
EXMS,
|
EXMS,
|
||||||
@@ -2716,7 +2718,9 @@ def test_CrossMarketPairlist_gen_pairlist_uses_cache(mocker, default_conf_usdt,
|
|||||||
|
|
||||||
def test_CrossMarketPairList_breaks_prefix_loop_on_match(mocker, default_conf_usdt, markets):
|
def test_CrossMarketPairList_breaks_prefix_loop_on_match(mocker, default_conf_usdt, markets):
|
||||||
default_conf_usdt["trading_mode"] = "spot"
|
default_conf_usdt["trading_mode"] = "spot"
|
||||||
default_conf_usdt["pairlists"] = [{"method": "CrossMarketPairList", "mode": "whitelist"}]
|
default_conf_usdt["pairlists"] = [
|
||||||
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"}
|
||||||
|
]
|
||||||
|
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
EXMS,
|
EXMS,
|
||||||
@@ -2750,7 +2754,9 @@ def test_CrossMarketPairList_breaks_prefix_loop_on_delayed_match(
|
|||||||
mocker, default_conf_usdt, markets
|
mocker, default_conf_usdt, markets
|
||||||
):
|
):
|
||||||
default_conf_usdt["trading_mode"] = "spot"
|
default_conf_usdt["trading_mode"] = "spot"
|
||||||
default_conf_usdt["pairlists"] = [{"method": "CrossMarketPairList", "mode": "whitelist"}]
|
default_conf_usdt["pairlists"] = [
|
||||||
|
{"method": "CrossMarketPairList", "pairs_exist_on": "both_markets"}
|
||||||
|
]
|
||||||
|
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
EXMS,
|
EXMS,
|
||||||
|
|||||||
Reference in New Issue
Block a user