StockSharp
155 строк · 3.9 Кб
1#region S# License2/******************************************************************************************
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: Portfolio.cs
11Created: 2015, 11, 11, 2:32 PM
12
13Copyright 2010 by StockSharp, LLC
14*******************************************************************************************/
15#endregion S# License16namespace StockSharp.BusinessEntities17{
18using System;19using System.ComponentModel;20using System.ComponentModel.DataAnnotations;21using System.Runtime.Serialization;22
23using StockSharp.Messages;24using 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(32ResourceType = typeof(LocalizedStrings),33Name = LocalizedStrings.PortfolioKey,34Description = LocalizedStrings.PortfolioDescKey)]35public class Portfolio : Position36{37/// <summary>38/// Initializes a new instance of the <see cref="Portfolio"/>.39/// </summary>40public Portfolio()41{42}43
44private string _name;45
46/// <summary>47/// Portfolio code name.48/// </summary>49[DataMember]50[Display(51ResourceType = typeof(LocalizedStrings),52Name = LocalizedStrings.NameKey,53Description = LocalizedStrings.PortfolioNameKey,54GroupName = LocalizedStrings.GeneralKey)]55public string Name56{57get => _name;58set59{60if (_name == value)61return;62
63_name = value;64NotifyChanged();65}66}67
68/// <summary>69/// Exchange board, for which the current portfolio is active.70/// </summary>71[DataMember]72[Display(73ResourceType = typeof(LocalizedStrings),74Name = LocalizedStrings.BoardKey,75Description = LocalizedStrings.PortfolioBoardKey,76GroupName = LocalizedStrings.GeneralKey)]77public ExchangeBoard Board { get; set; }78
79private PortfolioStates? _state;80
81/// <summary>82/// Portfolio state.83/// </summary>84[DataMember]85[Display(86ResourceType = typeof(LocalizedStrings),87Name = LocalizedStrings.StateKey,88Description = LocalizedStrings.PortfolioStateKey,89GroupName = LocalizedStrings.GeneralKey)]90[Browsable(false)]91public PortfolioStates? State92{93get => _state;94set95{96if (_state == value)97return;98
99_state = value;100NotifyChanged();101}102}103
104/// <inheritdoc />105[Browsable(false)]106public override string StrategyId { get => base.StrategyId; set => base.StrategyId = value; }107
108/// <inheritdoc />109[Browsable(false)]110public 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>115public static Portfolio AnonymousPortfolio { get; } = new Portfolio116{117Name = Extensions.AnonymousPortfolioName,118};119
120/// <summary>121/// Create virtual portfolio for simulation.122/// </summary>123/// <returns>Simulator.</returns>124public static Portfolio CreateSimulator() => new()125{126Name = Extensions.SimulatorPortfolioName,127BeginValue = 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>134public void CopyTo(Portfolio destination)135{136base.CopyTo(destination);137
138destination.Name = Name;139destination.Board = Board;140//destination.Connector = Connector;141destination.State = State;142}143
144/// <inheritdoc />145public override string ToString() => Name;146
147/// <inheritdoc />148public override Position Clone()149{150var clone = new Portfolio();151CopyTo(clone);152return clone;153}154}155}
156