/// <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 discount factor.
        /// </summary>
        /// <param name="commodityCurve">The discount factor curve.</param>
        /// <param name="targetDate">The target date.</param>
        /// <param name="valuationDate">The valuation date.</param>
        /// <returns></returns>
        public decimal GetCommodityForward(ICommodityCurve commodityCurve, DateTime targetDate,
                                           DateTime valuationDate)
        {
            IPoint point          = new DateTimePoint1D(valuationDate, targetDate);
            var    discountFactor = (decimal)commodityCurve.Value(point);

            return(discountFactor);
        }
        /// <summary>
        /// Gets the index.
        /// </summary>
        /// <param name="discountFactorCurve">The discount factor curve.</param>
        /// <param name="targetDate">The target date.</param>
        /// <param name="valuationDate">The valuation date.</param>
        /// <returns></returns>
        protected decimal GetIndex(ICommodityCurve discountFactorCurve, DateTime targetDate,
                                   DateTime valuationDate)
        {
            IPoint point          = new DateTimePoint1D(valuationDate, targetDate);
            var    discountFactor = (decimal)discountFactorCurve.Value(point);

            return(discountFactor);
        }
        /// <summary>
        /// Gets the discount factor.
        /// </summary>
        /// <param name="commodityCurve">The fx curve.</param>
        /// <param name="targetDate">The target date.</param>
        /// <param name="valuationDate">The valuation date.</param>
        /// <returns></returns>
        public decimal GetIndexAtMaturity(ICommodityCurve commodityCurve, DateTime targetDate,
                                          DateTime valuationDate)
        {
            var point          = new DateTimePoint1D(valuationDate, targetDate);
            var discountFactor = (decimal)commodityCurve.Value(point);

            return(discountFactor);
        }
