|
@@ -172,6 +172,9 @@ class InfoCommands:
|
|
|
total_margin_used = 0
|
|
|
total_equity_used = 0
|
|
|
|
|
|
+
|
|
|
+ exchange_positions_data = self.trading_engine.get_positions() or []
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -243,13 +246,17 @@ class InfoCommands:
|
|
|
logger.debug(f"Using position value calculation for {symbol}: {pnl_percentage}%")
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
roe_percentage = None
|
|
|
-
|
|
|
- exchange_data = self.trading_engine.get_positions()
|
|
|
- if exchange_data:
|
|
|
- for pos_data in exchange_data:
|
|
|
+ live_margin_used = None
|
|
|
+
|
|
|
+ if exchange_positions_data:
|
|
|
+ for pos_data in exchange_positions_data:
|
|
|
if pos_data.get('symbol') == symbol:
|
|
|
+
|
|
|
+ live_margin_used = pos_data.get('initialMargin')
|
|
|
+
|
|
|
+
|
|
|
info_data = pos_data.get('info', {})
|
|
|
position_info = info_data.get('position', {})
|
|
|
roe_raw = position_info.get('returnOnEquity')
|
|
@@ -259,7 +266,19 @@ class InfoCommands:
|
|
|
logger.debug(f"Found ROE for {symbol}: {roe_percentage}%")
|
|
|
except (ValueError, TypeError):
|
|
|
logger.warning(f"Could not parse ROE value: {roe_raw} for {symbol}")
|
|
|
+
|
|
|
+
|
|
|
+ if live_margin_used is None:
|
|
|
+ live_margin_used = position_info.get('marginUsed')
|
|
|
+ if live_margin_used is not None:
|
|
|
+ try:
|
|
|
+ live_margin_used = float(live_margin_used)
|
|
|
+ except (ValueError, TypeError):
|
|
|
+ live_margin_used = None
|
|
|
break
|
|
|
+
|
|
|
+
|
|
|
+ margin_used = live_margin_used if live_margin_used is not None else position_trade.get('margin_used')
|
|
|
|
|
|
|
|
|
individual_position_value = position_trade.get('position_value')
|