StockSharp
163 строки · 4.3 Кб
1#region S# License
2/******************************************************************************************
3NOTICE!!! This program and source code is owned and licensed by
4StockSharp, LLC, www.stocksharp.com
5Viewing or use of this code requires your acceptance of the license
6agreement found at https://github.com/StockSharp/StockSharp/blob/master/LICENSE
7Removal of this comment is a violation of the license agreement.
8
9Project: StockSharp.BusinessEntities.BusinessEntities
10File: MyTrade.cs
11Created: 2015, 11, 11, 2:32 PM
12
13Copyright 2010 by StockSharp, LLC
14*******************************************************************************************/
15#endregion S# License
16namespace StockSharp.BusinessEntities
17{
18using System;
19using System.ComponentModel;
20using System.ComponentModel.DataAnnotations;
21using System.Runtime.Serialization;
22
23using Ecng.Common;
24using Ecng.ComponentModel;
25
26using StockSharp.Localization;
27
28/// <summary>
29/// Own trade.
30/// </summary>
31[Serializable]
32[DataContract]
33[Display(
34ResourceType = typeof(LocalizedStrings),
35Name = LocalizedStrings.OwnTradeKey,
36Description = LocalizedStrings.OwnTradeDescKey)]
37public class MyTrade : NotifiableObject
38{
39/// <summary>
40/// Initializes a new instance of the <see cref="MyTrade"/>.
41/// </summary>
42public MyTrade()
43{
44}
45
46/// <summary>
47/// Order, for which a trade was filled.
48/// </summary>
49[DataMember]
50[TypeConverter(typeof(ExpandableObjectConverter))]
51[Display(
52ResourceType = typeof(LocalizedStrings),
53Name = LocalizedStrings.OrderKey,
54Description = LocalizedStrings.OwnTradeOrderKey,
55GroupName = LocalizedStrings.GeneralKey,
56Order = 0)]
57public Order Order { get; set; }
58
59/// <summary>
60/// Trade info.
61/// </summary>
62[DataMember]
63[TypeConverter(typeof(ExpandableObjectConverter))]
64[Display(
65ResourceType = typeof(LocalizedStrings),
66Name = LocalizedStrings.TradeKey,
67Description = LocalizedStrings.TickTradeInfoKey,
68GroupName = LocalizedStrings.GeneralKey,
69Order = 1)]
70#pragma warning disable CS0618 // Type or member is obsolete
71public Trade Trade { get; set; }
72#pragma warning restore CS0618 // Type or member is obsolete
73
74/// <summary>
75/// Commission.
76/// </summary>
77[DataMember]
78[Display(
79ResourceType = typeof(LocalizedStrings),
80Name = LocalizedStrings.CommissionKey,
81Description = LocalizedStrings.CommissionDescKey,
82GroupName = LocalizedStrings.StatisticsKey,
83Order = 0)]
84public decimal? Commission { get; set; }
85
86/// <summary>
87/// Commission currency. Can be <see langword="null"/>.
88/// </summary>
89public string CommissionCurrency { get; set; }
90
91/// <summary>
92/// Slippage in trade price.
93/// </summary>
94[DataMember]
95[Display(
96ResourceType = typeof(LocalizedStrings),
97Name = LocalizedStrings.SlippageKey,
98Description = LocalizedStrings.SlippageTradeKey,
99GroupName = LocalizedStrings.StatisticsKey,
100Order = 1)]
101public decimal? Slippage { get; set; }
102
103private decimal? _pnL;
104
105/// <summary>
106/// The profit, realized by trade.
107/// </summary>
108[DataMember]
109[Display(
110ResourceType = typeof(LocalizedStrings),
111Name = LocalizedStrings.PnLKey,
112Description = LocalizedStrings.PnLKey + LocalizedStrings.Dot,
113GroupName = LocalizedStrings.StatisticsKey,
114Order = 2)]
115public decimal? PnL
116{
117get => _pnL;
118set
119{
120if (_pnL == value)
121return;
122
123_pnL = value;
124NotifyChanged();
125}
126}
127
128/// <summary>
129/// The position, generated by trade.
130/// </summary>
131[DataMember]
132[Display(
133ResourceType = typeof(LocalizedStrings),
134Name = LocalizedStrings.PositionKey,
135Description = LocalizedStrings.PositionKey + LocalizedStrings.Dot,
136GroupName = LocalizedStrings.StatisticsKey,
137Order = 2)]
138public decimal? Position { get; set; }
139
140/// <summary>
141/// Used to identify whether the order initiator is an aggressor or not in the trade.
142/// </summary>
143[Display(
144ResourceType = typeof(LocalizedStrings),
145Name = LocalizedStrings.InitiatorKey,
146Description = LocalizedStrings.InitiatorTradeKey,
147GroupName = LocalizedStrings.GeneralKey,
148Order = 3)]
149public bool? Initiator { get; set; }
150
151/// <summary>
152/// Yield.
153/// </summary>
154[DataMember]
155public decimal? Yield { get; set; }
156
157/// <inheritdoc />
158public override string ToString()
159{
160return LocalizedStrings.TradeFromOrder.Put(Trade, Order);
161}
162}
163}