Exemple #5
0
        /// <summary>
        /// Bootstraps the specified priceable assets, where the assets
        /// are simple commodity asset with single cash flows on a
        /// single index observation.
        /// </summary>
        /// <param name="priceableAssets">The priceable assets.</param>
        /// <param name="referenceCurve">The reference curve.</param>
        /// <param name="baseDate">The base date.</param>
        /// <param name="extrapolationPermitted">The extrapolationPermitted flag.</param>
        /// <param name="tolerance">The tolerance for the solver</param>
        /// <param name="spreadXArray">THe spread interpolator produced in the bootstrapper</param>
        /// <param name="spreadYArray">THe spread interpolator produced in the bootstrapper</param>
        /// <returns></returns>
        public static TermPoint[] Bootstrap(IEnumerable <IPriceableCommoditySpreadAssetController> priceableAssets,
                                            ICommodityCurve referenceCurve, DateTime baseDate, bool extrapolationPermitted, double tolerance, ref IList <double> spreadXArray, ref IList <double> spreadYArray)
        {
            //only works for linear on zero.
            //InterpolationMethod interp = InterpolationMethodHelper.Parse("LinearInterpolation");
            //  Add the first element (date : discount factor) to the list
            var points = new Dictionary <DateTime, double>();
            var items
                = new SortedDictionary <DateTime, Pair <string, decimal> >();
            var dayCounter = new Actual365();

            foreach (var priceableAsset in priceableAssets)
            {
                DateTime assetMaturityDate = priceableAsset.GetRiskMaturityDate();
                if (points.Keys.Contains(assetMaturityDate))
                {
                    continue;
                }
                //This now should automatically extrapolate the required discount factor on a flat rate basis.
                if (IsSpreadAsset(priceableAsset))
                {
                    //These are simple assts so the solver is unnecessary.
                    var value    = (double)priceableAsset.CalculateImpliedQuoteWithSpread(referenceCurve);
                    var dayCount = dayCounter.YearFraction(baseDate, assetMaturityDate);
                    spreadXArray.Add(dayCount);
                    spreadYArray.Add((double)priceableAsset.MarketQuote.value);  //TODO Get the marketquote
                    points.Add(assetMaturityDate, value);
                    items.Add(assetMaturityDate,
                              new Pair <string, decimal>(priceableAsset.Id, (decimal)points[assetMaturityDate]));
                }
            }
            if (spreadXArray.Count > 2)
            {
                var spreadCurveInterpolator = new LinearInterpolation(spreadXArray.ToArray(),
                                                                      spreadYArray.ToArray());
                var index = 0;
                foreach (var assetMaturityDate in referenceCurve.GetTermCurve().GetListTermDates())
                {
                    if (points.Keys.Contains(assetMaturityDate))
                    {
                        continue;
                    }
                    var    dayCount    = dayCounter.YearFraction(baseDate, assetMaturityDate);
                    double spreadValue = spreadCurveInterpolator.ValueAt(dayCount, true);
                    var    value       = referenceCurve.GetForward(baseDate, assetMaturityDate);
                    points.Add(assetMaturityDate, value + spreadValue);
                    items.Add(assetMaturityDate,
                              new Pair <string, decimal>("RefCurvePillar_" + index, (decimal)points[assetMaturityDate]));
                    index++;
                }
                return(TermPointsFactory.Create(items));
            }
            return(null);
        }
        /// <summary>
        /// Evaluates the implied quote.
        /// </summary>
        /// <param name="priceableAssets">The priceable assets.</param>
        /// <param name="commodityCurve"></param>
        public NamedValueSet EvaluateImpliedQuote(IPriceableCommodityAssetController[] priceableAssets,
                                                  ICommodityCurve commodityCurve)
        {
            var result = new NamedValueSet();

            foreach (var priceableAsset in priceableAssets)
            {
                result.Set(priceableAsset.Id, priceableAsset.CalculateImpliedQuote(commodityCurve));
            }
            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="baseCurve"></param>
        /// <param name="spreadXArray"></param>
        /// <param name="spreadYArray"></param>
        /// <param name="psType"></param>
        protected void SetInterpolator(ICommodityCurve baseCurve, IList <double> spreadXArray, IList <double> spreadYArray, PricingStructureTypeEnum psType)
        {
            //var curveId = (RateCurveIdentifier)PricingStructureIdentifier;
            var interpDayCounter = Actual365.Instance;

            // interpolate the DiscountFactor curve based on the respective curve interpolation
            if (psType == PricingStructureTypeEnum.CommoditySpreadCurve)
            {
                Interpolator = new CommoditySpreadInterpolator2(baseCurve, spreadXArray, spreadYArray, true);
            }
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RateAssetQuote"/> class.
 /// </summary>
 /// <param name="priceableAsset">The priceable asset.</param>
 /// <param name="referenceCurve">The reference curve.</param>
 /// <param name="baseDate">The base date.</param>
 /// <param name="extrapolation">if set to <c>true</c> [extrapolation].</param>
 /// <param name="dfs">The DFS.</param>
 /// <param name="tolerance">The tolerance.</param>
 public CommoditySpreadAssetQuote2(IPriceableCommoditySpreadAssetController priceableAsset,
                                   ICommodityCurve referenceCurve, DateTime baseDate,
                                   bool extrapolation, IDictionary <DateTime, double> dfs, double tolerance)
 {
     PriceableAsset = priceableAsset;
     BaseDate       = baseDate;
     Dfs            = dfs;
     Extrapolation  = extrapolation;
     Tolerance      = tolerance;
     BaseCurve      = referenceCurve;
     MarketQuote    = PriceableAsset.CalculateImpliedQuoteWithSpread(BaseCurve);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommoditySpreadCurve2"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="cache">The cache.</param>
 ///  <param name="nameSpace">The client namespace</param>
 /// <param name="referenceCurve">The reference parent curveid.</param>
 /// <param name="spreadAssets">The spreads by asset.</param>
 /// <param name="properties">The properties of the new spread curve.</param>
 /// <param name="calendar">The calendar.</param>
 public CommoditySpreadCurve2(ILogger logger, ICoreCache cache, string nameSpace,
                              ICommodityCurve referenceCurve, FxRateSet spreadAssets, NamedValueSet properties,
                              IBusinessCalendar calendar)
     : base(logger, cache, nameSpace, ProcessQuotedAssetSet(logger, cache, nameSpace, referenceCurve, spreadAssets, properties, calendar), properties, calendar, calendar)
 {
     PricingStructureData = new PricingStructureData(CurveType.Child, AssetClass.Commodity, properties);
     BaseCurve            = referenceCurve;
     ReferenceCurveId     = BaseCurve.GetPricingStructureId();
     if (PricingStructureIdentifier.PricingStructureType != PricingStructureTypeEnum.CommoditySpreadCurve)
     {
         return;
     }
     //Set the spread sets.
     PriceableCommoditySpreadAssets = PriceableAssetFactory.CreatePriceableCommoditySpreadAssets(logger, cache, nameSpace, PricingStructureIdentifier.BaseDate, spreadAssets, calendar);
     Build(logger, cache, nameSpace, calendar, calendar);
 }
        /// <summary>
        /// Used to create the interpolation.
        /// </summary>
        /// <param name="baseCurve"></param>
        /// <returns></returns>
        public static IInterpolation CreateCommoditySpread(ICommodityCurve baseCurve)
        {
            var spreadInterpolation = new CommodityBasisSpreadInterpolation(baseCurve);

            return(spreadInterpolation);
        }
        /// <summary>
        /// Calculates the specified model data.
        /// </summary>
        /// <param name="modelData">The model data.</param>
        /// <returns></returns>
        public override BasicAssetValuation Calculate(IAssetControllerData modelData)
        {
            ModelData      = modelData;
            AnalyticsModel = new CommodityAssetAnalytic();
            //DependencyCreator.Resolve<IModelAnalytic<ICommodityAssetParameters, CommodityMetrics>>(_modelIdentifier);
            var metrics = MetricsHelper.GetMetricsToEvaluate(Metrics, AnalyticsModel.Metrics);
            // Determine if DFAM has been requested - if so thats all we evaluate - every other metric is ignored
            var bEvalForwardAtMaturity = false;

            if (metrics.Contains(CommodityMetrics.IndexAtMaturity))
            {
                bEvalForwardAtMaturity = true;
                metrics.RemoveAll(
                    metricItem => metricItem != CommodityMetrics.IndexAtMaturity);
            }
            ICommodityAssetParameters analyticModelParameters = new CommodityAssetParameters();

            AnalyticResults = new CommodityAssetResults();
            var metricsToEvaluate = metrics.ToArray();
            var marketEnvironment = modelData.MarketEnvironment;
            //1. instantiate curve
            ICommodityCurve commodityCurve = null;

            //1. instantiate curve
            if (marketEnvironment.GetType() == typeof(SimpleMarketEnvironment))
            {
                commodityCurve     = (ICommodityCurve)((ISimpleMarketEnvironment)marketEnvironment).GetPricingStructure();
                CommodityCurveName = commodityCurve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(SimpleCommodityMarketEnvironment))
            {
                commodityCurve     = ((ISimpleCommodityMarketEnvironment)marketEnvironment).GetCommodityCurve();
                CommodityCurveName = commodityCurve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(SwapLegEnvironment))
            {
                commodityCurve     = ((ISwapLegEnvironment)marketEnvironment).GetCommodityCurve();
                CommodityCurveName = commodityCurve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(MarketEnvironment))
            {
                commodityCurve = (ICommodityCurve)modelData.MarketEnvironment.GetPricingStructure(CommodityCurveName);
            }
            //3. Get the Rate
            if (CommodityValue != null)
            {
                analyticModelParameters.CommodityForward = CommodityValue.value;
            }
            if (bEvalForwardAtMaturity)
            {
                //4. Set the anaytic input parameters and Calculate the respective metrics
                AnalyticResults =
                    AnalyticsModel.Calculate <ICommodityAssetResults, CommodityAssetResults>(analyticModelParameters,
                                                                                             metricsToEvaluate);
                //_forwardAtMaturity = ForwardAtMaturity;
            }
            else
            {
                analyticModelParameters.NotionalAmount = NotionalAmount;
                IDayCounter dc = Actual365.Instance;
                analyticModelParameters.YearFraction = (decimal)dc.YearFraction(modelData.ValuationDate, RiskMaturityDate);
                //3. Get the end discount factor - Need to fix this.
                analyticModelParameters.CommodityCurveForward =
                    GetIndexAtMaturity(commodityCurve, GetRiskMaturityDate(), modelData.ValuationDate);

                //4. Set the anaytic input parameters and Calculate the respective metrics
                AnalyticResults =
                    AnalyticsModel.Calculate <ICommodityAssetResults, CommodityAssetResults>(analyticModelParameters,
                                                                                             metricsToEvaluate);
            }
            return(GetValue(AnalyticResults));
        }
        /// <summary>
        /// Calculates the specified model data.
        /// </summary>
        /// <param name="modelData">The model data.</param>
        /// <returns></returns>
        public override BasicAssetValuation Calculate(IAssetControllerData modelData)
        {
            ModelData      = modelData;
            AnalyticsModel = new CommodityFuturesAssetAnalytic();
            //DependencyCreator.Resolve<IModelAnalytic<ICommodityFuturesAssetParameters, CommodityMetrics>>(_modelIdentifier);
            var metrics = MetricsHelper.GetMetricsToEvaluate(Metrics, AnalyticsModel.Metrics);
            // Determine if DFAM has been requested - if so that is all we evaluate - every other metric is ignored
            var bEvalIndexAtMaturity = false;

            if (metrics.Contains(CommodityMetrics.IndexAtMaturity))
            {
                bEvalIndexAtMaturity = true;
                //  remove all except DiscountFactorAtMaturity metric
                //
                metrics.RemoveAll(metricItem => metricItem != CommodityMetrics.IndexAtMaturity);
            }
            var metricsToEvaluate = metrics.ToArray();
            ICommodityFuturesAssetParameters analyticModelParameters = new CommodityFuturesAssetParameters
            {
                UnitAmount   = Amount,
                TimeToExpiry = TimeToExpiry
            };
            var marketEnvironment = modelData.MarketEnvironment;
            //1. instantiate curve
            ICommodityCurve commodityCurve = null;

            //1. instantiate curve
            if (marketEnvironment.GetType() == typeof(SimpleMarketEnvironment))
            {
                commodityCurve = (ICommodityCurve)((ISimpleMarketEnvironment)marketEnvironment).GetPricingStructure();
                CurveName      = commodityCurve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(SimpleCommodityMarketEnvironment))
            {
                commodityCurve = ((ISimpleCommodityMarketEnvironment)marketEnvironment).GetCommodityCurve();
                CurveName      = commodityCurve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(SwapLegEnvironment))
            {
                commodityCurve = ((ISwapLegEnvironment)marketEnvironment).GetCommodityCurve();
                CurveName      = commodityCurve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(MarketEnvironment))
            {
                commodityCurve = (ICommodityCurve)modelData.MarketEnvironment.GetPricingStructure(CurveName);
            }
            //4. Get the Index
            analyticModelParameters.Index = CommodityValue.value;
            if (bEvalIndexAtMaturity)
            {
                //5. Set the analytic input parameters and Calculate the respective metrics
                AnalyticResults =
                    AnalyticsModel.Calculate <ICommodityAssetResults, CommodityAssetResults>(analyticModelParameters,
                                                                                             metricsToEvaluate);
                ForwardIndex = IndexAtMaturity;
            }
            else
            {
                //4. Get the end discount factor
                ForwardIndex = GetCommodityForward(commodityCurve, GetRiskMaturityDate(), modelData.ValuationDate);
                analyticModelParameters.Index = IndexAtMaturity;
                //5. Get the TimeToExpiry
                analyticModelParameters.TimeToExpiry = GetTimeToExpiry();
                //6. Get the position
                analyticModelParameters.Position = Position;
                //7. Set the analytic input parameters and Calculate the respective metrics
                AnalyticResults =
                    AnalyticsModel.Calculate <ICommodityAssetResults, CommodityAssetResults>(analyticModelParameters,
                                                                                             metricsToEvaluate);
            }
            return(GetValue(AnalyticResults));
        }
Exemple #13
0
 /// <summary>
 /// This assumes that the rest dates are consistent with the curve.
 /// </summary>
 /// <param name="valuationDate"></param>
 /// <param name="paymentDate">The payment date. The same rest period is assumed as with the spot date.</param>
 /// <param name="indexCurve">The index curve should be already in the correct form for the fx.</param>
 /// <param name="currency1">Normally the domestic rate curve. </param>
 public CommoditySwapLegAnalytic(DateTime valuationDate, DateTime paymentDate, ICommodityCurve indexCurve, IRateCurve currency1)
 {
     //ToReportingCurrencyRate = EvaluateReportingCurrencyFxRate(valuationDate, reportingCurrencyFxCurve);
     var todayRate = indexCurve.GetForward(valuationDate, valuationDate); //TODO The spot rate may not be the same due to the carry effect, but the evolution works.
     var df1       = currency1.GetDiscountFactor(valuationDate, paymentDate);
 }
Exemple #14
0
 /// <summary>
 /// This assumes that the rest dates are consistent with the curve.
 /// </summary>
 /// <param name="valuationDate"></param>
 /// <param name="paymentDate"></param>
 /// <param name="indexCurve"></param>
 public CommoditySwapLegAnalytic(DateTime valuationDate, DateTime paymentDate, ICommodityCurve indexCurve)
 {
     //ToReportingCurrencyRate = EvaluateReportingCurrencyFxRate(valuationDate, reportingCurrencyFxCurve);
     Units = (decimal)indexCurve.GetForward(valuationDate, paymentDate);
 }
 /// <summary>
 /// SimpleDiscountFactorCurve
 /// </summary>
 /// <param name="referenceCurve"></param>
 /// <param name="baseDate"></param>
 /// <param name="extrapolation"></param>
 /// <param name="dfs"></param>
 public SimpleSpreadDiscountFactorCurve(ICommodityCurve referenceCurve, DateTime baseDate, bool extrapolation,
                                        IDictionary <DateTime, double> dfs)
     : base(new DiscreteCurve(PointCurveHelper(baseDate, dfs.Keys), dfs.Values.ToList()), InterpolationFactory.CreateCommoditySpread(referenceCurve), extrapolation)
 {
     BaseDate = baseDate;
 }
Exemple #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RateSpreadAssetQuote"/> class.
 /// </summary>
 /// <param name="priceableAsset">The priceable asset.</param>
 /// <param name="referenceCurve">The reference curve.</param>
 /// <param name="baseDate">The base date.</param>
 /// <param name="extrapolation">if set to <c>true</c> [extrapolation].</param>
 /// <param name="dfs">The DFS.</param>
 public CommoditySpreadAssetQuote2(IPriceableCommoditySpreadAssetController priceableAsset, ICommodityCurve referenceCurve, DateTime baseDate,
                                   bool extrapolation, IDictionary <DateTime, double> dfs)
     : this(priceableAsset, referenceCurve, baseDate, extrapolation, dfs, DefaultTolerance)
 {
 }
 /// <summary>
 /// The other ctor.
 /// </summary>
 /// <param name="referenceCurve"></param>
 /// <param name="zeroSpreadCurve"></param>
 /// <param name="baseDate"></param>
 /// <param name="dayCounter"></param>
 public CommoditySpreadInterpolator2(ICommodityCurve referenceCurve, TermCurve zeroSpreadCurve, DateTime baseDate, IDayCounter dayCounter)
     : base(Converter(zeroSpreadCurve, baseDate, dayCounter), new CommodityBasisSpreadInterpolation(referenceCurve), IsExtrapolationPermitted(zeroSpreadCurve))
 {
 }
        /// <summary>
        /// Calculates the specified model data.
        /// </summary>
        /// <param name="modelData">The model data.</param>
        /// <returns></returns>
        public override BasicAssetValuation Calculate(IAssetControllerData modelData)
        {
            ModelData      = modelData;
            AnalyticsModel = new CommoditySpreadAssetAnalytic();
            //DependencyCreator.Resolve<IModelAnalytic<ISimpleAssetParameters, SpreadMetrics>>(_modelIdentifier);
            var metrics = MetricsHelper.GetMetricsToEvaluate(Metrics, AnalyticsModel.Metrics);
            // Determine if DFAM has been requested - if so thats all we evaluate - every other metric is ignored
            var bEvalDiscountFactorAtMaturity = false;

            if (metrics.Contains(CommoditySpreadMetrics.IndexAtMaturity))
            {
                bEvalDiscountFactorAtMaturity = true;
                metrics.RemoveAll(
                    metricItem => metricItem != CommoditySpreadMetrics.IndexAtMaturity);
            }
            var analyticModelParameters = new CommodityAssetParameters();

            AnalyticResults = new CommoditySpreadAssetResults();
            var             metricsToEvaluate = metrics.ToArray();
            var             marketEnvironment = modelData.MarketEnvironment;
            ICommodityCurve curve             = null;

            //1. instantiate curve
            if (marketEnvironment.GetType() == typeof(SimpleMarketEnvironment))
            {
                curve     = (ICommodityCurve)((ISimpleMarketEnvironment)marketEnvironment).GetPricingStructure();
                CurveName = curve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(SimpleCommodityMarketEnvironment))
            {
                curve     = ((ISimpleCommodityMarketEnvironment)marketEnvironment).GetCommodityCurve();
                CurveName = curve.GetPricingStructureId().UniqueIdentifier;
            }
            if (marketEnvironment.GetType() == typeof(MarketEnvironment))
            {
                curve = (ICommodityCurve)modelData.MarketEnvironment.GetPricingStructure(CurveName);
            }
            var endDF = GetIndex(curve, RiskMaturityDate, modelData.ValuationDate);

            Values = new[] { endDF };
            //3. Get the end discount factor
            analyticModelParameters.CommodityForward = endDF;
            if (Spread != null)
            {
                analyticModelParameters.Spread = MarketQuoteHelper.NormaliseGeneralPriceUnits(SpreadQuotationType, Spread, "Price").value;
            }
            if (bEvalDiscountFactorAtMaturity)
            {
                //4. Set the anaytic input parameters and Calculate the respective metrics
                AnalyticResults =
                    AnalyticsModel.Calculate <ICommoditySpreadAssetResults, CommoditySpreadAssetResults>(analyticModelParameters,
                                                                                                         metricsToEvaluate);
                ValueAtMaturity = AnalyticResults.IndexAtMaturity;
            }
            else
            {
                //4. Set the anaytic input parameters and Calculate the respective metrics
                AnalyticResults =
                    AnalyticsModel.Calculate <ICommoditySpreadAssetResults, CommoditySpreadAssetResults>(analyticModelParameters,
                                                                                                         metricsToEvaluate);
            }
            return(GetValue(AnalyticResults));
        }
 /// <summary>
 /// Evaluates the implied quote.
 /// </summary>
 /// <param name="commodityCurve">The rate curve.</param>
 /// <param name="priceableAssets">The priceable assets.</param>
 public NamedValueSet EvaluateImpliedQuote(ICommodityCurve commodityCurve, IPriceableCommodityAssetController[] priceableAssets)
 {
     return(EvaluateImpliedQuote(priceableAssets, commodityCurve));
 }
        //Clones a curve, maps the quoted assets specified and then returns an FpML structure back.
        //
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="nameSpace"></param>
        /// <param name="referenceCurve"></param>
        /// <param name="spreadValues"></param>
        /// <param name="properties"></param>
        /// <param name="calendar"></param>
        /// <returns></returns>
        public static Pair <PricingStructure, PricingStructureValuation> ProcessQuotedAssetSet(ILogger logger, ICoreCache cache,
                                                                                               string nameSpace, ICommodityCurve referenceCurve, FxRateSet spreadValues, NamedValueSet properties, IBusinessCalendar calendar)
        {
            var identifier = new CommodityCurveIdentifier(properties);
            //Clone the ref curves.
            //
            Pair <PricingStructure, PricingStructureValuation> fpml = CloneCurve(referenceCurve.GetFpMLData(), identifier.UniqueIdentifier);

            if (identifier.PricingStructureType != PricingStructureTypeEnum.CommoditySpreadCurve)
            {
                var ycvCurveCloned = (FxCurveValuation)fpml.Second;
                //  assign id to the cloned YieldCurve
                //
                ycvCurveCloned.fxForwardCurve.point = null;
                ycvCurveCloned.fxForwardCurve       = null;
                //Manipulate the quated asset set.
                ycvCurveCloned.spotRate = MappedQuotedAssetSet(logger, cache, nameSpace, referenceCurve, spreadValues,
                                                               properties, calendar);
            }
            return(fpml);
        }
Exemple #21
0
 /// <summary>
 /// Constructor for the <see cref="CommodityBasisSpreadInterpolation"/> class that
 /// transfers the array of x and y values into the data structure that
 /// stores (x,y) points into ascending order based on the x-value of
 /// each point.
 /// </summary>
 public CommodityBasisSpreadInterpolation(ICommodityCurve baseCurve)
 {
     BaseCurve = baseCurve;
 }
 /// <summary>
 /// The main ctor.
 /// </summary>
 /// <param name="referenceCurve"></param>
 /// <param name="xArray"></param>
 /// <param name="yArray"></param>
 /// <param name="extrapolate"></param>
 public CommoditySpreadInterpolator2(ICommodityCurve referenceCurve, IList <double> xArray, IList <double> yArray, bool extrapolate)
     : base(new DiscreteCurve(xArray, yArray), new CommodityBasisSpreadInterpolation2(referenceCurve), extrapolate)
 {
 }