@@ -58,20 +58,17 @@ def __init__(self, octobot_api):
58
58
# these attributes will be set at the last moment to ensure relevance and let time for everything to startup
59
59
self .has_real_trader = None
60
60
self .has_simulator = None
61
- self .exchange_managers = None
62
61
63
62
def _init_community_config (self ):
64
63
self .has_real_trader = trading_api .is_trader_enabled_in_config (self .edited_config .config )
65
64
self .has_simulator = trading_api .is_trader_simulator_enabled_in_config (self .edited_config .config )
66
- self .exchange_managers = trading_api .get_exchange_managers_from_exchange_ids (
67
- self .octobot_api .get_exchange_manager_ids ())
68
65
69
66
async def start_community_task (self ):
70
67
if self .enabled :
71
68
try :
72
69
# first ensure this session is not just a configuration test: register after a timer
73
70
await asyncio .sleep (
74
- common_constants . TIMER_BETWEEN_METRICS_UPTIME_UPDATE
71
+ constants . CLOUD_FIRST_METRICS_UPDATE_TIME
75
72
if constants .IS_CLOUD_ENV else common_constants .TIMER_BEFORE_METRICS_REGISTRATION_SECONDS
76
73
)
77
74
self ._init_community_config ()
@@ -187,14 +184,14 @@ def _get_bot_community(self):
187
184
def _get_exchange_types (self ):
188
185
return [
189
186
trading_api .get_exchange_type (exchange_manager ).value
190
- for exchange_manager in self .exchange_managers
187
+ for exchange_manager in self ._get_exchange_managers ()
191
188
]
192
189
193
190
def _get_profitability (self ):
194
191
total_origin_values = 0
195
192
total_profitability = 0
196
193
197
- for exchange_manager in self .exchange_managers :
194
+ for exchange_manager in self ._get_exchange_managers () :
198
195
if trading_api .is_exchange_trading (exchange_manager ):
199
196
profitability , _ , _ , _ , _ = trading_api .get_profitability_stats (exchange_manager )
200
197
total_profitability += float (profitability )
@@ -206,7 +203,7 @@ def _get_traded_volumes(self):
206
203
volume_by_currency = {}
207
204
if self .has_real_trader :
208
205
trades = []
209
- for exchange_manager in self .exchange_managers :
206
+ for exchange_manager in self ._get_exchange_managers () :
210
207
trades += trading_api .get_trade_history (exchange_manager , since = self .octobot_api .get_start_time ())
211
208
for trade in trades :
212
209
# cost is in quote currency for a traded pair
@@ -219,7 +216,7 @@ def _get_traded_volumes(self):
219
216
220
217
def _get_supports (self ):
221
218
supporting_exchanges = []
222
- for exchange_manager in self .exchange_managers :
219
+ for exchange_manager in self ._get_exchange_managers () :
223
220
exchange_name = trading_api .get_exchange_name (exchange_manager )
224
221
if self .has_real_trader \
225
222
and trading_api .is_sponsoring (exchange_name ) \
@@ -235,7 +232,7 @@ def _get_supports(self):
235
232
def _get_real_portfolio_value (self ):
236
233
if self .has_real_trader :
237
234
total_value = 0
238
- for exchange_manager in self .exchange_managers :
235
+ for exchange_manager in self ._get_exchange_managers () :
239
236
current_value = trading_api .get_current_portfolio_value (exchange_manager )
240
237
# current_value might be 0 if no trades have been made / canceled => use origin value
241
238
if current_value == 0 :
@@ -247,7 +244,7 @@ def _get_real_portfolio_value(self):
247
244
248
245
def _get_traded_pairs (self ):
249
246
pairs = set ()
250
- for exchange_manager in self .exchange_managers :
247
+ for exchange_manager in self ._get_exchange_managers () :
251
248
pairs = pairs .union (trading_api .get_trading_pairs (exchange_manager ))
252
249
return list (pairs )
253
250
@@ -322,3 +319,8 @@ async def _handle_post_error(self, resp, retry_on_error):
322
319
self .logger .debug (f"Impossible to send community data : "
323
320
f"status code: { resp .status } , "
324
321
f"text: { await resp .text ()} " )
322
+
323
+ def _get_exchange_managers (self ):
324
+ return trading_api .get_exchange_managers_from_exchange_ids (
325
+ self .octobot_api .get_exchange_manager_ids ()
326
+ )
0 commit comments