Skip to content

Feature Request: Add ExecutionId to OrderEvent and SerializedOrderEvent #9133

@JaggerH

Description

@JaggerH

Expected Behavior

OrderEvent and SerializedOrderEvent should have an ExecutionId field to store the unique execution identifier provided by brokerages.

Actual Behavior

Currently, OrderEvent and SerializedOrderEvent classes do not have a field to store the brokerage's execution identifier.

Algorithm maintains a virtual position tracker that differs from the brokerage's portfolio (e.g., for pairs trading, multi-leg strategies) . To keep the virtual position in sync, It's necessary.

Potential Solution

Add an ExecutionId property to both OrderEvent and SerializedOrderEvent classes:

Common/Orders/OrderEvent.cs:

/// <summary>
/// Unique execution identifier from the brokerage
/// </summary>
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
[ProtoMember(20)]
public string ExecutionId { get; set; }

Common/Orders/Serialization/SerializedOrderEvent.cs:
/// <summary>
/// Unique execution identifier from the brokerage
/// </summary>
[JsonProperty("executionId", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string ExecutionId { get; set; }

// Backwards compatibility
[JsonProperty("execution-id", DefaultValueHandling = DefaultValueHandling.Ignore)]
string OldExecutionId
{
    set { ExecutionId = value; }
}

Benefits:
- ✅ Minimal change to core classes (one property addition)
- ✅ Fully backward compatible (optional field with DefaultValueHandling.Ignore)
- ✅ Follows existing serialization patterns in SerializedOrderEvent
- ✅ Brokerages can optionally populate this field without breaking existing code
- ✅ Enables deduplication and reconciliation logic in user algorithms

Brokerage Implementation:
var orderEvent = new OrderEvent(...)
{
    ExecutionId = brokerageExecution.Id  // e.g., IB execution ID
};
---
Note: I'm willing to submit a PR implementing this change if the proposal is accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions