/// <summary> /// Prepare for valuation anything that is not dependent upon the scenario. /// </summary> public override void HeadNodeInitialize(PriceFactorList factors, BaseTimeGrid baseTimes, RequiredResults resultsRequired) { base.HeadNodeInitialize(factors, baseTimes, resultsRequired); var deal = (AverageForwardExplicitDealBase)Deal; fScale = (deal.Buy_Sell == BuySell.Buy ? +1 : -1) * deal.GetUnits(); fSamplingTimes = new double[deal.Sampling_Data.Count]; fSamplingTimesPlusTenor = new double[deal.Sampling_Data.Count]; int index = 0; Term tenorAsTerm = Period.ValueToTerm(deal.Tenor); // Loop over sampling dates and generate relevant sampling times. foreach (SamplingEntryAsset sample in deal.Sampling_Data) { double endDate = DateAdjuster.Add(sample.Date, tenorAsTerm, deal.GetHolidayCalendar()); double sampleTime = CalcUtils.DaysToYears(sample.Date - factors.BaseDate); // Store the start time and the end time. fSamplingTimes[index] = sampleTime; // Discount Factor and Forward Factor times are in Act365. fSamplingTimesPlusTenor[index] = CalcUtils.DaysToYears(endDate - factors.BaseDate); index++; } // Create a deep copy of the sampling data list and replace missing values with data from the rate fixings file var assetPrice = ((BaseAssetFxDealHelper)deal.GetDealHelper()).GetAssetPrice(factors); string assetCurrency = fPayoffType == PayoffType.Compo ? fPayoffCurrency : fCurrency; fSamplingData = deal.Sampling_Data.FillMissingDataFromFixings(factors.RateFixings, factors, assetPrice, assetCurrency, deal, "calculation of asset average"); // Add to valuation time grid fT.AddPayDate(deal.Maturity_Date, resultsRequired.CashRequired()); }
/// <summary> /// Initializes a new instance of the <see cref="AverageForwardExplicitDealBase"/> class. /// </summary> protected AverageForwardExplicitDealBase() { Sampling_Data = new SamplingEntryList <SamplingEntryAsset>(); }