Update "exchange_has" validation with new fallbacks

This commit is contained in:
Matthias
2024-02-18 15:14:07 +01:00
parent 3497f7946e
commit f53c019d2a
2 changed files with 13 additions and 8 deletions
+8 -7
View File
@@ -60,16 +60,17 @@ SUPPORTED_EXCHANGES = [
'okx', 'okx',
] ]
EXCHANGE_HAS_REQUIRED = [ # either the main, or replacement methods (array) is required
EXCHANGE_HAS_REQUIRED = {
# Required / private # Required / private
'fetchOrder', 'fetchOrder': ['fetchOpenOrder', 'fetchClosedOrder'],
'cancelOrder', 'cancelOrder': [],
'createOrder', 'createOrder': [],
'fetchBalance', 'fetchBalance': [],
# Public endpoints # Public endpoints
'fetchOHLCV', 'fetchOHLCV': [],
] }
EXCHANGE_HAS_OPTIONAL = [ EXCHANGE_HAS_OPTIONAL = [
# Private # Private
+5 -1
View File
@@ -49,7 +49,11 @@ def validate_exchange(exchange: str) -> Tuple[bool, str]:
reason = '' reason = ''
if not ex_mod or not ex_mod.has: if not ex_mod or not ex_mod.has:
return False, '' return False, ''
missing = [k for k in EXCHANGE_HAS_REQUIRED if ex_mod.has.get(k) is not True] missing = [
k for k, v in EXCHANGE_HAS_REQUIRED.items()
if ex_mod.has.get(k) is not True
and not (all(ex_mod.has.get(x) for x in v))
]
if missing: if missing:
result = False result = False
reason += f"missing: {', '.join(missing)}" reason += f"missing: {', '.join(missing)}"