From b7ebfdd5291973e17a23c190aed2d06dfea1fb30 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 16 Mar 2023 17:54:28 +0000 Subject: [PATCH] [RestExchange] filter symbols depending on exchange type tmp tmp tmp --- octobot_trading/exchanges/types/rest_exchange.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/octobot_trading/exchanges/types/rest_exchange.py b/octobot_trading/exchanges/types/rest_exchange.py index 9f0e8281d..60121e38c 100644 --- a/octobot_trading/exchanges/types/rest_exchange.py +++ b/octobot_trading/exchanges/types/rest_exchange.py @@ -23,6 +23,7 @@ import ccxt.async_support as ccxt import octobot_commons.enums as commons_enums +import octobot_commons.symbols.symbol_util as symbol_util import octobot_commons.tree as commons_tree from octobot_commons import number_util @@ -93,7 +94,7 @@ def _create_connector(self, config, exchange_manager, connector_class): async def initialize_impl(self): await self.connector.initialize() - self.symbols = self.connector.symbols + self.symbols = self.get_exchange_pairs() self.time_frames = self.connector.time_frames async def stop(self) -> None: @@ -558,6 +559,17 @@ def get_split_pair_from_exchange(self, pair) -> (str, str): def get_exchange_pair(self, pair) -> str: return self.connector.get_exchange_pair(pair) + def get_exchange_pairs(self) -> set: + # make sure spot doesnt use futures pairs and vice versa + if self.exchange_manager.is_spot_only or self.exchange_manager.is_margin: + return {symbol for symbol in self.connector.symbols + if symbol_util.parse_symbol(symbol).is_spot()} + elif self.exchange_manager.is_future: + return {symbol for symbol in self.connector.symbols + if symbol_util.parse_symbol(symbol).is_future()} + else: + return self.connector.symbols + def get_pair_cryptocurrency(self, pair) -> str: return self.connector.get_pair_cryptocurrency(pair)