Skip to content

Commit 30194a6

Browse files
committed
[Exchanges] update tests for ccxt update
1 parent 88e8580 commit 30194a6

15 files changed

+36
-44
lines changed

additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class AbstractAuthenticatedExchangeTester:
5656
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}"
5757
TIME_FRAME = "1h"
5858
VALID_ORDER_ID = "8bb80a81-27f7-4415-aa50-911ea46d841c"
59+
ALLOW_0_MAKER_FEES = False
5960
SPECIAL_ORDER_TYPES_BY_EXCHANGE_ID: dict[
6061
str, (
6162
str, # symbol
@@ -357,6 +358,8 @@ def assert_has_at_least_one_authenticated_call(calls):
357358
amount = self.get_order_size(
358359
portfolio, price, symbol=self.SYMBOL, settlement_currency=self.SETTLEMENT_CURRENCY
359360
) * 100000
361+
if amount == 0:
362+
amount = 100000
360363
if self.CHECK_EMPTY_ACCOUNT:
361364
amount = 10
362365
# (amount is too large, creating buy order will fail)
@@ -561,7 +564,7 @@ async def inner_test_create_and_cancel_limit_orders(self, symbol=None, settlemen
561564
open_orders = await self.get_open_orders(exchange_data)
562565
cancelled_orders = await self.get_cancelled_orders(exchange_data)
563566
if self.CHECK_EMPTY_ACCOUNT:
564-
assert size == trading_constants.ZERO
567+
assert size >= trading_constants.ZERO if enable_min_size_check else size == trading_constants.ZERO
565568
assert open_orders == []
566569
assert cancelled_orders == []
567570
return
@@ -1007,7 +1010,7 @@ def check_parsed_closed_order(
10071010
assert order.fee is None
10081011
else:
10091012
try:
1010-
assert order.fee
1013+
assert order.fee, f"Unexpected missing fee: {order.to_dict()}"
10111014
assert isinstance(order.fee[trading_enums.FeePropertyColumns.COST.value], decimal.Decimal)
10121015
has_paid_fees = order.fee[trading_enums.FeePropertyColumns.COST.value] > trading_constants.ZERO
10131016
if has_paid_fees:
@@ -1024,7 +1027,12 @@ def check_parsed_closed_order(
10241027
else:
10251028
assert order.fee[trading_enums.FeePropertyColumns.IS_FROM_EXCHANGE.value] is True
10261029
except AssertionError:
1027-
if allow_incomplete_fees and self.EXPECT_MISSING_ORDER_FEES_DUE_TO_ORDERS_TOO_OLD_FOR_RECENT_TRADES:
1030+
if (
1031+
not order.fee and self.ALLOW_0_MAKER_FEES and
1032+
order.taker_or_maker == trading_enums.ExchangeConstantsOrderColumns.MAKER.value
1033+
):
1034+
incomplete_fee_orders.append(order)
1035+
elif allow_incomplete_fees and self.EXPECT_MISSING_ORDER_FEES_DUE_TO_ORDERS_TOO_OLD_FOR_RECENT_TRADES:
10281036
incomplete_fee_orders.append(order)
10291037
else:
10301038
raise
@@ -1310,7 +1318,9 @@ def check_portfolio_changed(self, previous_portfolio, updated_portfolio, has_inc
13101318
def _check_order(self, order, size, side):
13111319
if self.CONVERTS_ORDER_SIZE_BEFORE_PUSHING_TO_EXCHANGES:
13121320
# actual origin_quantity may vary due to quantity conversion for market orders
1313-
assert size * decimal.Decimal("0.8") <= order.origin_quantity <= size * decimal.Decimal("1.2")
1321+
assert size * decimal.Decimal("0.8") <= order.origin_quantity <= size * decimal.Decimal("1.2"), (
1322+
f"FALSE: {size * decimal.Decimal('0.8')} <= {order.origin_quantity} <= {size * decimal.Decimal('1.2')}"
1323+
)
13141324
else:
13151325
assert order.origin_quantity == size
13161326
assert order.side is side

additional_tests/exchanges_tests/test_ascendex.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class TestAscendexAuthenticatedExchange(
2626
):
2727
# enter exchange name as a class variable here
2828
EXCHANGE_NAME = "ascendex"
29+
EXCHANGE_TENTACLE_NAME = "AscendEx"
2930
ORDER_CURRENCY = "BTC"
3031
SETTLEMENT_CURRENCY = "USDT"
3132
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}"

additional_tests/exchanges_tests/test_binance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestBinanceAuthenticatedExchange(
3030
ORDER_CURRENCY = "BTC"
3131
SETTLEMENT_CURRENCY = "USDC"
3232
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}"
33-
ORDER_SIZE = 50 # % of portfolio to include in test orders
33+
ORDER_SIZE = 80 # % of portfolio to include in test orders
3434
DUPLICATE_TRADES_RATIO = 0.1 # allow 10% duplicate in trades (due to trade id set to order id)
3535
VALID_ORDER_ID = "26408108410"
3636
EXPECTED_QUOTE_MIN_ORDER_SIZE = 5 # min quote value of orders to create (used to check market status parsing)

additional_tests/exchanges_tests/test_binance_futures.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# You should have received a copy of the GNU General Public
1515
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.
1616
import pytest
17+
import decimal
1718

1819
import octobot_trading.enums
1920
from additional_tests.exchanges_tests import abstract_authenticated_future_exchange_tester, \
@@ -30,14 +31,16 @@ class TestBinanceFuturesAuthenticatedExchange(
3031
EXCHANGE_NAME = "binance"
3132
CREDENTIALS_EXCHANGE_NAME = "BINANCE_FUTURES"
3233
ORDER_CURRENCY = "BTC" # always use a contract that has a size different from 1 unit of the currency
33-
SETTLEMENT_CURRENCY = "USDC"
34+
SETTLEMENT_CURRENCY = "USDT"
3435
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}:{SETTLEMENT_CURRENCY}"
3536
INVERSE_SYMBOL = f"{ORDER_CURRENCY}/USD:{ORDER_CURRENCY}"
3637
ORDER_SIZE = 30 # % of portfolio to include in test orders
3738
DUPLICATE_TRADES_RATIO = 0.1 # allow 10% duplicate in trades (due to trade id set to order id)
3839
VALID_ORDER_ID = "26408108410"
3940
EXPECTED_QUOTE_MIN_ORDER_SIZE = 200 # min quote value of orders to create (used to check market status parsing)
4041
IS_AUTHENTICATED_REQUEST_CHECK_AVAILABLE = True # set True when is_authenticated_request is implemented
42+
MAX_TRADE_USD_VALUE = decimal.Decimal(200000) # testnet portfolio
43+
ALLOW_0_MAKER_FEES = True
4144

4245
SPECIAL_ORDER_TYPES_BY_EXCHANGE_ID: dict[
4346
str, (

additional_tests/exchanges_tests/test_bingx.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class TestBingxAuthenticatedExchange(
4949
bool, # trigger above (on higher price than order price)
5050
)
5151
] = {
52+
# orders can't be fetched anymore: create new ones to test
5253
"1877004154170146816": (
5354
"TAO/USDT", "type", "TAKE_STOP_MARKET",
5455
octobot_trading.enums.TradeOrderType.STOP_LOSS.value, octobot_trading.enums.TradeOrderSide.SELL.value, False

additional_tests/exchanges_tests/test_bybit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# All test coroutines will be treated as marked.
2121
pytestmark = pytest.mark.asyncio
2222

23-
23+
#todo
2424
class TestBybitAuthenticatedExchange(
2525
abstract_authenticated_exchange_tester.AbstractAuthenticatedExchangeTester
2626
):

additional_tests/exchanges_tests/test_bybit_futures.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
pytestmark = pytest.mark.asyncio
2222

2323

24+
#todo
2425
class TestBybitFuturesAuthenticatedExchange(
2526
abstract_authenticated_future_exchange_tester.AbstractAuthenticatedFutureExchangeTester
2627
):

additional_tests/exchanges_tests/test_coinbase.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# You should have received a copy of the GNU General Public
1515
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.
1616
import pytest
17+
import decimal
1718

1819
import octobot_trading.enums
1920
from additional_tests.exchanges_tests import abstract_authenticated_exchange_tester
@@ -30,7 +31,8 @@ class TestCoinbaseAuthenticatedExchange(
3031
ORDER_CURRENCY = "BTC"
3132
SETTLEMENT_CURRENCY = "USDC"
3233
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}"
33-
ORDER_SIZE = 30 # % of portfolio to include in test orders
34+
ORDER_SIZE = 80 # % of portfolio to include in test orders
35+
MIN_TRADE_USD_VALUE = decimal.Decimal("0.004")
3436
CONVERTS_ORDER_SIZE_BEFORE_PUSHING_TO_EXCHANGES = True
3537
VALID_ORDER_ID = "8bb80a81-27f7-4415-aa50-911ea46d841c"
3638
USE_ORDER_OPERATION_TO_CHECK_API_KEY_RIGHTS = True # set True when api key rights can't be checked using a

additional_tests/exchanges_tests/test_coinbase_legacy_api_key.py

-32
This file was deleted.

additional_tests/exchanges_tests/test_cryptocom.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TestCryptoComAuthenticatedExchange(
3030
ORDER_CURRENCY = "BTC"
3131
SETTLEMENT_CURRENCY = "USDT"
3232
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}"
33-
ORDER_SIZE = 20 # % of portfolio to include in test orders
33+
ORDER_SIZE = 70 # % of portfolio to include in test orders
3434
VALID_ORDER_ID = "1777764898965454848"
3535

3636
async def test_get_portfolio(self):

additional_tests/exchanges_tests/test_kucoin.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class TestKucoinAuthenticatedExchange(
4848
bool, # trigger above (on higher price than order price)
4949
)
5050
] = {
51+
# can't be fetched anymore
5152
"vs93gpruc6ikekiv003o48ci": (
5253
"BTC/USDT", "type", "market",
5354
octobot_trading.enums.TradeOrderType.LIMIT.value, octobot_trading.enums.TradeOrderSide.BUY.value, False

additional_tests/exchanges_tests/test_kucoin_futures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestKucoinFuturesAuthenticatedExchange(
2828
# enter exchange name as a class variable here
2929
EXCHANGE_NAME = "kucoin"
3030
CREDENTIALS_EXCHANGE_NAME = "KUCOIN_FUTURES"
31-
ORDER_CURRENCY = "SOL" # always use a contract that has a size different from 1 unit of the currency
31+
ORDER_CURRENCY = "DOT" # always use a contract that has a size different from 1 unit of the currency
3232
SETTLEMENT_CURRENCY = "USDT"
3333
SYMBOL = f"{ORDER_CURRENCY}/{SETTLEMENT_CURRENCY}:{SETTLEMENT_CURRENCY}"
3434
INVERSE_SYMBOL = f"{ORDER_CURRENCY}/USD:{ORDER_CURRENCY}"

additional_tests/exchanges_tests/test_mexc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class TestMEXCAuthenticatedExchange(
3434
CONVERTS_ORDER_SIZE_BEFORE_PUSHING_TO_EXCHANGES = True
3535
CANCELLED_ORDERS_IN_CLOSED_ORDERS = True
3636
EXPECT_MISSING_FEE_IN_CANCELLED_ORDERS = False
37-
IS_ACCOUNT_ID_AVAILABLE = False
37+
IS_ACCOUNT_ID_AVAILABLE = True
38+
EXPECTED_GENERATED_ACCOUNT_ID = True
3839
IS_AUTHENTICATED_REQUEST_CHECK_AVAILABLE = True # set True when is_authenticated_request is implemented
3940
USE_ORDER_OPERATION_TO_CHECK_API_KEY_RIGHTS = True
4041
USED_TO_HAVE_UNTRADABLE_SYMBOL = True

additional_tests/exchanges_tests/test_phemex.py

+4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ async def test_get_my_recent_trades(self):
8181
await super().test_get_my_recent_trades()
8282

8383
async def test_get_closed_orders(self):
84+
# fails due to each trade being duplicated in privateGetExchangeSpotOrder resp
85+
# 07/04/25
8486
await super().test_get_closed_orders()
8587

8688
async def test_get_cancelled_orders(self):
89+
# fails due to each trade being duplicated in privateGetExchangeSpotOrder resp
90+
# 07/04/25
8791
await super().test_get_cancelled_orders()
8892

8993
async def test_create_and_cancel_stop_orders(self):

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OctoBot-Tentacles-Manager==2.9.16
66
OctoBot-Services==1.6.23
77
OctoBot-Backtesting==1.9.7
88
Async-Channel==2.2.1
9-
trading-backend==1.2.37
9+
trading-backend==1.2.38
1010

1111
## Others
1212
colorlog==6.8.0

0 commit comments

Comments
 (0)