|
@@ -227,17 +227,33 @@ class InfoCommands:
|
|
|
bot_ref_id = order_in_db.get('bot_order_ref_id')
|
|
|
if bot_ref_id:
|
|
|
# Look for pending stop losses with this order as parent
|
|
|
- pending_sls = stats.get_orders_by_status(
|
|
|
- status='pending_trigger',
|
|
|
- order_type_filter='stop_limit_trigger',
|
|
|
- parent_bot_order_ref_id=bot_ref_id
|
|
|
- )
|
|
|
+ # First, get all pending stop losses to debug
|
|
|
+ all_pending_sls = stats.get_orders_by_status('pending_trigger')
|
|
|
+ logger.info(f"DEBUG: Found {len(all_pending_sls)} total pending trigger orders")
|
|
|
|
|
|
- if pending_sls:
|
|
|
- sl_order = pending_sls[0] # Should only be one
|
|
|
+ # Filter for stop_limit_trigger type and matching parent
|
|
|
+ matching_sls = []
|
|
|
+ for sl in all_pending_sls:
|
|
|
+ sl_type = sl.get('type', '').upper()
|
|
|
+ sl_parent = sl.get('parent_bot_order_ref_id', '')
|
|
|
+
|
|
|
+ logger.info(f"DEBUG: Checking SL - Type: '{sl_type}', Parent: '{sl_parent}', Looking for: '{bot_ref_id}'")
|
|
|
+
|
|
|
+ if (sl_type == 'STOP_LIMIT_TRIGGER' and
|
|
|
+ sl_parent == bot_ref_id):
|
|
|
+ matching_sls.append(sl)
|
|
|
+ logger.info(f"DEBUG: Found matching SL - Price: {sl.get('price')}, Side: {sl.get('side')}")
|
|
|
+
|
|
|
+ if matching_sls:
|
|
|
+ sl_order = matching_sls[0] # Should only be one
|
|
|
sl_price = sl_order.get('price', 0)
|
|
|
sl_side = sl_order.get('side', '').upper()
|
|
|
orders_text += f" 🛑 Pending SL: {sl_side} @ {formatter.format_price_with_symbol(sl_price, symbol)} (activates when filled)\n"
|
|
|
+ logger.info(f"DEBUG: Added SL display text for order {order_id}")
|
|
|
+ else:
|
|
|
+ logger.info(f"DEBUG: No matching SL found for order {order_id} with bot_ref {bot_ref_id}")
|
|
|
+ else:
|
|
|
+ logger.info(f"DEBUG: Order {order_id} not found in database")
|
|
|
|
|
|
orders_text += "\n"
|
|
|
|