StockSharp

Форк
0
155 строк · 3.9 Кб
1
#region S# License
2
/******************************************************************************************
3
NOTICE!!!  This program and source code is owned and licensed by
4
StockSharp, LLC, www.stocksharp.com
5
Viewing or use of this code requires your acceptance of the license
6
agreement found at https://github.com/StockSharp/StockSharp/blob/master/LICENSE
7
Removal of this comment is a violation of the license agreement.
8

9
Project: StockSharp.BusinessEntities.BusinessEntities
10
File: Portfolio.cs
11
Created: 2015, 11, 11, 2:32 PM
12

13
Copyright 2010 by StockSharp, LLC
14
*******************************************************************************************/
15
#endregion S# License
16
namespace StockSharp.BusinessEntities
17
{
18
	using System;
19
	using System.ComponentModel;
20
	using System.ComponentModel.DataAnnotations;
21
	using System.Runtime.Serialization;
22

23
	using StockSharp.Messages;
24
	using StockSharp.Localization;
25

26
	/// <summary>
27
	/// Portfolio, describing the trading account and the size of its generated commission.
28
	/// </summary>
29
	[Serializable]
30
	[DataContract]
31
	[Display(
32
		ResourceType = typeof(LocalizedStrings),
33
		Name = LocalizedStrings.PortfolioKey,
34
		Description = LocalizedStrings.PortfolioDescKey)]
35
	public class Portfolio : Position
36
	{
37
		/// <summary>
38
		/// Initializes a new instance of the <see cref="Portfolio"/>.
39
		/// </summary>
40
		public Portfolio()
41
		{
42
		}
43

44
		private string _name;
45

46
		/// <summary>
47
		/// Portfolio code name.
48
		/// </summary>
49
		[DataMember]
50
		[Display(
51
			ResourceType = typeof(LocalizedStrings),
52
			Name = LocalizedStrings.NameKey,
53
			Description = LocalizedStrings.PortfolioNameKey,
54
			GroupName = LocalizedStrings.GeneralKey)]
55
		public string Name
56
		{
57
			get => _name;
58
			set
59
			{
60
				if (_name == value)
61
					return;
62

63
				_name = value;
64
				NotifyChanged();
65
			}
66
		}
67

68
		/// <summary>
69
		/// Exchange board, for which the current portfolio is active.
70
		/// </summary>
71
		[DataMember]
72
		[Display(
73
			ResourceType = typeof(LocalizedStrings),
74
			Name = LocalizedStrings.BoardKey,
75
			Description = LocalizedStrings.PortfolioBoardKey,
76
			GroupName = LocalizedStrings.GeneralKey)]
77
		public ExchangeBoard Board { get; set; }
78

79
		private PortfolioStates? _state;
80

81
		/// <summary>
82
		/// Portfolio state.
83
		/// </summary>
84
		[DataMember]
85
		[Display(
86
			ResourceType = typeof(LocalizedStrings),
87
			Name = LocalizedStrings.StateKey,
88
			Description = LocalizedStrings.PortfolioStateKey,
89
			GroupName = LocalizedStrings.GeneralKey)]
90
		[Browsable(false)]
91
		public PortfolioStates? State
92
		{
93
			get => _state;
94
			set
95
			{
96
				if (_state == value)
97
					return;
98

99
				_state = value;
100
				NotifyChanged();
101
			}
102
		}
103

104
		/// <inheritdoc />
105
		[Browsable(false)]
106
		public override string StrategyId { get => base.StrategyId; set => base.StrategyId = value; }
107

108
		/// <inheritdoc />
109
		[Browsable(false)]
110
		public override Sides? Side { get => base.Side; set => base.Side = value; }
111

112
		/// <summary>
113
		/// Portfolio associated with the orders received through the orders log.
114
		/// </summary>
115
		public static Portfolio AnonymousPortfolio { get; } = new Portfolio
116
		{
117
			Name = Extensions.AnonymousPortfolioName,
118
		};
119

120
		/// <summary>
121
		/// Create virtual portfolio for simulation.
122
		/// </summary>
123
		/// <returns>Simulator.</returns>
124
		public static Portfolio CreateSimulator() => new()
125
		{
126
			Name = Extensions.SimulatorPortfolioName,
127
			BeginValue = 1000000,
128
		};
129

130
		/// <summary>
131
		/// To copy the current portfolio fields to the <paramref name="destination" />.
132
		/// </summary>
133
		/// <param name="destination">The portfolio, in which fields should be copied.</param>
134
		public void CopyTo(Portfolio destination)
135
		{
136
			base.CopyTo(destination);
137

138
			destination.Name = Name;
139
			destination.Board = Board;
140
			//destination.Connector = Connector;
141
			destination.State = State;
142
		}
143

144
		/// <inheritdoc />
145
		public override string ToString() => Name;
146

147
		/// <inheritdoc />
148
		public override Position Clone()
149
		{
150
			var clone = new Portfolio();
151
			CopyTo(clone);
152
			return clone;
153
		}
154
	}
155
}
156

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.