/// <summary> /// Prepare for valuation anything that will be shared between scenarios. /// </summary> public override void PreCloneInitialize(PriceFactorList factors, BaseTimeGrid baseTimes, RequiredResults requiredResults) { base.PreCloneInitialize(factors, baseTimes, requiredResults); CommitmentDeal deal = (CommitmentDeal)Deal; // Add to valuation time grid fT.Add(deal.Effective_Date - 1.0); fT.Add(deal.Effective_Date); for (int i = 0; i < deal.Amortisation.Count; ++i) { fT.AddPayDate(deal.Amortisation[i].Date); } }
/// <summary> /// Calculate valuation profiles. /// </summary> public override void Value(ValuationResults valuationResults, PriceFactorList factors, BaseTimeGrid baseTimes) { PreValue(factors); TimeGridIterator tgi = new TimeGridIterator(fT); PVProfiles result = valuationResults.Profile; CommitmentDeal deal = (CommitmentDeal)Deal; VectorEngine.For(tgi, () => { if (tgi.Date < deal.Effective_Date) { result.AppendZeroVector(tgi.Date); } else { double amount = deal.Amortisation.GetPrincipal(deal.Amount, tgi.Date - 1.0); result.AppendVector(tgi.Date, fFxRate.Get(tgi.T) * amount); } }); result.Complete(fT); }