Skip to content

Commit 84fa3e7

Browse files
committed
[IndexTrading] implement get_tentacle_config_traded_symbols
1 parent 6093295 commit 84fa3e7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Trading/Mode/index_trading_mode/index_trading.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ async def _send_alert_notification(self):
368368
self.logger.exception(e, True, f"Impossible to send notification: {e}")
369369

370370
def _notify_if_missing_too_many_coins(self):
371-
if ideal_distribution := self.trading_mode.get_ideal_distribution():
371+
if ideal_distribution := self.trading_mode.get_ideal_distribution(self.trading_mode.trading_config):
372372
if len(self.trading_mode.indexed_coins) < len(ideal_distribution) / 2:
373373
self.logger.error(
374374
f"Less than half of configured coins can be traded on {self.exchange_manager.exchange_name}. "
@@ -563,6 +563,13 @@ def init_user_inputs(self, inputs: dict) -> None:
563563
title="Weight of the coin within this distribution.")
564564
self._update_coins_distribution()
565565

566+
@classmethod
567+
def get_tentacle_config_traded_symbols(cls, config: dict, reference_market: str) -> list:
568+
return [
569+
symbol_util.merge_currencies(asset[index_distribution.DISTRIBUTION_NAME], reference_market)
570+
for asset in (cls.get_ideal_distribution(config) or [])
571+
]
572+
566573
def is_updating_at_each_price_change(self):
567574
return self.refresh_interval_days == 0
568575

@@ -596,11 +603,12 @@ def _get_filtered_traded_coins(self):
596603
def get_coins_to_consider_for_ratio(self) -> list:
597604
return self.indexed_coins + [self.exchange_manager.exchange_personal_data.portfolio_manager.reference_market]
598605

599-
def get_ideal_distribution(self):
600-
return self.trading_config.get(IndexTradingModeProducer.INDEX_CONTENT, None)
606+
@classmethod
607+
def get_ideal_distribution(cls, config: dict):
608+
return config.get(IndexTradingModeProducer.INDEX_CONTENT, None)
601609

602610
def _get_supported_distribution(self) -> list:
603-
if full_distribution := self.get_ideal_distribution():
611+
if full_distribution := self.get_ideal_distribution(self.trading_config):
604612
traded_bases = set(
605613
symbol.base
606614
for symbol in self.exchange_manager.exchange_config.traded_symbols
@@ -630,7 +638,7 @@ def _get_supported_distribution(self) -> list:
630638

631639
def get_removed_coins_from_config(self, available_traded_bases) -> list:
632640
removed_coins = []
633-
if self.get_ideal_distribution() and self.sell_unindexed_traded_coins:
641+
if self.get_ideal_distribution(self.trading_config) and self.sell_unindexed_traded_coins:
634642
# only remove non indexed coins if an ideal distribution is set
635643
removed_coins = [
636644
coin
@@ -642,7 +650,7 @@ def get_removed_coins_from_config(self, available_traded_bases) -> list:
642650
return removed_coins
643651
current_coins = [
644652
asset[index_distribution.DISTRIBUTION_NAME]
645-
for asset in (self.get_ideal_distribution() or [])
653+
for asset in (self.get_ideal_distribution(self.trading_config) or [])
646654
]
647655
return list(set(removed_coins + [
648656
asset[index_distribution.DISTRIBUTION_NAME]

0 commit comments

Comments
 (0)