Skip to content

Commit 94f38b4

Browse files
committed
Add IOwnerMessage carrying numeric owner identity on messages
Introduce IOwnerMessage with OwnerUserId / OwnerPortfolioId — the numeric primary keys of the owning user and portfolio. Implement it on OrderMessage, ExecutionMessage, PositionChangeMessage and PortfolioMessage, copying both fields in their CopyTo so the identity survives Clone. Order subtypes (register/replace/cancel/group-cancel and order-status) inherit it from OrderMessage, and PortfolioLookupMessage inherits it from PortfolioMessage. This lets a downstream carry the owner identity on the message itself rather than in an external instance-keyed side table that was lost on a clone.
1 parent 47838e9 commit 94f38b4

5 files changed

Lines changed: 56 additions & 4 deletions

File tree

Messages/ExecutionMessage.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public enum ExecutionTypes
4242
public class ExecutionMessage : BaseSubscriptionIdMessage<ExecutionMessage>,
4343
ITransactionIdMessage, IServerTimeMessage, ISecurityIdMessage, ISeqNumMessage,
4444
IPortfolioNameMessage, IClientCodeMessage, IBrokerCodeMessage, IErrorMessage, IStrategyIdMessage, IGeneratedMessage,
45-
IOrderMessage, ITickTradeMessage, IOrderLogMessage, ISystemMessage
45+
IOrderMessage, ITickTradeMessage, IOrderLogMessage, ISystemMessage, IOwnerMessage
4646
{
4747
OrderStates? IOrderMessage.State => OrderState;
4848
decimal? IOrderMessage.Balance => Balance;
@@ -678,6 +678,12 @@ public override string ToString()
678678
return str;
679679
}
680680

681+
/// <inheritdoc />
682+
public long OwnerUserId { get; set; }
683+
684+
/// <inheritdoc />
685+
public long OwnerPortfolioId { get; set; }
686+
681687
/// <inheritdoc />
682688
public override void CopyTo(ExecutionMessage destination)
683689
{
@@ -748,5 +754,7 @@ public override void CopyTo(ExecutionMessage destination)
748754
destination.OrderBuyId = OrderBuyId;
749755
destination.OrderSellId = OrderSellId;
750756
destination.MarketPrice = MarketPrice;
757+
destination.OwnerUserId = OwnerUserId;
758+
destination.OwnerPortfolioId = OwnerPortfolioId;
751759
}
752760
}

Messages/IOwnerMessage.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace StockSharp.Messages;
2+
3+
/// <summary>
4+
/// The interface describing a message that carries the numeric identity of its owner —
5+
/// the owning user and portfolio primary keys. Carried on the message itself (and copied
6+
/// by <c>CopyTo</c>) so the identity survives cloning and travels with the message through
7+
/// the pipeline without an external side table.
8+
/// </summary>
9+
public interface IOwnerMessage
10+
{
11+
/// <summary>
12+
/// Numeric primary key of the owning user, or 0 when unknown.
13+
/// </summary>
14+
long OwnerUserId { get; set; }
15+
16+
/// <summary>
17+
/// Numeric primary key of the owning portfolio, or 0 when unknown.
18+
/// </summary>
19+
long OwnerPortfolioId { get; set; }
20+
}

Messages/OrderMessage.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace StockSharp.Messages;
1010
[DataContract]
1111
[Serializable]
1212
public abstract class OrderMessage(MessageTypes type) : SecurityMessage(type),
13-
ITransactionIdMessage, IPortfolioNameMessage, IClientCodeMessage, IBrokerCodeMessage, IStrategyIdMessage
13+
ITransactionIdMessage, IPortfolioNameMessage, IClientCodeMessage, IBrokerCodeMessage, IStrategyIdMessage, IOwnerMessage
1414
{
1515
/// <inheritdoc />
1616
[DataMember]
@@ -109,6 +109,12 @@ public abstract class OrderMessage(MessageTypes type) : SecurityMessage(type),
109109
GroupName = LocalizedStrings.GeneralKey)]
110110
public MarginModes? MarginMode { get; set; }
111111

112+
/// <inheritdoc />
113+
public long OwnerUserId { get; set; }
114+
115+
/// <inheritdoc />
116+
public long OwnerPortfolioId { get; set; }
117+
112118
/// <summary>
113119
/// Copy the message into the <paramref name="destination" />.
114120
/// </summary>
@@ -127,6 +133,8 @@ public void CopyTo(OrderMessage destination)
127133
destination.Condition = Condition?.Clone();
128134
destination.Comment = Comment;
129135
destination.MarginMode = MarginMode;
136+
destination.OwnerUserId = OwnerUserId;
137+
destination.OwnerPortfolioId = OwnerPortfolioId;
130138
}
131139

132140
/// <inheritdoc />

Messages/PortfolioMessage.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public enum PortfolioStates
2727
/// </summary>
2828
[DataContract]
2929
[Serializable]
30-
public class PortfolioMessage : BaseSubscriptionIdMessage<PortfolioMessage>, IPortfolioNameMessage, IClientCodeMessage
30+
public class PortfolioMessage : BaseSubscriptionIdMessage<PortfolioMessage>, IPortfolioNameMessage, IClientCodeMessage, IOwnerMessage
3131
{
3232
/// <inheritdoc />
3333
[DataMember]
@@ -105,6 +105,12 @@ public override string ToString()
105105
return str;
106106
}
107107

108+
/// <inheritdoc />
109+
public long OwnerUserId { get; set; }
110+
111+
/// <inheritdoc />
112+
public long OwnerPortfolioId { get; set; }
113+
108114
/// <inheritdoc />
109115
public override void CopyTo(PortfolioMessage destination)
110116
{
@@ -114,5 +120,7 @@ public override void CopyTo(PortfolioMessage destination)
114120
destination.Currency = Currency;
115121
destination.BoardCode = BoardCode;
116122
destination.ClientCode = ClientCode;
123+
destination.OwnerUserId = OwnerUserId;
124+
destination.OwnerPortfolioId = OwnerPortfolioId;
117125
}
118126
}

Messages/PositionChangeMessage.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public enum PositionChangeTypes
209209
Name = LocalizedStrings.PositionKey,
210210
Description = LocalizedStrings.PositionDescKey)]
211211
public class PositionChangeMessage : BaseChangeMessage<PositionChangeMessage,
212-
PositionChangeTypes>, IPortfolioNameMessage, IClientCodeMessage, ISecurityIdMessage, IStrategyIdMessage
212+
PositionChangeTypes>, IPortfolioNameMessage, IClientCodeMessage, ISecurityIdMessage, IStrategyIdMessage, IOwnerMessage
213213
{
214214
/// <inheritdoc />
215215
[DataMember]
@@ -326,6 +326,12 @@ public override Message Clone()
326326
return clone;
327327
}
328328

329+
/// <inheritdoc />
330+
public long OwnerUserId { get; set; }
331+
332+
/// <inheritdoc />
333+
public long OwnerPortfolioId { get; set; }
334+
329335
/// <inheritdoc />
330336
public override void CopyTo(PositionChangeMessage destination)
331337
{
@@ -340,6 +346,8 @@ public override void CopyTo(PositionChangeMessage destination)
340346
destination.BoardCode = BoardCode;
341347
destination.StrategyId = StrategyId;
342348
destination.Side = Side;
349+
destination.OwnerUserId = OwnerUserId;
350+
destination.OwnerPortfolioId = OwnerPortfolioId;
343351
}
344352

345353
/// <inheritdoc />

0 commit comments

Comments
 (0)