diff --git a/additional_tests/exchanges_tests/__init__.py b/additional_tests/exchanges_tests/__init__.py index 80c186c37..4a4ced08e 100644 --- a/additional_tests/exchanges_tests/__init__.py +++ b/additional_tests/exchanges_tests/__init__.py @@ -63,7 +63,7 @@ def get_name(self): @contextlib.asynccontextmanager async def get_authenticated_exchange_manager(exchange_name, exchange_tentacle_name, config=None, - credentials_exchange_name=None): + credentials_exchange_name=None, market_filter=None): credentials_exchange_name = credentials_exchange_name or exchange_name _load_exchange_creds_env_variables_if_necessary() config = {**test_config.load_test_config(), **config} if config else test_config.load_test_config() @@ -82,6 +82,7 @@ async def get_authenticated_exchange_manager(exchange_name, exchange_tentacle_na .is_checking_credentials(False) \ .is_sandboxed(_get_exchange_is_sandboxed(credentials_exchange_name)) \ .is_using_exchange_type(exchange_type) \ + .use_market_filter(market_filter) \ .enable_storage(False) \ .disable_trading_mode() \ .is_exchange_only() diff --git a/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py b/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py index 8b48e782d..5621f9a18 100644 --- a/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py +++ b/additional_tests/exchanges_tests/abstract_authenticated_exchange_tester.py @@ -76,6 +76,18 @@ async def test_get_portfolio(self): async with self.local_exchange_manager(): await self.inner_test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # ensure market status are already loaded by another exchange manage and filters are applied + async with self.local_exchange_manager(): + # get portfolio with all markets + all_markets_portfolio = await self.get_portfolio() + + # now that market status are cached, test with filters + async with self.local_exchange_manager(market_filter=self._get_market_filter()): + # check portfolio fetched with filtered markets (should be equal to the one with all markets) + filtered_markets_portfolio = await self.get_portfolio() + assert filtered_markets_portfolio == all_markets_portfolio + async def inner_test_get_portfolio(self): self.check_portfolio_content(await self.get_portfolio()) @@ -554,14 +566,15 @@ async def get_price(self, symbol=None): )) @contextlib.asynccontextmanager - async def local_exchange_manager(self): + async def local_exchange_manager(self, market_filter=None): try: exchange_tentacle_name = self.EXCHANGE_TENTACLE_NAME or self.EXCHANGE_NAME.capitalize() async with get_authenticated_exchange_manager( self.EXCHANGE_NAME, exchange_tentacle_name, self.get_config(), - credentials_exchange_name=self.CREDENTIALS_EXCHANGE_NAME or self.EXCHANGE_NAME + credentials_exchange_name=self.CREDENTIALS_EXCHANGE_NAME or self.EXCHANGE_NAME, + market_filter=market_filter ) as exchange_manager: self.exchange_manager = exchange_manager yield @@ -903,3 +916,12 @@ def get_exchange_data(self, symbol=None, all_symbols=None) -> exchange_data_impo for s in _symbols ] ) + + def _get_market_filter(self): + def market_filter(market): + return ( + market[trading_enums.ExchangeConstantsMarketStatusColumns.SYMBOL.value] + in (self.SYMBOL, ) + ) + + return market_filter diff --git a/additional_tests/exchanges_tests/test_ascendex.py b/additional_tests/exchanges_tests/test_ascendex.py index 4ecc22212..a684fead7 100644 --- a/additional_tests/exchanges_tests/test_ascendex.py +++ b/additional_tests/exchanges_tests/test_ascendex.py @@ -35,6 +35,10 @@ class TestAscendexAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 3b9884e78..9d5fdcff2 100644 --- a/additional_tests/exchanges_tests/test_binance.py +++ b/additional_tests/exchanges_tests/test_binance.py @@ -35,6 +35,9 @@ class TestBinanceAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + await super().test_get_portfolio_with_market_filter() + 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 af68ac60c..9828f4a33 100644 --- a/additional_tests/exchanges_tests/test_binance_futures.py +++ b/additional_tests/exchanges_tests/test_binance_futures.py @@ -42,6 +42,10 @@ async def _set_account_types(self, account_types): async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + async def test_get_empty_linear_and_inverse_positions(self): await super().test_get_empty_linear_and_inverse_positions() diff --git a/additional_tests/exchanges_tests/test_bitget.py b/additional_tests/exchanges_tests/test_bitget.py index 45bc51353..218239c05 100644 --- a/additional_tests/exchanges_tests/test_bitget.py +++ b/additional_tests/exchanges_tests/test_bitget.py @@ -37,6 +37,10 @@ class TestBitgetAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 cfe88b245..9d720e348 100644 --- a/additional_tests/exchanges_tests/test_bybit.py +++ b/additional_tests/exchanges_tests/test_bybit.py @@ -39,6 +39,10 @@ class TestBybitAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 e8b452f44..e017f34f6 100644 --- a/additional_tests/exchanges_tests/test_bybit_futures.py +++ b/additional_tests/exchanges_tests/test_bybit_futures.py @@ -40,6 +40,10 @@ class TestBybitFuturesAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + async def test_get_empty_linear_and_inverse_positions(self): await super().test_get_empty_linear_and_inverse_positions() diff --git a/additional_tests/exchanges_tests/test_coinbase.py b/additional_tests/exchanges_tests/test_coinbase.py index 18753d6de..802754c97 100644 --- a/additional_tests/exchanges_tests/test_coinbase.py +++ b/additional_tests/exchanges_tests/test_coinbase.py @@ -35,6 +35,10 @@ class TestCoinbaseAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 b17a3732d..a62a97822 100644 --- a/additional_tests/exchanges_tests/test_cryptocom.py +++ b/additional_tests/exchanges_tests/test_cryptocom.py @@ -35,6 +35,10 @@ class TestCryptoComAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 178f78fd4..60406dafe 100644 --- a/additional_tests/exchanges_tests/test_hollaex.py +++ b/additional_tests/exchanges_tests/test_hollaex.py @@ -38,6 +38,10 @@ class TestHollaexAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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_huobi.py b/additional_tests/exchanges_tests/test_huobi.py index 99c6e9b78..231c1fa9f 100644 --- a/additional_tests/exchanges_tests/test_huobi.py +++ b/additional_tests/exchanges_tests/test_huobi.py @@ -37,6 +37,10 @@ class _TestHuobiAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 0f00aeee9..ffc79eab2 100644 --- a/additional_tests/exchanges_tests/test_kucoin.py +++ b/additional_tests/exchanges_tests/test_kucoin.py @@ -34,6 +34,9 @@ class TestKucoinAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + await super().test_get_portfolio_with_market_filter() + 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 30e3135fc..598590678 100644 --- a/additional_tests/exchanges_tests/test_kucoin_futures.py +++ b/additional_tests/exchanges_tests/test_kucoin_futures.py @@ -38,6 +38,10 @@ class TestKucoinFuturesAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + async def test_get_empty_linear_and_inverse_positions(self): await super().test_get_empty_linear_and_inverse_positions() diff --git a/additional_tests/exchanges_tests/test_mexc.py b/additional_tests/exchanges_tests/test_mexc.py index 5f6e4bb00..27da287cf 100644 --- a/additional_tests/exchanges_tests/test_mexc.py +++ b/additional_tests/exchanges_tests/test_mexc.py @@ -37,6 +37,10 @@ class TestMEXCAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + 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 cf1966363..a387cf294 100644 --- a/additional_tests/exchanges_tests/test_okx.py +++ b/additional_tests/exchanges_tests/test_okx.py @@ -34,6 +34,9 @@ class TestOKXAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + await super().test_get_portfolio_with_market_filter() + 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 6d8a3d99e..c95152535 100644 --- a/additional_tests/exchanges_tests/test_okx_futures.py +++ b/additional_tests/exchanges_tests/test_okx_futures.py @@ -37,6 +37,10 @@ class TestOKXFuturesAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + async def test_get_empty_linear_and_inverse_positions(self): await super().test_get_empty_linear_and_inverse_positions() diff --git a/additional_tests/exchanges_tests/test_phemex.py b/additional_tests/exchanges_tests/test_phemex.py index 06213adaf..a6c1be6be 100644 --- a/additional_tests/exchanges_tests/test_phemex.py +++ b/additional_tests/exchanges_tests/test_phemex.py @@ -36,6 +36,10 @@ class TestPemexAuthenticatedExchange( async def test_get_portfolio(self): await super().test_get_portfolio() + async def test_get_portfolio_with_market_filter(self): + # pass if not implemented + pass + async def test_create_and_cancel_limit_orders(self): await super().test_create_and_cancel_limit_orders()