test: add test for kraken balance response parsing

part of #11118
This commit is contained in:
Matthias
2025-01-05 11:21:15 +01:00
parent 5f0df2c1de
commit 4f1bf6a1f0
2 changed files with 30 additions and 0 deletions

View File

@@ -139,6 +139,23 @@ EXCHANGES = {
"leverage_tiers_public": False,
"leverage_in_spot_market": True,
"trades_lookback_hours": 12,
"sample_balances": {
"exchange_response": {
"result": {
"ADA": {"balance": "0.00000000", "hold_trade": "0.00000000"},
"ADA.F": {"balance": "2.00000000", "hold_trade": "0.00000000"},
"XBT": {"balance": "0.00060000", "hold_trade": "0.00000000"},
"XBT.F": {"balance": "0.00100000", "hold_trade": "0.00000000"},
}
},
"expected": {
"ADA": {"free": 0.0, "total": 0.0, "used": 0.0},
"ADA.F": {"free": 2.0, "total": 2.0, "used": 0.0},
"BTC": {"free": 0.0006, "total": 0.0006, "used": 0.0},
# XBT.F should be mapped to BTC.F
"XBT.F": {"free": 0.001, "total": 0.001, "used": 0.0},
},
},
},
"kucoin": {
"pair": "XRP/USDT",

View File

@@ -114,6 +114,19 @@ class TestCCXTExchange:
else:
pytest.skip(f"No sample Trades available for exchange {exchange_name}")
def test_ccxt_balances_parse(self, exchange: EXCHANGE_FIXTURE_TYPE):
exch, exchange_name = exchange
if balance_response := EXCHANGES[exchange_name].get("sample_balances"):
balances = exch._api.parse_balance(balance_response["exchange_response"])
expected = balance_response["expected"]
for currency, balance in expected.items():
assert currency in balances
assert isinstance(balance, dict)
assert balance == balances[currency]
pass
else:
pytest.skip(f"No sample Balances available for exchange {exchange_name}")
def test_ccxt_fetch_tickers(self, exchange: EXCHANGE_FIXTURE_TYPE):
exch, exchangename = exchange
pair = EXCHANGES[exchangename]["pair"]