Skip to content

Commit b7ebfdd

Browse files
committed
[RestExchange] filter symbols depending on exchange type
tmp tmp tmp
1 parent 53e9398 commit b7ebfdd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

octobot_trading/exchanges/types/rest_exchange.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import ccxt.async_support as ccxt
2525
import octobot_commons.enums as commons_enums
26+
import octobot_commons.symbols.symbol_util as symbol_util
2627
import octobot_commons.tree as commons_tree
2728

2829
from octobot_commons import number_util
@@ -93,7 +94,7 @@ def _create_connector(self, config, exchange_manager, connector_class):
9394

9495
async def initialize_impl(self):
9596
await self.connector.initialize()
96-
self.symbols = self.connector.symbols
97+
self.symbols = self.get_exchange_pairs()
9798
self.time_frames = self.connector.time_frames
9899

99100
async def stop(self) -> None:
@@ -558,6 +559,17 @@ def get_split_pair_from_exchange(self, pair) -> (str, str):
558559
def get_exchange_pair(self, pair) -> str:
559560
return self.connector.get_exchange_pair(pair)
560561

562+
def get_exchange_pairs(self) -> set:
563+
# make sure spot doesnt use futures pairs and vice versa
564+
if self.exchange_manager.is_spot_only or self.exchange_manager.is_margin:
565+
return {symbol for symbol in self.connector.symbols
566+
if symbol_util.parse_symbol(symbol).is_spot()}
567+
elif self.exchange_manager.is_future:
568+
return {symbol for symbol in self.connector.symbols
569+
if symbol_util.parse_symbol(symbol).is_future()}
570+
else:
571+
return self.connector.symbols
572+
561573
def get_pair_cryptocurrency(self, pair) -> str:
562574
return self.connector.get_pair_cryptocurrency(pair)
563575

0 commit comments

Comments
 (0)