Skip to content

Commit

Permalink
Merge pull request QuantConnect#4551 from StefanoRaggi/bug-4550-alpac…
Browse files Browse the repository at this point in the history
…a-rejected-order-event

Add handler for Alpaca rejected order events
  • Loading branch information
Martin-Molinero authored Jun 30, 2020
2 parents c6157a7 + 495cf71 commit 23c3d48
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Brokerages/Alpaca/AlpacaBrokerage.Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,19 @@ private void OnTradeUpdate(ITradeUpdate trade)
FillQuantity = fillQuantity * (order.Direction == OrderDirection.Buy ? 1 : -1)
});
}
else if (trade.Event == TradeEvent.Canceled)
else if (trade.Event == TradeEvent.Rejected)
{
OnOrderEvent(new OrderEvent(order,
DateTime.UtcNow,
OrderFee.Zero,
"Alpaca Rejected Order Event") { Status = OrderStatus.Invalid });
}
else if (trade.Event == TradeEvent.Canceled || trade.Event == TradeEvent.Expired)
{
OnOrderEvent(new OrderEvent(order,
DateTime.UtcNow,
OrderFee.Zero,
"Alpaca Cancel Order Event") { Status = OrderStatus.Canceled });
$"Alpaca {trade.Event} Order Event") { Status = OrderStatus.Canceled });
}
else if (trade.Event == TradeEvent.OrderCancelRejected)
{
Expand Down

0 comments on commit 23c3d48

Please sign in to comment.