diff --git a/tests/exchange_online/conftest.py b/tests/exchange_online/conftest.py index ad1bdb870..ee1e8a741 100644 --- a/tests/exchange_online/conftest.py +++ b/tests/exchange_online/conftest.py @@ -200,6 +200,24 @@ EXCHANGES = { "rebated_fee_currency": "USDT", }, ], + "sample_my_trades": [ + { + "id": "123412341234", + "create_time": "167997798", + "create_time_ms": "167997798825.566200", + "currency_pair": "ETH_USDT", + "side": "sell", + "role": "taker", + "amount": "0.0115", + "price": "1712.63", + "order_id": "1234123412", + "fee": "0.0", + "fee_currency": "USDT", + "point_fee": "0.03939049", + "gt_fee": "0.0", + "amend_text": "-", + } + ], }, "okx": { "pair": "BTC/USDT", diff --git a/tests/exchange_online/test_ccxt_compat.py b/tests/exchange_online/test_ccxt_compat.py index b764f8f75..6eb9f0023 100644 --- a/tests/exchange_online/test_ccxt_compat.py +++ b/tests/exchange_online/test_ccxt_compat.py @@ -86,6 +86,33 @@ class TestCCXTExchange: else: pytest.skip(f"No sample order available for exchange {exchange_name}") + def test_ccxt_my_trades_parse(self, exchange: EXCHANGE_FIXTURE_TYPE): + exch, exchange_name = exchange + if trades := EXCHANGES[exchange_name].get("sample_my_trades"): + pair = "SOL/USDT" + for trade in trades: + market = exch._api.markets[pair] + po = exch._api.parse_trade(trade) + (trade, market) + assert isinstance(po["id"], str) + assert isinstance(po["side"], str) + assert isinstance(po["amount"], float) + assert isinstance(po["price"], float) + assert isinstance(po["datetime"], str) + assert isinstance(po["timestamp"], int) + + if fees := po.get("fees"): + assert isinstance(fees, list) + for fee in fees: + assert isinstance(fee, dict) + assert isinstance(fee["cost"], str) + # TODO: this should be a float! + # assert isinstance(fee["cost"], float) + assert isinstance(fee["currency"], str) + + else: + pytest.skip(f"No sample Trades available for exchange {exchange_name}") + def test_ccxt_fetch_tickers(self, exchange: EXCHANGE_FIXTURE_TYPE): exch, exchangename = exchange pair = EXCHANGES[exchangename]["pair"]