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

View File

@@ -60,16 +60,17 @@ SUPPORTED_EXCHANGES = [
'okx',
]
EXCHANGE_HAS_REQUIRED = [
# either the main, or replacement methods (array) is required
EXCHANGE_HAS_REQUIRED = {
# Required / private
'fetchOrder',
'cancelOrder',
'createOrder',
'fetchBalance',
'fetchOrder': ['fetchOpenOrder', 'fetchClosedOrder'],
'cancelOrder': [],
'createOrder': [],
'fetchBalance': [],
# Public endpoints
'fetchOHLCV',
]
'fetchOHLCV': [],
}
EXCHANGE_HAS_OPTIONAL = [
# Private

View File

@@ -49,7 +49,11 @@ def validate_exchange(exchange: str) -> Tuple[bool, str]:
reason = ''
if not ex_mod or not ex_mod.has:
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:
result = False
reason += f"missing: {', '.join(missing)}"