public WeightedPosition(WeightedPortfolio portfolio, IEnumerable <Position> innerPositions) { if (innerPositions == null) { throw new ArgumentNullException(nameof(innerPositions)); } _innerPositions = innerPositions; var beginValue = 0m; var currentValue = 0m; var blockedValue = 0m; foreach (var position in _innerPositions) { var mult = portfolio.Weights[position.Portfolio]; beginValue += mult * position.BeginValue; currentValue += mult * position.CurrentValue; blockedValue += mult * position.BlockedValue; } BeginValue = beginValue; BlockedValue = blockedValue; CurrentValue = currentValue; }
public WeightsDictionary(WeightedPortfolio parent) { if (parent == null) { throw new ArgumentNullException("parent"); } _parent = parent; }
public WeightsDictionary(WeightedPortfolio parent, IConnector connector) { if (parent == null) { throw new ArgumentNullException(nameof(parent)); } _parent = parent; _connector = connector; }
public WeightedPosition(WeightedPortfolio portfolio, IEnumerable <Position> innerPositions) { if (innerPositions == null) { throw new ArgumentNullException(nameof(innerPositions)); } _innerPositions = innerPositions; decimal?beginValue = null; decimal?currentValue = null; decimal?blockedValue = null; foreach (var position in _innerPositions) { var mult = portfolio.Weights[position.Portfolio]; if (beginValue == null) { beginValue = mult * position.BeginValue; } else { beginValue += mult * position.BeginValue; } if (currentValue == null) { currentValue = mult * position.CurrentValue; } else { currentValue += mult * position.CurrentValue; } if (blockedValue == null) { blockedValue = mult * position.BlockedValue; } else { blockedValue += mult * position.BlockedValue; } } BeginValue = beginValue; BlockedValue = blockedValue; CurrentValue = currentValue; }