/// <summary> /// Gets the quoted asset set. /// </summary> /// <returns></returns> public sealed override void Build(ILogger logger, ICoreCache cache, string nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar) { var pricingStructureId = (RateCurveIdentifier)PricingStructureIdentifier; //Order the assets. PriceableRateSpreadAssets = PriceableRateSpreadAssets.OrderBy(a => a.GetRiskMaturityDate()).ToList(); var termCurve = SetConfigurationData(); //Get the reference interpolated curve. termCurve.point = RateSpreadBootstrapper.Bootstrap(PriceableRateSpreadAssets,//TODO what about the interpoation. BaseCurve, pricingStructureId.BaseDate, termCurve.extrapolationPermitted, Tolerance); CreatePricingStructure(pricingStructureId, termCurve, PriceableAssetFactory.Parse(PriceableRateSpreadAssets)); SetInterpolator(BaseCurve, pricingStructureId.PricingStructureType); // Set the Zero curve, just for reference YieldCurveValuation yieldCurveValuation = GetYieldCurveValuation(); if (yieldCurveValuation.zeroCurve?.rateCurve == null) { //var curveId = (RateCurveIdentifier)PricingStructureIdentifier; //var psType = PricingStructureIdentifier.PricingStructureType; TermCurve curve = YieldCurveAnalytics.ToZeroCurve(termCurve, GetBaseDate(), CompoundingFrequency, DayCounter); curve.interpolationMethod = InterpolationMethodHelper.Parse(Holder.GetValue("CurveInterpolation")); var zeroCurve = new ZeroRateCurve { rateCurve = curve, compoundingFrequency = FpML.V5r3.Reporting.CompoundingFrequency.Create(CompoundingFrequency) }; yieldCurveValuation.zeroCurve = zeroCurve; } }
/// <summary> /// Initializes a new instance of the <see cref="RateBasisCurve"/> class. /// </summary> /// <param name="referenceCurve">The reference curve.</param> /// <param name="spreadAssets">The spreads by asset.</param> /// <param name="properties">The properties of the new spread curve.</param> /// <param name="algorithm">The algorithm holder. </param> public RateBasisCurve(NamedValueSet properties, IRateCurve referenceCurve, List <IPriceableRateSpreadAssetController> spreadAssets, PricingStructureAlgorithmsHolder algorithm) : base(properties, algorithm) { PricingStructureData = new PricingStructureData(CurveType.Child, AssetClass.Rates, properties); //Set the identifier. var pricingStructureId = GetRateCurveId(); if (pricingStructureId.PricingStructureType != PricingStructureTypeEnum.RateBasisCurve) { return; } //Set the reference curve BaseCurve = referenceCurve; ReferenceCurveId = BaseCurve.GetPricingStructureId(); PriceableRateSpreadAssets = spreadAssets; //Order the assets. PriceableRateSpreadAssets = PriceableRateSpreadAssets.OrderBy(a => a.GetRiskMaturityDate()).ToList(); var termCurve = SetConfigurationData(); //Get the reference interpolated curve. termCurve.point = RateSpreadBootstrapper.Bootstrap(PriceableRateSpreadAssets, BaseCurve, pricingStructureId.BaseDate, termCurve.extrapolationPermitted, Tolerance); CreatePricingStructure(pricingStructureId, termCurve, PriceableAssetFactory.Parse(PriceableRateSpreadAssets)); SetInterpolator(BaseCurve, pricingStructureId.PricingStructureType); // Set the Zero curve, just for reference YieldCurveValuation yieldCurveValuation = GetYieldCurveValuation(); if (yieldCurveValuation.zeroCurve?.rateCurve == null) { //var curveId = (RateCurveIdentifier)PricingStructureIdentifier; //var psType = PricingStructureIdentifier.PricingStructureType; TermCurve curve = YieldCurveAnalytics.ToZeroCurve(termCurve, GetBaseDate(), CompoundingFrequency, DayCounter); curve.interpolationMethod = InterpolationMethodHelper.Parse(Holder.GetValue("CurveInterpolation")); var zeroCurve = new ZeroRateCurve { rateCurve = curve, compoundingFrequency = FpML.V5r3.Reporting.CompoundingFrequency.Create(CompoundingFrequency) }; yieldCurveValuation.zeroCurve = zeroCurve; } }
//TODO this is not yet implemented. FIX IT! internal void SetSpreadInterpolator(TermCurve discountFactorCurve, string algorithm, PricingStructureTypeEnum psType) { var curveId = (RateCurveIdentifier)PricingStructureIdentifier; // The underlying curve and associated compounding frequency (compounding frequency required when underlying curve is a ZeroCurve) CompoundingFrequency = EnumHelper.Parse <CompoundingFrequencyEnum>(Holder.GetValue("CompoundingFrequency")); UnderlyingInterpolatedCurve = Holder.GetValue("UnderlyingCurve"); //TODO this redundant. var interpDayCounter = Actual365.Instance; var underlyingCurve = ParseUnderlyingCurve(UnderlyingInterpolatedCurve); // interpolate the DiscountFactor curve based on the respective curve interpolation if (underlyingCurve != UnderlyingCurveTypes.ZeroCurve) { Interpolator = new TermCurveInterpolator(discountFactorCurve, GetBaseDate(), interpDayCounter); } // otherwise interpolate our underlying curve will be a zero curve else { var zeroCurve = new ZeroRateCurve { rateCurve = YieldCurveAnalytics.ToZeroCurve(discountFactorCurve, GetBaseDate(), CompoundingFrequency, DayCounter) }; zeroCurve.rateCurve.interpolationMethod = InterpolationMethodHelper.Parse(Holder.GetValue("CurveInterpolation")); zeroCurve.compoundingFrequency = FpML.V5r3.Reporting.CompoundingFrequency.Create(CompoundingFrequency); GetYieldCurveValuation().zeroCurve = zeroCurve; if (curveId.Algorithm == "SpreadInterpolation") { } else { Interpolator = new TermCurveInterpolator(GetYieldCurveValuation().zeroCurve.rateCurve, GetBaseDate(), interpDayCounter); }//TODO this is where to add the spread stuff. } }