Exemple #1
0
        //Backs out the implied quotes for the asset provided and adds the spread to it.
        //
        protected static QuotedAssetSet MappedQuotedAssetSet(ILogger logger, ICoreCache cache,
                                                             string nameSpace, IInterpolatedSpace referenceCurve, QuotedAssetSet spreadValues,
                                                             NamedValueSet properties, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
        {
            var index    = 0;
            var baseDate = properties.GetValue <DateTime>(CurveProp.BaseDate);

            //Find the backed out implied quote for each asset.
            //
            foreach (var asset in spreadValues.instrumentSet.Items)
            {
                NamedValueSet namedValueSet = PriceableAssetFactory.BuildPropertiesForAssets(nameSpace, asset.id, baseDate);
                var           quote         = spreadValues.assetQuote[index];
                //Get the implied quote to use as the input market quote. Make sure it is rate controller.
                var priceableAsset = (PriceableRateAssetController)PriceableAssetFactory.Create(logger, cache, nameSpace, quote, namedValueSet, fixingCalendar, rollCalendar);
                var value          = priceableAsset.CalculateImpliedQuote(referenceCurve);
                //Replace the market quote in the bav and remove the spread.
                var quotes       = new List <BasicQuotation>(quote.quote);
                var impliedQuote = MarketQuoteHelper.ReplaceQuotationByMeasureType("MarketQuote", quotes, value);
                var marketQuote  = new List <BasicQuotation>(impliedQuote);
                spreadValues.assetQuote[index].quote = MarketQuoteHelper.MarketQuoteRemoveSpreadAndNormalise(marketQuote);
                index++;
            }
            return(spreadValues);
        }
        /// <summary>
        /// Gets the vol.
        /// </summary>
        /// <param name="volCurve">The vol curve.</param>
        /// <param name="expiry">The expiry.</param>
        /// <returns></returns>
        public double GetCurveVolatility(IInterpolatedSpace volCurve, Double expiry)
        {
            IPoint point = new Point1D(expiry);
            var    vol   = volCurve.Value(point);

            return(vol);
        }
Exemple #3
0
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            if (UseSimpleModel)
            {
                return(IndexAtMaturity);
            }
            if (AnalyticsModel == null)
            {
                AnalyticsModel = new CommodityAverageAssetAnalytic();
            }
            ICommodityAverageAssetParameters analyticModelParameters = new CommodityAverageAssetParameters
            {
                StartIndex =
                    GetIndexAtMaturity(interpolatedSpace,
                                       AdjustedStartDate, BaseDate),
            };

            //3. Get the Index
            //
            if (MarketQuote != null)
            {
                analyticModelParameters.AverageIndex = MarketQuoteHelper.NormalisePriceUnits(MarketQuote, "DecimalRate").value;
            }
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            AnalyticResults = AnalyticsModel.Calculate <ICommodityAssetResults, CommodityAssetResults>(analyticModelParameters, new[] { CommodityMetrics.IndexAtMaturity });
            return(CalculationResults.IndexAtMaturity);
        }
