Esempio n. 1
0
        public void Process()
        {
            var currentFixingDate = _assetFxModel.BuildDate;

            while (currentFixingDate <= _endDate)
            {
                currentFixingDate = currentFixingDate.AddDays(1);
                _assetFxModel     = _assetFxModel.RollModel(currentFixingDate, _currencyProvider);
            }

            ParallelUtils.Instance.For(0, _calculationDates.Length, 1, i =>
            {
                var d        = _calculationDates[i];
                var epe      = _epeValues[i];
                var newModel = _assetFxModel.Clone();
                newModel.OverrideBuildDate(d);

                var ead     = _portfolio.SaCcrEAD(epe, newModel, _reportingCurrency, _assetIdToGroupMap);
                var capital = _counterpartyRiskWeight * ead;
                if (!_ead.ContainsKey(d))
                {
                    lock (_threadLock)
                    {
                        if (!_ead.ContainsKey(d))
                        {
                            _ead.Add(d, 0.0);
                        }
                    }
                }
                if (double.IsNaN(capital) || double.IsInfinity(capital))
                {
                    throw new Exception("Invalid capital generated");
                }

                lock (_threadLock)
                {
                    _ead[d] += capital;
                }
            }).Wait();
        }