Skip to content

Commit 3b5e644

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

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

octobot_trading/exchanges/types/rest_exchange.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import sys
2323

2424
import ccxt.async_support as ccxt
25+
import octobot_commons as octobot_commons
2526
import octobot_commons.enums as commons_enums
27+
import octobot_commons.symbols.symbol_util as symbol_util
2628
import octobot_commons.tree as commons_tree
2729

2830
from octobot_commons import number_util
@@ -93,7 +95,7 @@ def _create_connector(self, config, exchange_manager, connector_class):
9395

9496
async def initialize_impl(self):
9597
await self.connector.initialize()
96-
self.symbols = self.connector.symbols
98+
self.symbols = self.get_exchange_pairs()
9799
self.time_frames = self.connector.time_frames
98100

99101
async def stop(self) -> None:
@@ -558,6 +560,17 @@ def get_split_pair_from_exchange(self, pair) -> (str, str):
558560
def get_exchange_pair(self, pair) -> str:
559561
return self.connector.get_exchange_pair(pair)
560562

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

0 commit comments

Comments
 (0)