Exemple #4
0
        /// <summary>
        /// Calculates the specified model data.
        /// </summary>
        /// <param name="interpolatedSpace">The interpolatedSpace.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            AnalyticsModel = new SimpleSwapAssetAnalytic();
            //DependencyCreator.Resolve<IModelAnalytic<ISwapAssetParameters, RateMetrics>>("InflationSwapAsset");
            ISwapAssetParameters analyticModelParameters = new IRSwapAssetParameters();

            AnalyticResults = new RateAssetResults();
            //1. instantiate curve
            //var curve = (IRateCurve)modelData.MarketEnvironment.GetPricingStructure(_discountCurveName);
            //2. Set the rate
            analyticModelParameters.Rate = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value;
            //2. Get the discount factors
            analyticModelParameters.DiscountFactors =
                GetDiscountFactors(interpolatedSpace, AdjustedPeriodDates.ToArray(), BaseDate);
            //3. Get the respective year fractions
            analyticModelParameters.YearFractions = GetYearFractions();
            //4. Get the Weightings
            analyticModelParameters.Weightings =
                CreateWeightings(CDefaultWeightingValue, analyticModelParameters.DiscountFactors.Length);
            //5. Set the anaytic input parameters and Calculate the respective metrics
            AnalyticResults =
                AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters,
                                                                               new[] { RateMetrics.ImpliedQuote });
            return(AnalyticResults.ImpliedQuote);
        }
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                AnalyticsModel = new RateSpreadAssetAnalytic();
                // DependencyCreator.Resolve<IModelAnalytic<ISimpleAssetParameters, RateMetrics>>(_modelIdentifier);
            }
            //3. Get the Rate
            StartDiscountFactor = GetDiscountFactor(interpolatedSpace, AdjustedStartDate, BaseDate);
            EndDiscountFactor   = GetDiscountFactor(interpolatedSpace, RiskMaturityDate, BaseDate);
            ISimpleRateAssetParameters analyticModelParameters = new RateAssetParameters
            {
                YearFraction        = YearFraction,
                StartDiscountFactor =
                    StartDiscountFactor,
                EndDiscountFactor =
                    EndDiscountFactor
            };
            var fixedRate = GetRate(StartDiscountFactor, EndDiscountFactor, YearFraction);

            if (Spread != null)
            {
                analyticModelParameters.Rate = fixedRate + MarketQuoteHelper
                                               .NormaliseGeneralPriceUnits(SpreadQuotationType, Spread,
                                                                           "DecimalRate").value;
            }
            AnalyticResults = new RateSpreadAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            AnalyticResults =
                AnalyticsModel.Calculate <IRateSpreadAssetResults, RateSpreadAssetResults>(analyticModelParameters,
                                                                                           new[] { RateSpreadMetrics.ImpliedQuote });
            return(AnalyticResults.ImpliedQuote);
        }
Exemple #6
0
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateDiscountFactorAtMaturity(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                AnalyticsModel = new ZeroCouponRateAssetAnalytic();
                // DependencyCreator.Resolve<IModelAnalytic<ISimpleAssetParameters, RateMetrics>>(_modelIdentifier);
            }
            IZeroRateAssetParameters analyticModelParameters = new ZeroRateAssetParameters
            {
                YearFraction         = YearFraction,
                PeriodAsTimesPerYear =
                    CompoundingHelper.
                    PeriodFractionFromCompoundingFrequency(
                        BaseDate, CompoundingFrequency,
                        DayCountFraction),
                StartDiscountFactor =
                    GetDiscountFactor(interpolatedSpace,
                                      BaseDate, BaseDate)
            };

            //2. get start df = curve.getvalue(this._adjustedStartDate);
            //
            //3. Get the Rate
            //
            if (FixedRate != null)
            {
                analyticModelParameters.Rate = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value;
            }
            CalculationResults = new RateAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            CalculationResults = AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters, new[] { RateMetrics.DiscountFactorAtMaturity });
            return(CalculationResults.DiscountFactorAtMaturity);
        }
Exemple #7
0
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            ISimpleOptionAssetParameters analyticModelParameters = new SimpleRateOptionAssetParameters();

            //{
            //    YearFraction = YearFraction,
            //    TimeToExpiry = TimeToExpiry,
            //    StartDiscountFactor =
            //        GetDiscountFactor(interpolatedSpace,
            //            AdjustedStartDate, BaseDate),
            //    EndDiscountFactor =
            //        GetDiscountFactor(interpolatedSpace,
            //            GetRiskMaturityDate(), BaseDate),
            //    Volatility = Volatility
            //};
            //3. Get the Rate
            //
            //if (Volatility != null)
            //{
            //    analyticModelParameters.Rate = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value;
            //}
            AnalyticResults = new SimpleRateOptionAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            AnalyticResults = AnalyticsModel.Calculate <ISimpleRateOptionAssetResults, SimpleRateOptionAssetResults>(analyticModelParameters, new[] { RateOptionMetrics.ImpliedQuote });
            return(AnalyticResults.ImpliedQuote);
        }
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                AnalyticsModel = new InflationAssetAnalytic();
                // DependencyCreator.Resolve<IModelAnalytic<ISimpleAssetParameters, RateMetrics>>(_modelIdentifier);
            }
            ISimpleDualAssetParameters analyticModelParameters = new DualRateAssetParameters
            {
                YearFraction        = YearFraction,
                StartDiscountFactor =
                    GetDiscountFactor(interpolatedSpace,
                                      AdjustedStartDate, BaseDate),
                EndDiscountFactor =
                    GetDiscountFactor(interpolatedSpace,
                                      GetRiskMaturityDate(), BaseDate)
            };

            //3. Get the Rate
            //
            if (FixedRate != null)
            {
                analyticModelParameters.Rate = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value;
            }
            AnalyticResults = new RateAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            AnalyticResults = AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters, new[] { RateMetrics.ImpliedQuote });
            return(AnalyticResults.ImpliedQuote);
        }
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                AnalyticsModel = new CommoditySpreadAssetAnalytic();
                // DependencyCreator.Resolve<IModelAnalytic<ISimpleAssetParameters, RateMetrics>>(_modelIdentifier);
            }
            //3. Get the Rate
            var endDF = GetIndex(interpolatedSpace, RiskMaturityDate, BaseDate);
            var analyticModelParameters = new CommodityAssetParameters
            {
                CommodityForward =
                    endDF
            };

            Values = new[] { endDF };
            if (Spread != null)
            {
                analyticModelParameters.Spread = MarketQuoteHelper.NormaliseGeneralPriceUnits(SpreadQuotationType, Spread, "MarketQuote").value;
            }
            AnalyticResults = new CommoditySpreadAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            AnalyticResults = AnalyticsModel.Calculate <ICommoditySpreadAssetResults, CommoditySpreadAssetResults>(analyticModelParameters, new[] { CommoditySpreadMetrics.ImpliedQuote });
            return(AnalyticResults.ImpliedQuote);
        }
Exemple #10
0
        /// <summary>
        /// Gets the index.
        /// </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(IInterpolatedSpace commodityCurve, DateTime targetDate,
                                          DateTime valuationDate)
        {
            var 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(IInterpolatedSpace discountFactorCurve, DateTime targetDate,
                                   DateTime valuationDate)
        {
            IPoint point          = new DateTimePoint1D(valuationDate, targetDate);
            var    discountFactor = (decimal)discountFactorCurve.Value(point);

            return(discountFactor);
        }
        /// <summary>
        /// Gets the vols.
        /// </summary>
        /// <param name="volCurve">The vol curve.</param>
        /// <param name="timesToExpiry">The times To Expiry.</param>
        /// <returns></returns>
        public List <double> GetCurveVolatilties(IInterpolatedSpace volCurve, List <double> timesToExpiry)
        {
            var vol = new List <double>();

            foreach (var time in timesToExpiry)
            {
                vol.Add(GetCurveVolatility(volCurve, time));
            }
            return(vol);
        }
Exemple #13
0
        /// <summary>
        /// Gets the discount factor.
        /// </summary>
        /// <param name="discountFactorCurve">The discount factor curve.</param>
        /// <param name="targetDates">The target dates.</param>
        /// <param name="valuationDate">The valuation date.</param>
        /// <returns></returns>
        public decimal[] GetDiscountFactors(IInterpolatedSpace discountFactorCurve, DateTime[] targetDates,
                                            DateTime valuationDate)
        {
            var discountFactors = new List <decimal>();

            foreach (var date in targetDates)
            {
                discountFactors.Add(GetDiscountFactor(discountFactorCurve, date, valuationDate));
            }
            return(discountFactors.ToArray());
        }
Exemple #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RateAssetQuote"/> class.
 /// </summary>
 /// <param name="priceableAsset">The priceable asset.</param>
 /// <param name="baseDate">The base date.</param>
 /// <param name="interpolation">The interpolation.</param>
 /// <param name="extrapolation">if set to <c>true</c> [extrapolation].</param>
 /// <param name="dfs">The discount factors.</param>
 /// <param name="baseCurve">The base curve i.e. the OIS discount curve.</param>
 /// <param name="tolerance">The tolerance.</param>
 public ClearedRateAssetQuote(IPriceableClearedRateAssetController priceableAsset, DateTime baseDate, InterpolationMethod interpolation,
                              bool extrapolation, IDictionary <DateTime, double> dfs, IInterpolatedSpace baseCurve, double tolerance)
 {
     PriceableClearedRateAsset = priceableAsset;
     BaseCurve           = baseCurve;
     BaseDate            = baseDate;
     Dfs                 = dfs;
     InterpolationMethod = interpolation;
     Extrapolation       = extrapolation;
     Tolerance           = tolerance;
     Quote               = MarketQuoteHelper.NormalisePriceUnits(priceableAsset.MarketQuote, "DecimalRate").value;
 }
Exemple #15
0
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <param name="discountedSpace">The OIS Space.</param>
        /// <returns></returns>
        public Decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace, IInterpolatedSpace discountedSpace)
        {
            switch (ModelIdentifier)
            {
            case "SwapAsset":
                AnalyticsModel = new SwapAssetAnalytic();
                break;

            case "DiscountSwapAsset":
                AnalyticsModel = new DiscountSwapAssetAnalytic();
                break;
            }
            //1. Set the basic parameters.
            ISwapAssetParameters analyticModelParameters = new IRSwapAssetParameters
            {
                NotionalAmount = Notional,
                //2. Get the discount factors
                DiscountFactors = GetDiscountFactors(discountedSpace, AdjustedPeriodDates.ToArray(), BaseDate),
                //3. Get the respective year fractions
                YearFractions = YearFractions,
                Rate          = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value
            };

            //2. Get any rates that have reset.
            if (ForwardRates != null)
            {
                analyticModelParameters.FloatingLegForwardRates = ForwardRates;
            }
            //4. Get the Weightings
            analyticModelParameters.Weightings =
                CreateWeightings(CDefaultWeightingValue, analyticModelParameters.DiscountFactors.Length - 1);
            analyticModelParameters.FloatingLegDiscountFactors =
                GetDiscountFactors(discountedSpace, FloatingLegAdjustedPeriodDates.ToArray(), BaseDate);
            //6. Get the respective fixed leg year fractions
            analyticModelParameters.FloatingLegYearFractions = FloatingLegYearFractions;
            //7. Get the Fixed Leg Weightings
            analyticModelParameters.FloatingLegWeightings = FloatingLegWeightings;
            //8. Get the forecast curve discount factors.
            analyticModelParameters.FloatingLegForecastDiscountFactors =
                GetDiscountFactors(interpolatedSpace, FloatingLegAdjustedPeriodDates.ToArray(), BaseDate);
            AnalyticResults = new RateAssetResults();
            //4. Set the analytic input parameters and Calculate the respective metrics
            //
            if (AnalyticsModel != null)
            {
                AnalyticResults = AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters, new[] { RateMetrics.ImpliedQuote });
            }
            return(AnalyticResults.ImpliedQuote);
        }
Exemple #16
0
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                switch (ModelIdentifier)
                {
                case "SwapAsset":
                case "SimpleSwapAsset":
                case "ClearedSwapAsset":
                    AnalyticsModel = new SimpleSwapAssetAnalytic();
                    break;

                case "DiscountSwapAsset":
                case "SimpleDiscountSwapAsset":
                case "DiscountClearedSwapAsset":
                    AnalyticsModel = new SimpleDiscountSwapAssetAnalytic();
                    break;
                }
            }
            ISwapAssetParameters analyticModelParameters = new IRSwapAssetParameters
            {
                NotionalAmount = Notional,
                //2. Get the discount factors
                DiscountFactors =
                    GetDiscountFactors(interpolatedSpace,
                                       AdjustedPeriodDates.ToArray(),
                                       BaseDate),
                //3. Get the respective year fractions
                YearFractions = YearFractions,
                Rate          =
                    MarketQuoteHelper.NormalisePriceUnits(
                        FixedRate, "DecimalRate").value
            };

            //4. Get the Weightings
            analyticModelParameters.Weightings =
                CreateWeightings(CDefaultWeightingValue, analyticModelParameters.DiscountFactors.Length - 1);
            AnalyticResults = new RateAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            if (AnalyticsModel != null)
            {
                AnalyticResults = AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters, new[] { RateMetrics.ImpliedQuote });
            }
            return(AnalyticResults.ImpliedQuote);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="interpolatedSpace"></param>
 /// <returns>The premium</returns>
 public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
 {
     //Check the curves. If they are null use the market quote.
     if (DiscountCurve != null && ForecastCurve != null)
     {
         //1. Copy the vols.
         var volatilities = GetCurveVolatilties(interpolatedSpace, TimesToExpiry);
         //Currently onlt non-discounted caps are avialable.
         var notionals = CreateList(InitialNotional, TimesToExpiry.Count);
         //2.The premium of the flat volatility must be calculated.
         var analyticsModel = new RateOptionAssetAnalytic();
         if (Strike != null)
         {
             var strikes = CreateList((decimal)Strike, TimesToExpiry.Count);
             var analyticModelParameters = new RateOptionAssetParameters
             {
                 PaymentDiscountFactors  = GetDiscountFactors(DiscountCurve, AdjustedPeriodDates.ToArray(), BaseDate),
                 ForecastDiscountFactors = GetDiscountFactors(ForecastCurve, AdjustedPeriodDates.ToArray(), BaseDate),
                 Volatilities            = volatilities,
                 YearFractions           = GetYearFractions(),
                 Strikes       = strikes,
                 TimesToExpiry = TimesToExpiry,
                 IsDiscounted  = false,
                 IsPut         = !IsCap,
                 Notionals     = notionals
             };
             //3. Solve for the forward volatility that has the same premium.
             var metrics         = new[] { RateOptionMetrics.NPV };
             var analyticResults =
                 analyticsModel.Calculate <IRateOptionAssetResults, RateOptionAssetResults>(analyticModelParameters,
                                                                                            metrics);
             decimal calculatedPremium;
             if (IncludeFirstPeriod)
             {
                 calculatedPremium = (decimal)SumDoubleList(analyticResults.NPV, 0);
             }
             else
             {
                 calculatedPremium = (decimal)SumDoubleList(analyticResults.NPV, 1);
             }
             return(calculatedPremium);
         }
     }
     return(0.0m);
 }
Exemple #18
0
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The intepolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateDiscountFactorAtMaturity(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                switch (ModelIdentifier)
                {
                case "SwapAsset":
                case "SimpleSwapAsset":
                case "ClearedSwapAsset":
                    AnalyticsModel = new SimpleSwapAssetAnalytic();
                    break;

                case "DiscountSwapAsset":
                case "SimpleDiscountSwapAsset":
                case "DiscountClearedSwapAsset":
                    AnalyticsModel = new SimpleDiscountSwapAssetAnalytic();
                    break;
                }
            }
            ISwapAssetParameters analyticModelParameters = new IRSwapAssetParameters()
            {
                YearFractions       = YearFractions,
                StartDiscountFactor = GetDiscountFactor(interpolatedSpace, AdjustedStartDate, BaseDate)
            };

            //3. Get the Rate
            //
            if (FixedRate != null)
            {
                analyticModelParameters.Rate = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value;
            }
            AnalyticResults = new RateAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            if (AnalyticsModel == null)
            {
                return(1.0m);
            }
            AnalyticResults = AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters,
                                                                                             new[] { RateMetrics.DiscountFactorAtMaturity });
            return(AnalyticResults.DiscountFactorAtMaturity);
        }
Exemple #19
0
        /// <summary>
        /// Calculates the specified model data.
        /// </summary>
        /// <param name="interpolatedSpace">The interpolatedSpace.</param>
        /// <returns></returns>
        public override decimal CalculateDiscountFactorAtMaturity(IInterpolatedSpace interpolatedSpace)
        {
            AnalyticsModel = new SwapAssetAnalytic();
            //DependencyCreator.Resolve<IModelAnalytic<ISwapAssetParameters, RateMetrics>>("InflationSwapAsset");
            ISwapAssetParameters analyticModelParameters = new IRSwapAssetParameters();

            AnalyticResults = new RateAssetResults();
            //1. instantiate curve
            //var curve = (IRateCurve)modelData.MarketEnvironment.GetPricingStructure(_discountCurveName);
            //2. Set the rate
            analyticModelParameters.Rate = MarketQuoteHelper.NormalisePriceUnits(FixedRate, "DecimalRate").value;
            //3. Set the start diccount factor
            analyticModelParameters.StartDiscountFactor =
                GetDiscountFactor(interpolatedSpace, AdjustedStartDate, BaseDate);
            //4. Get the respective year fractions
            analyticModelParameters.YearFractions = GetYearFractions();
            //5. Set the anaytic input parameters and Calculate the respective metrics
            AnalyticResults =
                AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters,
                                                                               new[] { RateMetrics.DiscountFactorAtMaturity });
            return(AnalyticResults.DiscountFactorAtMaturity);
        }
        /// <summary>
        /// Calculates the specified metric for the fast bootstrapper.
        /// </summary>
        /// <param name="interpolatedSpace">The interpolated Space.</param>
        /// <returns></returns>
        public override decimal CalculateDiscountFactorAtMaturity(IInterpolatedSpace interpolatedSpace)
        {
            if (AnalyticsModel == null)
            {
                switch (ModelIdentifier)
                {
                case "SwapAsset":
                case "ClearedSwapAsset":
                    AnalyticsModel = new SimpleSwapAssetAnalytic();    //
                    break;
                }
            }
            ISwapAssetParameters analyticModelParameters = new IRSwapAssetParameters
            {
                YearFractions       = YearFractions,
                StartDiscountFactor =
                    GetDiscountFactor(interpolatedSpace,
                                      AdjustedStartDate, BaseDate),
                Rate =
                    CalculateImpliedQuote(interpolatedSpace) +
                    MarketQuoteHelper
                    .NormaliseGeneralPriceUnits(QuotationType, Spread,
                                                "DecimalRate").value
            };

            //3. Set the implied Rate with a spread
            //
            AnalyticResults = new RateAssetResults();
            //4. Set the anaytic input parameters and Calculate the respective metrics
            //
            if (AnalyticsModel != null)
            {
                AnalyticResults = AnalyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters, new[] { RateMetrics.DiscountFactorAtMaturity });
            }
            return(AnalyticResults.DiscountFactorAtMaturity);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="interpolatedSpace"></param>
 /// <returns></returns>
 public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
 {
     return(Quote.value);
 }
 ///<summary>
 ///</summary>
 ///<param name="interpolatedSpace"></param>
 ///<returns>The spread calculated from the curve provided and the marketquote of the asset.</returns>
 public override decimal CalculateSpreadQuote(IInterpolatedSpace interpolatedSpace)
 {
     return(Spread.value);
 }
 ///<summary>
 ///</summary>
 ///<param name="interpolatedSpace"></param>
 ///<returns>The spread calculated from the curve provided and the market quote of the asset.</returns>
 public abstract decimal CalculateSpreadQuote(IInterpolatedSpace interpolatedSpace);
 /// <summary>
 /// Calculates the specified metric for the fast bootstrapper.
 /// </summary>
 /// <param name="interpolatedSpace">The interpolated Space.</param>
 /// <returns></returns>
 public abstract decimal CalculateImpliedQuoteWithSpread(IInterpolatedSpace interpolatedSpace);
 ///<summary>
 ///</summary>
 ///<param name="interpolatedSpace"></param>
 ///<returns></returns>
 public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
 {
     throw new NotImplementedException();
 }
