Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix for cross order id #8213

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Brokerages/Brokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,11 @@ protected virtual CrossZeroOrderResponse PlaceCrossZeroOrder(CrossZeroFirstOrder
response = PlaceCrossZeroOrder(firstOrderPartRequest);
if (response.IsOrderPlacedSuccessfully)
{
order.BrokerId.Add(response.BrokerageOrderId.ToStringInvariant());
var orderId = response.BrokerageOrderId;
if (!order.BrokerId.Contains(orderId))
{
order.BrokerId.Add(orderId);
}
}
}

Expand Down Expand Up @@ -796,8 +800,15 @@ protected bool TryHandleRemainingCrossZeroOrder(Order leanOrder, OrderEvent orde
if (response.IsOrderPlacedSuccessfully)
{
// add the new brokerage id for retrieval later
leanOrder.BrokerId.Add(response.BrokerageOrderId);
LeanOrderByZeroCrossBrokerageOrderId.AddOrUpdate(response.BrokerageOrderId, leanOrder);
var orderId = response.BrokerageOrderId;
if (!leanOrder.BrokerId.Contains(orderId))
{
leanOrder.BrokerId.Add(orderId);
}

// leanOrder is a clone, here we can add the new brokerage order Id for the second part of the cross zero
OnOrderIdChangedEvent(new BrokerageOrderIdChangedEvent { OrderId = leanOrder.Id, BrokerId = leanOrder.BrokerId });
LeanOrderByZeroCrossBrokerageOrderId.AddOrUpdate(orderId, leanOrder);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Common/Orders/BrokerageOrderIdChangedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace QuantConnect.Orders
public class BrokerageOrderIdChangedEvent
{
/// <summary>
/// The order ID.
/// The lean order ID.
/// </summary>
public int OrderId { get; set; }

Expand Down
Loading