예제 #1
0
                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;
                }
예제 #2
0
            public WeightsDictionary(WeightedPortfolio parent)
            {
                if (parent == null)
                {
                    throw new ArgumentNullException("parent");
                }

                _parent = parent;
            }
예제 #3
0
            public WeightsDictionary(WeightedPortfolio parent, IConnector connector)
            {
                if (parent == null)
                {
                    throw new ArgumentNullException(nameof(parent));
                }

                _parent    = parent;
                _connector = connector;
            }
예제 #4
0
                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;
                }