From 3bdde74096904c9c4a6371a00a2308c1f37958ee Mon Sep 17 00:00:00 2001 From: Martin-Molinero Date: Thu, 18 Jul 2024 14:34:29 -0300 Subject: [PATCH] Minor brokerage testing improvements (#8209) --- Brokerages/Brokerage.cs | 2 +- Common/Orders/OrderEvent.cs | 1 + Tests/Brokerages/BrokerageTests.cs | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Brokerages/Brokerage.cs b/Brokerages/Brokerage.cs index fc7243f24e33..ab58dd19a9d4 100644 --- a/Brokerages/Brokerage.cs +++ b/Brokerages/Brokerage.cs @@ -816,7 +816,7 @@ protected bool TryHandleRemainingCrossZeroOrder(Order leanOrder, OrderEvent orde catch (Exception err) { Log.Error(err); - OnMessage(new BrokerageMessageEvent(BrokerageMessageType.Warning, "CrossZeroOrderError", "An error occurred while trying to submit an cross zero order: " + err)); + OnMessage(new BrokerageMessageEvent(BrokerageMessageType.Warning, "CrossZeroOrderError", "Error occurred submitting cross zero order: " + err.Message)); OnOrderEvent(new OrderEvent(leanOrder, DateTime.UtcNow, OrderFee.Zero) { Status = OrderStatus.Canceled }); } #pragma warning restore CA1031 // Do not catch general exception types diff --git a/Common/Orders/OrderEvent.cs b/Common/Orders/OrderEvent.cs index ac0771573aa1..32bc2e2c7fc2 100644 --- a/Common/Orders/OrderEvent.cs +++ b/Common/Orders/OrderEvent.cs @@ -288,6 +288,7 @@ public OrderEvent(Order order, DateTime utcTime, OrderFee orderFee, string messa OrderId = order.Id; Symbol = order.Symbol; Status = order.Status; + Quantity = order.Quantity; Direction = order.Direction; //Initialize to zero, manually set fill quantity diff --git a/Tests/Brokerages/BrokerageTests.cs b/Tests/Brokerages/BrokerageTests.cs index fc2ca32a21a0..ff7a154d53aa 100644 --- a/Tests/Brokerages/BrokerageTests.cs +++ b/Tests/Brokerages/BrokerageTests.cs @@ -168,7 +168,7 @@ private void HandleFillEvents(object sender, List ordeEvents) _securityProvider[orderEvent.Symbol].Holdings.SetHoldings(orderEvent.FillPrice, orderEvent.FillQuantity); } - Log.Trace("--HOLDINGS: " + _securityProvider[orderEvent.Symbol]); + Log.Trace("--HOLDINGS: " + _securityProvider[orderEvent.Symbol].Holdings); // update order mapping var order = _orderProvider.GetOrderById(orderEvent.OrderId); @@ -314,6 +314,7 @@ public virtual void CancelOrders(OrderTestParameters parameters) using var canceledOrderStatusEvent = new ManualResetEvent(false); EventHandler> orderStatusCallback = (sender, fills) => { + order.Status = fills.First().Status; if (fills[0].Status == OrderStatus.Canceled) { canceledOrderStatusEvent.Set();