|
@@ -73,27 +73,22 @@ class PositionsCommands(InfoCommandsBase):
|
|
|
duration_str = "Error"
|
|
|
|
|
|
# Calculate unrealized PnL
|
|
|
- unrealized_pnl = position_trade.get('unrealized_pnl')
|
|
|
- if unrealized_pnl is None:
|
|
|
- if position_side == 'long':
|
|
|
- unrealized_pnl = (mark_price - entry_price) * abs_current_amount
|
|
|
- else: # Short position
|
|
|
- unrealized_pnl = (entry_price - mark_price) * abs_current_amount
|
|
|
- unrealized_pnl = unrealized_pnl or 0.0
|
|
|
-
|
|
|
- # ROE Percentage from database
|
|
|
+ unrealized_pnl = position_trade.get('unrealized_pnl', 0.0)
|
|
|
+
|
|
|
+ # Get ROE from database
|
|
|
roe_percentage = position_trade.get('roe_percentage', 0.0)
|
|
|
|
|
|
# Add to totals
|
|
|
- individual_position_value = position_trade.get('position_value')
|
|
|
- if individual_position_value is None:
|
|
|
+ individual_position_value = position_trade.get('position_value', 0.0)
|
|
|
+ if individual_position_value is None or individual_position_value == 0:
|
|
|
individual_position_value = abs_current_amount * mark_price
|
|
|
|
|
|
total_position_value += individual_position_value
|
|
|
total_unrealized += unrealized_pnl
|
|
|
|
|
|
- margin_used = position_trade.get('margin_used')
|
|
|
- if margin_used is not None:
|
|
|
+ # Add margin to total
|
|
|
+ margin_used = position_trade.get('margin_used', 0.0)
|
|
|
+ if margin_used > 0:
|
|
|
total_margin_used += margin_used
|
|
|
|
|
|
# Format position details
|
|
@@ -103,10 +98,15 @@ class PositionsCommands(InfoCommandsBase):
|
|
|
size_str = formatter.format_amount(abs_current_amount, base_asset)
|
|
|
|
|
|
# Position header
|
|
|
- pos_emoji = "🟢" if position_side == 'long' else "🔴"
|
|
|
- direction_text = position_side.upper()
|
|
|
+ pos_emoji = ""
|
|
|
+ direction_text = ""
|
|
|
+ if position_side == 'long':
|
|
|
+ pos_emoji = "🟢"
|
|
|
+ direction_text = "LONG"
|
|
|
+ else: # Short position
|
|
|
+ pos_emoji = "🔴"
|
|
|
+ direction_text = "SHORT"
|
|
|
|
|
|
- # Add leverage if available
|
|
|
leverage = position_trade.get('leverage')
|
|
|
if leverage is not None:
|
|
|
try:
|