public virtual void test_presentValueSensitivity_ended()
        {
            ResolvedFxSingle   fwd      = ResolvedFxSingle.of(CurrencyAmount.of(USD, NOMINAL_USD), FxRate.of(USD, KRW, FX_RATE), PAYMENT_DATE_PAST);
            PointSensitivities computed = PRICER.presentValueSensitivity(fwd, PROVIDER);

            assertEquals(computed, PointSensitivities.empty());
        }
        public virtual void test_presentValueSensitivity_ended()
        {
            ResolvedFxSwap     product  = ResolvedFxSwap.ofForwardPoints(CurrencyAmount.of(USD, NOMINAL_USD), KRW, FX_RATE, FX_FWD_POINTS, PAYMENT_DATE_LONG_PAST, PAYMENT_DATE_PAST);
            PointSensitivities computed = PRICER.presentValueSensitivity(product, PROVIDER);

            assertEquals(computed, PointSensitivities.empty());
        }
        public virtual void test_presentValueSensitivity_ended()
        {
            ResolvedFxNdf      ndf      = ResolvedFxNdf.builder().settlementCurrencyNotional(CURRENCY_NOTIONAL).agreedFxRate(FxRate.of(USD, KRW, FX_RATE)).observation(FxIndexObservation.of(INDEX, FIXING_DATE_PAST, REF_DATA)).paymentDate(PAYMENT_DATE_PAST).build();
            PointSensitivities computed = PRICER.presentValueSensitivity(ndf, PROVIDER);

            assertEquals(computed, PointSensitivities.empty());
        }
Beispiel #4
0
        public virtual void test_presentValueSensitivity_inPast()
        {
            SimpleRatesProvider prov = createProvider(VAL_DATE);

            PointSensitivities computed = PRICER.presentValueSensitivity(PERIOD_PAST, prov).build();

            assertEquals(computed, PointSensitivities.empty());
        }
Beispiel #5
0
        /// <summary>
        /// Calculates the present value curve sensitivity of the FX product.
        /// <para>
        /// The present value sensitivity of the product is the sensitivity of the present value to
        /// the underlying curves.
        ///
        /// </para>
        /// </summary>
        /// <param name="fx">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the point sensitivity of the present value </returns>
        public virtual PointSensitivities presentValueSensitivity(ResolvedFxSingle fx, RatesProvider provider)
        {
            if (provider.ValuationDate.isAfter(fx.PaymentDate))
            {
                return(PointSensitivities.empty());
            }
            PointSensitivityBuilder pvcs1 = paymentPricer.presentValueSensitivity(fx.BaseCurrencyPayment, provider);
            PointSensitivityBuilder pvcs2 = paymentPricer.presentValueSensitivity(fx.CounterCurrencyPayment, provider);

            return(pvcs1.combinedWith(pvcs2).build());
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity of the bill product.
        /// <para>
        /// The present value sensitivity of the product is the sensitivity of the present value to
        /// the underlying curves.
        ///
        /// </para>
        /// </summary>
        /// <param name="bill">  the product </param>
        /// <param name="provider">  the discounting provider </param>
        /// <returns> the present value curve sensitivity of the product </returns>
        public virtual PointSensitivities presentValueSensitivity(ResolvedBill bill, LegalEntityDiscountingProvider provider)
        {
            if (provider.ValuationDate.isAfter(bill.Notional.Date))
            {
                return(PointSensitivities.empty());
            }
            IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bill, provider);
            double dfEndBar = bill.Notional.Amount;
            PointSensitivityBuilder sensMaturity = issuerDf.zeroRatePointSensitivity(bill.Notional.Date).multipliedBy(dfEndBar);

            return(sensMaturity.build());
        }
        /// <summary>
        /// Calculates the present value sensitivity of the bill product with z-spread.
        /// <para>
        /// The present value sensitivity of the product is the sensitivity of the present value to
        /// the underlying curves.
        /// </para>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or
        /// periodic compounded rates of the issuer discounting curve.
        ///
        /// </para>
        /// </summary>
        /// <param name="bill">  the product </param>
        /// <param name="provider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the present value curve sensitivity of the product </returns>
        public virtual PointSensitivities presentValueSensitivityWithZSpread(ResolvedBill bill, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            if (provider.ValuationDate.isAfter(bill.Notional.Date))
            {
                return(PointSensitivities.empty());
            }
            IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bill, provider);
            double dfEndBar = bill.Notional.Amount;
            ZeroRateSensitivity            zeroSensMaturity = issuerDf.DiscountFactors.zeroRatePointSensitivityWithSpread(bill.Notional.Date, zSpread, compoundedRateType, periodsPerYear);
            IssuerCurveZeroRateSensitivity dscSensMaturity  = IssuerCurveZeroRateSensitivity.of(zeroSensMaturity, issuerDf.LegalEntityGroup).multipliedBy(dfEndBar);

            return(dscSensMaturity.build());
        }
