Пример #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Explains the present value of the CMS product.
        /// <para>
        /// This returns explanatory information about the calculation.
        ///
        /// </para>
        /// </summary>
        /// <param name="cms">  the CMS product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the swaption volatilities </param>
        /// <returns> the explain PV map </returns>
        public virtual ExplainMap explainPresentValue(ResolvedCms cms, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            ExplainMapBuilder builder = ExplainMap.builder();

            builder.put(ExplainKey.ENTRY_TYPE, "CmsSwap");
            IList <ExplainMap> legsExplain = new List <ExplainMap>();

            legsExplain.Add(cmsLegPricer.explainPresentValue(cms.CmsLeg, ratesProvider, swaptionVolatilities));
            if (cms.PayLeg.Present)
            {
                legsExplain.Add(payLegPricer.explainPresentValue(cms.PayLeg.get(), ratesProvider));
            }
            builder.put(ExplainKey.LEGS, legsExplain);
            return(builder.build());
        }
        public virtual double explainRate(OvernightAveragedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder)
        {
            double rate = this.rate(computation, startDate, endDate, provider);

            builder.put(ExplainKey.COMBINED_RATE, rate);
            return(rate);
        }
Пример #3
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Explain present value builder used to build large explain map from the individual legs.
 /// </summary>
 /// <param name="leg">  the swap log </param>
 /// <param name="provider">  the rates provider </param>
 /// <param name="builder">  the explain map builder which will be populated but the leg  </param>
 internal virtual void explainPresentValueInternal(ResolvedSwapLeg leg, RatesProvider provider, ExplainMapBuilder builder)
 {
     builder.put(ExplainKey.ENTRY_TYPE, "Leg");
     builder.put(ExplainKey.PAY_RECEIVE, leg.PayReceive);
     builder.put(ExplainKey.LEG_TYPE, leg.Type.ToString());
     foreach (SwapPaymentPeriod period in leg.PaymentPeriods)
     {
         builder.addListEntry(ExplainKey.PAYMENT_PERIODS, child => paymentPeriodPricer.explainPresentValue(period, provider, child));
     }
     foreach (SwapPaymentEvent @event in leg.PaymentEvents)
     {
         builder.addListEntry(ExplainKey.PAYMENT_EVENTS, child => paymentEventPricer.explainPresentValue(@event, provider, child));
     }
     builder.put(ExplainKey.FORECAST_VALUE, forecastValue(leg, provider));
     builder.put(ExplainKey.PRESENT_VALUE, presentValue(leg, provider));
 }
Пример #4
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Explains the present value of the swap product.
        /// <para>
        /// This returns explanatory information about the calculation.
        ///
        /// </para>
        /// </summary>
        /// <param name="swap">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the explanatory information </returns>
        public virtual ExplainMap explainPresentValue(ResolvedSwap swap, RatesProvider provider)
        {
            ExplainMapBuilder builder = ExplainMap.builder();

            builder.put(ExplainKey.ENTRY_TYPE, "Swap");
            foreach (ResolvedSwapLeg leg in swap.Legs)
            {
                builder.addListEntryWithIndex(ExplainKey.LEGS, child => legPricer.explainPresentValueInternal(leg, provider, child));
            }
            return(builder.build());
        }
Пример #5
0
        /// <summary>
        /// Explains the present value of the CMS period.
        /// <para>
        /// This returns explanatory information about the calculation.
        ///
        /// </para>
        /// </summary>
        /// <param name="period">  the product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the volatilities </param>
        /// <param name="builder">  the builder to populate </param>
        public void explainPresentValue(CmsPeriod period, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities, ExplainMapBuilder builder)
        {
            string    type        = period.CmsPeriodType.ToString();
            Currency  ccy         = period.Currency;
            LocalDate paymentDate = period.PaymentDate;

            builder.put(ExplainKey.ENTRY_TYPE, "Cms" + type + "Period");
            builder.put(ExplainKey.STRIKE_VALUE, period.Strike);
            builder.put(ExplainKey.NOTIONAL, CurrencyAmount.of(ccy, period.Notional));
            builder.put(ExplainKey.PAYMENT_DATE, period.PaymentDate);
            builder.put(ExplainKey.DISCOUNT_FACTOR, ratesProvider.discountFactor(ccy, paymentDate));
            builder.put(ExplainKey.START_DATE, period.StartDate);
            builder.put(ExplainKey.END_DATE, period.EndDate);
            builder.put(ExplainKey.FIXING_DATE, period.FixingDate);
            builder.put(ExplainKey.ACCRUAL_YEAR_FRACTION, period.YearFraction);
            builder.put(ExplainKey.PRESENT_VALUE, presentValue(period, ratesProvider, swaptionVolatilities));
            builder.put(ExplainKey.FORWARD_RATE, swapPricer.parRate(period.UnderlyingSwap, ratesProvider));
            builder.put(ExplainKey.CONVEXITY_ADJUSTED_RATE, adjustedForwardRate(period, ratesProvider, swaptionVolatilities));
        }