57
57
from nautilus_trader .model .functions import time_in_force_to_pyo3
58
58
from nautilus_trader .model .identifiers import AccountId
59
59
from nautilus_trader .model .identifiers import ClientId
60
+ from nautilus_trader .model .identifiers import ClientOrderId
60
61
from nautilus_trader .model .identifiers import VenueOrderId
61
62
from nautilus_trader .model .orders import LimitOrder
62
63
from nautilus_trader .model .orders import MarketOrder
@@ -618,6 +619,9 @@ async def _submit_stop_limit_order(
618
619
reduce_only = order .is_reduce_only if order .is_reduce_only else None ,
619
620
)
620
621
622
+ def _is_external_order (self , client_order_id : ClientOrderId ) -> bool :
623
+ return not client_order_id or not self ._cache .strategy_id_for_order (client_order_id )
624
+
621
625
def _handle_msg (self , msg : Any ) -> None : # noqa: C901 (too complex)
622
626
# Note: These FIX execution reports are using a default precision of 8 for now,
623
627
# this avoids the need to track a separate cache down in Rust. Ensure all price
@@ -626,8 +630,9 @@ def _handle_msg(self, msg: Any) -> None: # noqa: C901 (too complex)
626
630
627
631
if isinstance (msg , nautilus_pyo3 .OrderStatusReport ):
628
632
report = OrderStatusReport .from_pyo3 (msg )
629
- if report .order_status is None :
630
- self ._log .warning (f"No ClientOrderId to process { report } " )
633
+
634
+ if self ._is_external_order (report .client_order_id ):
635
+ self ._send_order_status_report (report )
631
636
return
632
637
633
638
order = self ._cache .order (report .client_order_id )
@@ -686,8 +691,9 @@ def _handle_msg(self, msg: Any) -> None: # noqa: C901 (too complex)
686
691
self ._log .warning (f"Received unhandled execution report { report } " )
687
692
elif isinstance (msg , nautilus_pyo3 .FillReport ):
688
693
report = FillReport .from_pyo3 (msg )
689
- if report .client_order_id is None :
690
- self ._log .warning (f"No ClientOrderId to process { report } " )
694
+
695
+ if self ._is_external_order (report .client_order_id ):
696
+ self ._send_order_status_report (report )
691
697
return
692
698
693
699
order = self ._cache .order (report .client_order_id )
0 commit comments