Răsfoiți Sursa

Refactor stop loss retrieval in InfoCommands - Updated the method for fetching pending stop losses to streamline the logic and improve readability. The new implementation directly filters pending stop losses by parent order reference ID, enhancing clarity in the code and maintaining consistent user notifications regarding stop loss statuses.

Carles Sentis 4 zile în urmă
părinte
comite
a4cee8b091
1 a modificat fișierele cu 7 adăugiri și 4 ștergeri
  1. 7 4
      src/commands/info_commands.py

+ 7 - 4
src/commands/info_commands.py

@@ -227,11 +227,14 @@ 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('pending_trigger', 'stop_limit_trigger')
-                                    linked_sls = [sl for sl in pending_sls if sl.get('parent_bot_order_ref_id') == bot_ref_id]
+                                    pending_sls = stats.get_orders_by_status(
+                                        status='pending_trigger', 
+                                        order_type_filter='stop_limit_trigger',
+                                        parent_bot_order_ref_id=bot_ref_id
+                                    )
                                     
-                                    if linked_sls:
-                                        sl_order = linked_sls[0]  # Should only be one
+                                    if pending_sls:
+                                        sl_order = pending_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"