Skip to content

[RestExchange] filter symbols depending on exchange type #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion octobot_trading/exchanges/types/rest_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down