Skip to content

Commit

Permalink
[ExchangeTests] add test_is_valid_account
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Dec 3, 2024
1 parent 1a3c511 commit 515493a
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_ascendex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TestBinanceAuthenticatedExchange(
'7457313043',
'7457370420',
]
IS_BROKER_ENABLED_ACCOUNT = False

async def test_get_portfolio(self):
await super().test_get_portfolio()
Expand All @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_binance_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_bingx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_bitget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_bitmart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_bybit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_bybit_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 4 additions & 0 deletions additional_tests/exchanges_tests/test_coinbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_coinex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_cryptocom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_gateio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_hollaex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_htx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_kucoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_kucoin_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_mexc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_okx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_okx_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions additional_tests/exchanges_tests/test_phemex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 515493a

Please sign in to comment.