Skip to content

Commit

Permalink
Minor improvements for order event handling (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero authored Jul 19, 2024
1 parent 349e45a commit 1ac8f3c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion QuantConnect.AlpacaBrokerage/AlpacaBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,17 @@ protected override CrossZeroOrderResponse PlaceCrossZeroOrder(CrossZeroFirstOrde
return new CrossZeroOrderResponse(string.Empty, false);
}

var newBrokerageOrderId = response.OrderId.ToString();
if (!crossZeroOrderRequest.LeanOrder.BrokerId.Contains(newBrokerageOrderId))
{
crossZeroOrderRequest.LeanOrder.BrokerId.Add(newBrokerageOrderId);
}

if (isPlaceOrderWithLeanEvent)
{
OnOrderEvent(new OrderEvent(crossZeroOrderRequest.LeanOrder, DateTime.UtcNow, OrderFee.Zero, $"{nameof(AlpacaBrokerage)} Order Event") { Status = Orders.OrderStatus.Submitted });
}
return new CrossZeroOrderResponse(response.OrderId.ToString(), true);
return new CrossZeroOrderResponse(newBrokerageOrderId, true);
}

/// <summary>
Expand Down

0 comments on commit 1ac8f3c

Please sign in to comment.