/// <summary> /// Initializes a new instance of the <see cref="CommoditySpreadCurve2"/> 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 alogorithm holder. </param> public CommoditySpreadCurve2(NamedValueSet properties, ICommodityCurve referenceCurve, List <IPriceableCommoditySpreadAssetController> spreadAssets, PricingStructureAlgorithmsHolder algorithm) : base(properties, algorithm) { PricingStructureData = new PricingStructureData(CurveType.Child, AssetClass.Commodity, properties); //Set the identifier. var pricingStructureId = GetCommodityCurveId(); if (pricingStructureId.PricingStructureType != PricingStructureTypeEnum.CommoditySpreadCurve) { return; } //Set the reference curve BaseCurve = referenceCurve; ReferenceCurveId = BaseCurve.GetPricingStructureId(); PriceableCommoditySpreadAssets = spreadAssets; //Order the assets. PriceableCommoditySpreadAssets = PriceableCommoditySpreadAssets.OrderBy(a => a.GetRiskMaturityDate()).ToList(); var termCurve = SetConfigurationData(); //Get the reference interpolated curve. IList <Double> xArray = new List <double>(); IList <Double> yArray = new List <double>(); termCurve.point = CommoditySpreadBootstrapper2.Bootstrap(PriceableCommoditySpreadAssets, BaseCurve, pricingStructureId.BaseDate, termCurve.extrapolationPermitted, Tolerance, ref xArray, ref yArray); CreatePricingStructure(pricingStructureId, termCurve, PriceableAssetFactory.Parse(PriceableCommoditySpreadAssets)); SetInterpolator(BaseCurve, xArray, yArray, pricingStructureId.PricingStructureType); }
/// <summary> /// Gets the quoted asset set. /// </summary> /// <returns></returns> public override void Build(ILogger logger, ICoreCache cache, string nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar) { var pricingStructureId = (CommodityCurveIdentifier)PricingStructureIdentifier; //Order the assets. PriceableCommoditySpreadAssets = PriceableCommoditySpreadAssets.OrderBy(a => a.GetRiskMaturityDate()).ToList(); var termCurve = SetConfigurationData(); //Get the reference interpolated curve. IList <Double> xArray = new List <double>(); IList <Double> yArray = new List <double>(); termCurve.point = CommoditySpreadBootstrapper2.Bootstrap(PriceableCommoditySpreadAssets,//TODO what about the interpoation. BaseCurve, pricingStructureId.BaseDate, termCurve.extrapolationPermitted, Tolerance, ref xArray, ref yArray); CreatePricingStructure(pricingStructureId, termCurve, PriceableAssetFactory.Parse(PriceableCommoditySpreadAssets)); SetInterpolator(BaseCurve, xArray, yArray, pricingStructureId.PricingStructureType);//TOTO Modify with the actual spreads.... }