Beispiel #8
0
        /// <summary>
        /// Calculates the present value sensitivity of a bill trade with z-spread.
        /// <para>
        /// If the settlement details are provided, the sensitivity is the sum of the underlying product's sensitivity
        /// multiplied by the quantity and the sensitivity of the settlement payment if still due at the valuation date.
        /// If not it is the underlying product's sensitivity multiplied by the quantity.
        /// </para>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates of
        /// the issuer discounting curve. The z-spread is applied only on the legal entity curve, not on the repo curve used
        /// for the settlement amount.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="provider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the present value sensitivity </returns>
        public virtual PointSensitivities presentValueSensitivityWithZSpread(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            if (provider.ValuationDate.isAfter(trade.Product.Notional.Date))
            {
                return(PointSensitivities.empty());
            }
            PointSensitivities sensiProduct = productPricer.presentValueSensitivityWithZSpread(trade.Product, provider, zSpread, compoundedRateType, periodsPerYear).multipliedBy(trade.Quantity);

            if (!trade.Settlement.Present)
            {
                return(sensiProduct);
            }
            Payment settlement = trade.Settlement.get();
            RepoCurveDiscountFactors repoDf      = DiscountingBillProductPricer.repoCurveDf(trade.Product, provider);
            PointSensitivities       sensiSettle = presentValueSensitivitySettlement(settlement, repoDf);

            return(sensiProduct.combinedWith(sensiSettle));
        }
        /// <summary>
        /// Calculates the present value curve sensitivity of the NDF product.
        /// <para>
        /// The present value sensitivity of the product is the sensitivity of the present value to
        /// the underlying curves.
        ///
        /// </para>
        /// </summary>
        /// <param name="ndf">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the point sensitivity of the present value </returns>
        public virtual PointSensitivities presentValueSensitivity(ResolvedFxNdf ndf, RatesProvider provider)
        {
            if (provider.ValuationDate.isAfter(ndf.PaymentDate))
            {
                return(PointSensitivities.empty());
            }
            Currency ccySettle               = ndf.SettlementCurrency;
            Currency ccyOther                = ndf.NonDeliverableCurrency;
            double   notionalSettle          = ndf.SettlementNotional;
            double   agreedRate              = ndf.AgreedFxRate.fxRate(ccySettle, ccyOther);
            double   forwardRate             = provider.fxIndexRates(ndf.Index).rate(ndf.Observation, ccySettle);
            double   dfSettle                = provider.discountFactor(ccySettle, ndf.PaymentDate);
            double   ratio                   = agreedRate / forwardRate;
            double   dscBar                  = (1d - ratio) * notionalSettle;
            PointSensitivityBuilder sensiDsc = provider.discountFactors(ccySettle).zeroRatePointSensitivity(ndf.PaymentDate).multipliedBy(dscBar);
            double forwardRateBar            = dfSettle * notionalSettle * ratio / forwardRate;
            PointSensitivityBuilder sensiFx  = provider.fxIndexRates(ndf.Index).ratePointSensitivity(ndf.Observation, ccySettle).withCurrency(ccySettle).multipliedBy(forwardRateBar);

            return(sensiDsc.combinedWith(sensiFx).build());
        }
        public virtual void test_presentValueSensitivity_afterExpiry()
        {
            PointSensitivities point = PRICER.presentValueSensitivityRatesStickyStrike(CALL_ITM, RATES_PROVIDER_AFTER, VOLS_AFTER);

            assertEquals(point, PointSensitivities.empty());
        }
Beispiel #11
0
        public virtual void test_presentValueSensitivity_provider_ended()
        {
            PointSensitivities computed = PRICER.presentValueSensitivity(TRADE_PAST, PROVIDER);

            assertEquals(computed, PointSensitivities.empty());
        }