19 using Newtonsoft.Json;
22 using System.Collections.Generic;
34 public DateTime
Time {
get;
set; }
49 [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
55 [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
56 public Dictionary<string, Cash>
CashBook {
get;
set; }
61 [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
71 var totalMarginUsed = 0m;
72 var positionGroups =
new List<PositionGroupState>(portfolioManager.
Positions.Groups.Count);
73 foreach (var group
in portfolioManager.
Positions.Groups)
75 var buyingPowerForPositionGroup = group.BuyingPowerModel.GetReservedBuyingPowerForPositionGroup(portfolioManager, group);
79 MarginUsed = buyingPowerForPositionGroup,
82 if (currentPortfolioValue != 0)
84 positionGroupState.PortfolioValuePercentage = (buyingPowerForPositionGroup / currentPortfolioValue).RoundToSignificantDigits(4);
87 positionGroups.Add(positionGroupState);
88 totalMarginUsed += buyingPowerForPositionGroup;
96 CashBook = portfolioManager.
CashBook.Where(pair => pair.Value.Amount != 0).ToDictionary(pair => pair.Key, pair => pair.Value)
100 .Where(pair => pair.Value.Amount != 0)
101 .ToDictionary(pair => pair.Key, pair => pair.Value);
102 if (positionGroups.Count > 0)
104 result.PositionGroups = positionGroups;
106 if (unsettledCashBook.Count > 0)
108 result.UnsettledCashBook = unsettledCashBook;
129 public string Name {
get;
set; }