/// <summary> /// Create European option pricer prior to valuation. /// </summary> protected override void CreateOption(double baseDate, VectorScopedCache.Scope cache) { var deal = (IDIOptionDeal)Deal; base.CreateOption(baseDate, cache); fEuroPricer = new EuropeanOption(deal.Option_Type, fStrike, deal.Expiry_Date, deal.Expiry_Date, deal.Expiry_Date, baseDate, cache, DayCount.BUS_252, deal.Calendar()); }
private static void CreateVectorArrays(Vector[] df, VectorScopedCache.Scope cache, Vector[] coupon, Vector[] coefficient, Vector[] stdDev) { int count = df.Length; VectorEngine.For(0, count, i => { df[i] = cache.GetClear(); coupon[i] = cache.GetClear(); coefficient[i] = cache.GetClear(); stdDev[i] = cache.GetClear(); return(LoopAction.Continue); }); }
/// <summary> /// Returns the energy option pricer. /// </summary> protected virtual EnergySpreadOptionPricer GetEnergyOptionPricer(ForwardPriceSample forwardSample, IReferencePrice referencePrice, ReferenceVol referenceVol, double baseDate, double tExpiry, double periodStart, double periodEnd, double realisedAverage, TDate realisedAverageDate, VectorScopedCache.Scope cache) { // Price samples List <TDate> priceSamples = forwardSample.GetSamplesList(periodStart, periodEnd).ToList(); return(new EnergySpreadOptionPricer( baseDate, tExpiry, priceSamples, forwardSample.Offset, realisedAverage, realisedAverageDate, referencePrice, referenceVol, fFxRate, fPriceFactorFxRate, fFxPayoffRate, cache)); }
/// <summary> /// Constructor. /// </summary> public CreditValuationParameters(DealCreditBase deal, CreditBaseValuation valuation, PriceFactorList factors, VectorScopedCache.Scope cache) { DF = DiscountRate.Get(factors, InterestRateUtils.GetRateId(deal.Discount_Rate, deal.Currency)); X = factors.GetInterface <IFxRate>(deal.Currency); SP = factors.GetInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.Survival_Probability) ? deal.Name : deal.Survival_Probability); RR = null; CR = null; DefaultTime = null; Weights = null; NamesDefaultedBeforeBaseDate = null; if (valuation.Respect_Default == YesNo.Yes) { List <string> names = new List <string>(); if (deal.ProtectionReferenceType() == DealCreditBase.ReferenceType.Single_Name) { names.Add(deal.Name); Weights = new double[] { 1.0 }; } else { IndexCDSPool indexCds = factors.Get <IndexCDSPool>(deal.Name); Weights = new double[indexCds.Names.Count]; for (int i = 0; i < indexCds.Names.Count; ++i) { names.Add(indexCds.Names[i].Name); Weights[i] = indexCds.Names[i].Weight; } } if (valuation.RequiresRecoveryOnDefault()) { RR = new RecoveryRate[names.Count]; for (int i = 0; i < names.Count; ++i) { RR[i] = factors.Get <RecoveryRate>(string.IsNullOrEmpty(deal.Recovery_Rate) ? names[i] : deal.Recovery_Rate); } } CR = new CreditRating[names.Count]; NamesDefaultedBeforeBaseDate = new bool[names.Count]; DefaultTime = new Vector[names.Count]; for (int i = 0; i < names.Count; ++i) { DefaultTime[i] = cache.Get(); CR[i] = factors.Get <CreditRating>(names[i]); NamesDefaultedBeforeBaseDate[i] = CreditRating.DefaultedBeforeBaseDate(CR[i], factors.BaseDate); CR[i].DefaultTime(DefaultTime[i]); } } }