private void InitialiseInstance(ILogger logger, ICoreCache cache, string nameSpace, PricingStructureIdentifier curveId, DateTime baseDate, FxRateSet assetSet, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar, double tolerance) { FixingCalendar = fixingCalendar; PaymentCalendar = rollCalendar; // The bootstrapper to use // BootstrapperName = Holder.GetValue("Bootstrapper"); var termCurve = new TermCurve { extrapolationPermitted = bool.Parse(Holder.GetValue("ExtrapolationPermitted")), extrapolationPermittedSpecified = true, interpolationMethod = InterpolationMethodHelper.Parse( Holder.GetValue("BootstrapperInterpolation")) }; PriceableCommodityAssets = PriceableAssetFactory.CreatePriceableCommodityAssets(logger, cache, nameSpace, curveId.BaseDate, assetSet, fixingCalendar, rollCalendar); termCurve.point = CommodityBootstrapper.Bootstrap(PriceableCommodityAssets, curveId.BaseDate, termCurve.extrapolationPermitted, termCurve.interpolationMethod, tolerance); // Pull out the fx curve and fx curve valuation // var quotedAssetSet = PriceableCommodityAssets != null?PriceableAssetFactory.Parse(PriceableCommodityAssets) : assetSet; var fpmlData = CreateFpMLPair(baseDate, curveId, quotedAssetSet, termCurve); //Bootstrapper = Bootstrap(bootstrapperName, fpmlData.First, fpmlData.Second); SetFpMLData(fpmlData); // Interpolate the DiscountFactor curve based on the respective curve interpolation // SetInterpolator(baseDate, Holder); }
/// <summary> /// Builds this instance. /// </summary> public override void Build(ILogger logger, ICoreCache cache, string nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar) { PriceableCommodityAssets = PriceableAssetFactory.CreatePriceableCommodityAssets(logger, cache, nameSpace, GetFxCurveValuation().baseDate.Value, GetFxCurveValuation().spotRate, fixingCalendar, rollCalendar); var termCurve = ((FxCurveValuation)PricingStructureValuation).fxForwardCurve; termCurve.point = CommodityBootstrapper.Bootstrap(PriceableCommodityAssets, GetFxCurveValuation().baseDate.Value, termCurve.extrapolationPermitted, termCurve.interpolationMethod); SetFpMLData(new Pair <PricingStructure, PricingStructureValuation>(PricingStructure, PricingStructureValuation)); SetInterpolator(GetFxCurveValuation().baseDate.Value, Holder); }
/// <summary> /// Initializes a new instance of the <see cref="RateCurve"/> class. /// This constructor is used to clone perturbed copies of a base curve. /// </summary> /// <param name="priceableCommodityAssets">The priceable Commodity Assets.</param> /// <param name="pricingStructureAlgorithmsHolder">The pricingStructureAlgorithmsHolder.</param> /// <param name="curveProperties">The Curve Properties.</param> public CommodityCurve(NamedValueSet curveProperties, List <IPriceableCommodityAssetController> priceableCommodityAssets, PricingStructureAlgorithmsHolder pricingStructureAlgorithmsHolder) : this(curveProperties, pricingStructureAlgorithmsHolder) { var curveId = GetCommodityCurveId(); var termCurve = SetConfigurationData(); PriceableCommodityAssets = priceableCommodityAssets; termCurve.point = CommodityBootstrapper.Bootstrap(PriceableCommodityAssets, curveId.BaseDate, termCurve.extrapolationPermitted, termCurve.interpolationMethod, Tolerance); CreatePricingStructure(curveId, termCurve, PriceableCommodityAssets, null); // Interpolate the DiscountFactor curve based on the respective curve interpolation SetInterpolator(curveId.BaseDate, Holder); }
/// <summary> /// Initializes a new instance of the <see cref="CommodityCurve"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">The client namespace</param> /// <param name="fpmlData">The FPML data.</param> /// <param name="properties">The properties.</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="rollCalendar">The rollCalendar.</param> public CommodityCurve(ILogger logger, ICoreCache cache, string nameSpace, Pair <PricingStructure, PricingStructureValuation> fpmlData, NamedValueSet properties, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar) : base(logger, cache, nameSpace, fpmlData, new CommodityCurveIdentifier(properties)) { PricingStructureData = new PricingStructureData(CurveType.Parent, AssetClass.Commodity, properties); if (fpmlData == null) { return; } FixingCalendar = fixingCalendar; PaymentCalendar = rollCalendar; var tempFpML = (FxCurveValuation)fpmlData.Second; // Use default algorithm name // Algorithm = DefaultAlgorithName; var termCurve = SetConfigurationData(); //SetFpMLData(fpmlData); BootstrapperName = Holder.GetValue("Bootstrapper"); var bootstrap = PropertyHelper.ExtractBootStrapOverrideFlag(properties); // If there's no forward points - do build the curve. // //This is to catch it when there are no discount factor points. var discountsAbsent = tempFpML.fxForwardCurve == null || tempFpML.fxForwardCurve.point == null || tempFpML.fxForwardCurve.point.Length == 0; if (cache == null) { //optimize = true; bootstrap = false; } bool doBuild = (tempFpML.spotRate != null) && discountsAbsent; if (bootstrap || doBuild) { var qas = tempFpML.spotRate; PriceableCommodityAssets = PriceableAssetFactory.CreatePriceableCommodityAssets(logger, cache, nameSpace, tempFpML.baseDate.Value, qas, fixingCalendar, rollCalendar); var point = CommodityBootstrapper.Bootstrap(PriceableCommodityAssets, tempFpML.baseDate.Value, termCurve.extrapolationPermitted, termCurve.interpolationMethod); ((FxCurveValuation)fpmlData.Second).fxForwardCurve.point = point; } SetInterpolator(PricingStructureValuation.baseDate.Value, Holder); }