Skip to content

Commit

Permalink
refactor: return always 'true' from PlaceOrder to handle Invalid Orde…
Browse files Browse the repository at this point in the history
…r internally in brokerage (#17)
  • Loading branch information
Romazes authored Sep 11, 2024
1 parent 7ed3f3f commit f691001
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ public override bool PlaceOrder(Order order)
return false;
}

var result = false;
try
{
_messageHandler.WithLockedStream(() =>
Expand All @@ -361,20 +360,14 @@ 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;
}
});
}
catch (Exception ex)
{
OnOrderEvent(new OrderEvent(order, DateTime.UtcNow, OrderFee.Zero, ex.Message) { Status = Orders.OrderStatus.Invalid });
}

return result;
return true;
}

private void HandleTradeUpdate(ITradeUpdate obj)
Expand Down

0 comments on commit f691001

Please sign in to comment.