diff --git a/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py b/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py index cfdde40d8..d906604c4 100644 --- a/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py +++ b/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py @@ -86,6 +86,7 @@ class AbstractAuthenticatedExchangeTester: EXPECTED_INVALID_ORDERS_QUANTITY = [] # orders with known invalid quantity exchange order id (usually legacy) CHECK_EMPTY_ACCOUNT = False # set True when the account to check has no funds. Warning: does not check order # parse/create/fill/cancel or portfolio & trades parsing + IS_BROKER_ENABLED_ACCOUNT = True # set False when this test account can't generate broker fees # Implement all "test_[name]" methods, call super() to run the test, pass to ignore it. # Override the "inner_test_[name]" method to override a test content. @@ -209,6 +210,21 @@ async def inner_test_get_not_found_order(self): non_existing_order = await self.exchange_manager.exchange.get_order(self.VALID_ORDER_ID, self.SYMBOL) assert non_existing_order is None + async def test_is_valid_account(self): + async with self.local_exchange_manager(): + await self.inner_test_is_valid_account() + + async def inner_test_is_valid_account(self): + is_compatible, error = await self.exchange_manager.exchange_backend.is_valid_account( + always_check_key_rights=True + ) + assert is_compatible is self.IS_BROKER_ENABLED_ACCOUNT + if is_compatible: + assert error is None + else: + assert isinstance(error, str) + assert len(error) > 0 + async def test_create_and_cancel_limit_orders(self): async with self.local_exchange_manager(): await self.inner_test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_ascendex.py b/additional_tests/exchanges_tests/test_ascendex.py index 847477df1..aff455acf 100644 --- a/additional_tests/exchanges_tests/test_ascendex.py +++ b/additional_tests/exchanges_tests/test_ascendex.py @@ -57,6 +57,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_binance.py b/additional_tests/exchanges_tests/test_binance.py index fd27e340a..9bd62ca14 100644 --- a/additional_tests/exchanges_tests/test_binance.py +++ b/additional_tests/exchanges_tests/test_binance.py @@ -38,6 +38,7 @@ class TestBinanceAuthenticatedExchange( '7457313043', '7457370420', ] + IS_BROKER_ENABLED_ACCOUNT = False async def test_get_portfolio(self): await super().test_get_portfolio() @@ -60,6 +61,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_binance_futures.py b/additional_tests/exchanges_tests/test_binance_futures.py index 9da665bb2..30fa13746 100644 --- a/additional_tests/exchanges_tests/test_binance_futures.py +++ b/additional_tests/exchanges_tests/test_binance_futures.py @@ -80,6 +80,9 @@ async def test_get_and_set_margin_type(self): async def test_get_and_set_leverage(self): await super().test_get_and_set_leverage() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_bingx.py b/additional_tests/exchanges_tests/test_bingx.py index 257479205..3150a9f44 100644 --- a/additional_tests/exchanges_tests/test_bingx.py +++ b/additional_tests/exchanges_tests/test_bingx.py @@ -58,6 +58,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_bitget.py b/additional_tests/exchanges_tests/test_bitget.py index 628be48cf..a670a1d6d 100644 --- a/additional_tests/exchanges_tests/test_bitget.py +++ b/additional_tests/exchanges_tests/test_bitget.py @@ -59,6 +59,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_bitmart.py b/additional_tests/exchanges_tests/test_bitmart.py index 82ae6d604..b0e1a87c2 100644 --- a/additional_tests/exchanges_tests/test_bitmart.py +++ b/additional_tests/exchanges_tests/test_bitmart.py @@ -57,6 +57,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_bybit.py b/additional_tests/exchanges_tests/test_bybit.py index 0a5782030..40e0d13cc 100644 --- a/additional_tests/exchanges_tests/test_bybit.py +++ b/additional_tests/exchanges_tests/test_bybit.py @@ -61,6 +61,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_bybit_futures.py b/additional_tests/exchanges_tests/test_bybit_futures.py index e30453855..72a245b8a 100644 --- a/additional_tests/exchanges_tests/test_bybit_futures.py +++ b/additional_tests/exchanges_tests/test_bybit_futures.py @@ -73,6 +73,9 @@ async def test_get_and_set_margin_type(self): async def test_get_and_set_leverage(self): await super().test_get_and_set_leverage() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_coinbase.py b/additional_tests/exchanges_tests/test_coinbase.py index 01532a1ab..d98e37c1b 100644 --- a/additional_tests/exchanges_tests/test_coinbase.py +++ b/additional_tests/exchanges_tests/test_coinbase.py @@ -34,6 +34,7 @@ class TestCoinbaseAuthenticatedExchange( VALID_ORDER_ID = "8bb80a81-27f7-4415-aa50-911ea46d841c" USE_ORDER_OPERATION_TO_CHECK_API_KEY_RIGHTS = True # set True when api key rights can't be checked using a EXPECT_MISSING_FEE_IN_CANCELLED_ORDERS = False + IS_BROKER_ENABLED_ACCOUNT = False async def test_get_portfolio(self): await super().test_get_portfolio() @@ -56,6 +57,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_coinex.py b/additional_tests/exchanges_tests/test_coinex.py index 536697e85..780bad832 100644 --- a/additional_tests/exchanges_tests/test_coinex.py +++ b/additional_tests/exchanges_tests/test_coinex.py @@ -56,6 +56,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_cryptocom.py b/additional_tests/exchanges_tests/test_cryptocom.py index 43c0e7795..1a567fe39 100644 --- a/additional_tests/exchanges_tests/test_cryptocom.py +++ b/additional_tests/exchanges_tests/test_cryptocom.py @@ -57,6 +57,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_gateio.py b/additional_tests/exchanges_tests/test_gateio.py index bf466f5f5..97d8df012 100644 --- a/additional_tests/exchanges_tests/test_gateio.py +++ b/additional_tests/exchanges_tests/test_gateio.py @@ -59,6 +59,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_hollaex.py b/additional_tests/exchanges_tests/test_hollaex.py index 3ee1e0c4c..d9bcdee7d 100644 --- a/additional_tests/exchanges_tests/test_hollaex.py +++ b/additional_tests/exchanges_tests/test_hollaex.py @@ -59,6 +59,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_htx.py b/additional_tests/exchanges_tests/test_htx.py index ac9b56106..6477fb886 100644 --- a/additional_tests/exchanges_tests/test_htx.py +++ b/additional_tests/exchanges_tests/test_htx.py @@ -58,6 +58,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_kucoin.py b/additional_tests/exchanges_tests/test_kucoin.py index 8aa92be46..e6d18f404 100644 --- a/additional_tests/exchanges_tests/test_kucoin.py +++ b/additional_tests/exchanges_tests/test_kucoin.py @@ -41,6 +41,9 @@ async def test_get_portfolio(self): async def test_get_portfolio_with_market_filter(self): await super().test_get_portfolio_with_market_filter() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_kucoin_futures.py b/additional_tests/exchanges_tests/test_kucoin_futures.py index 943b35a30..8dd13ffa1 100644 --- a/additional_tests/exchanges_tests/test_kucoin_futures.py +++ b/additional_tests/exchanges_tests/test_kucoin_futures.py @@ -69,6 +69,9 @@ async def test_get_and_set_margin_type(self): async def test_get_and_set_leverage(self): await super().test_get_and_set_leverage() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_mexc.py b/additional_tests/exchanges_tests/test_mexc.py index ad95718c7..72f87e599 100644 --- a/additional_tests/exchanges_tests/test_mexc.py +++ b/additional_tests/exchanges_tests/test_mexc.py @@ -58,6 +58,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_okx.py b/additional_tests/exchanges_tests/test_okx.py index 16831d6f3..fb8aeb4d3 100644 --- a/additional_tests/exchanges_tests/test_okx.py +++ b/additional_tests/exchanges_tests/test_okx.py @@ -41,6 +41,9 @@ async def test_get_portfolio(self): async def test_get_portfolio_with_market_filter(self): await super().test_get_portfolio_with_market_filter() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_okx_futures.py b/additional_tests/exchanges_tests/test_okx_futures.py index 9897bb189..95dfbf7b1 100644 --- a/additional_tests/exchanges_tests/test_okx_futures.py +++ b/additional_tests/exchanges_tests/test_okx_futures.py @@ -67,6 +67,9 @@ async def test_get_and_set_margin_type(self): async def test_get_and_set_leverage(self): await super().test_get_and_set_leverage() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders() diff --git a/additional_tests/exchanges_tests/test_phemex.py b/additional_tests/exchanges_tests/test_phemex.py index 44df6e6ee..5f82b302f 100644 --- a/additional_tests/exchanges_tests/test_phemex.py +++ b/additional_tests/exchanges_tests/test_phemex.py @@ -56,6 +56,9 @@ async def test_missing_trading_api_key_permissions(self): async def test_get_not_found_order(self): await super().test_get_not_found_order() + async def test_is_valid_account(self): + await super().test_is_valid_account() + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders()