/// <summary> /// /// </summary> /// <returns>The swap par rate</returns> public decimal CalculateImpliedParRate(DateTime baseDate) { //Check the curves. If they are null use the market quote. if (ForecastCurve == null) { return(0.0m); } var analyticsModel = new SimpleSwapAssetAnalytic(); var analyticModelParameters = new IRSwapAssetParameters { NotionalAmount = InitialNotional, DiscountFactors = GetDiscountFactors(ForecastCurve, AdjustedPeriodDates, baseDate), YearFractions = Convert(GetYearFractions()), Weightings = CreateList(AdjustedPeriodDates.Count - 1, 1.0m) }; //2. Get the discount factors //3. Get the respective year fractions //4. Get the Weightings //3. Solve for the forward volatility that has the same premium. var metrics = new[] { RateMetrics.ImpliedQuote }; var analyticResults = analyticsModel.Calculate <IRateAssetResults, RateAssetResults>(analyticModelParameters, metrics); return(analyticResults.ImpliedQuote); }
/// <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); }