From f691001c712afc8f1975a688c80e61a7c1eca7fb Mon Sep 17 00:00:00 2001 From: Roman Yavnikov <45608740+Romazes@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:11:43 +0300 Subject: [PATCH] refactor: return always 'true' from PlaceOrder to handle Invalid Order internally in brokerage (#17) --- QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs b/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs index 9adfd0f..0a61106 100644 --- a/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs +++ b/QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs @@ -342,7 +342,6 @@ public override bool PlaceOrder(Order order) return false; } - var result = false; try { _messageHandler.WithLockedStream(() => @@ -361,11 +360,6 @@ public override bool PlaceOrder(Order order) order.BrokerId.Add(response.OrderId.ToString()); OnOrderEvent(new OrderEvent(order, DateTime.UtcNow, OrderFee.Zero, $"{nameof(AlpacaBrokerage)} Order Event") { Status = Orders.OrderStatus.Submitted }); - result = response != null && response.OrderStatus != AlpacaMarket.OrderStatus.Rejected; - } - else - { - result = isPlaceCrossOrder.Value; } }); } @@ -373,8 +367,7 @@ public override bool PlaceOrder(Order order) { OnOrderEvent(new OrderEvent(order, DateTime.UtcNow, OrderFee.Zero, ex.Message) { Status = Orders.OrderStatus.Invalid }); } - - return result; + return true; } private void HandleTradeUpdate(ITradeUpdate obj)