Exemple #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="interpolatedSpace"></param>
 /// <returns></returns>
 public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
 {
     return(Quote.value);//TODO This will only work for ytm quotes.
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="interpolatedSpace"></param>
 /// <returns></returns>
 public override decimal CalculateImpliedQuote(IInterpolatedSpace interpolatedSpace)
 {
     return(IndexAtMaturity);
 }
Exemple #28
0
 /// <summary>
 /// Gets the discount factor.
 /// </summary>
 /// <param name="discountFactorCurve">The discount factor curve.</param>
 /// <param name="targetDates">The target dates.</param>
 /// <param name="valuationDate">The valuation date.</param>
 /// <returns></returns>
 public decimal[] GetDiscountFactors(IInterpolatedSpace discountFactorCurve, DateTime[] targetDates,
                                     DateTime valuationDate)
 {
     return(targetDates.Select(date => GetDiscountFactor(discountFactorCurve, date, valuationDate)).ToArray());
 }
Exemple #29
0
 ///<summary>
 ///</summary>
 ///<param name="interpolatedSpace"></param>
 ///<returns></returns>
 public abstract decimal CalculateDiscountFactorAtMaturity(IInterpolatedSpace interpolatedSpace);
 ///<summary>
 ///</summary>
 ///<param name="interpolatedSpace"></param>
 ///<returns>The spread calculated from the curve provided and the marketquote of the asset.</returns>
 public override decimal CalculateSpreadQuote(IInterpolatedSpace interpolatedSpace)
 {
     return(MarketQuote.value - CalculateImpliedQuote(interpolatedSpace));
 }