Пример #1
0
        //-------------------------------------------------------------------------
        public virtual void test_pvsensi_settle_before_val()
        {
            PointSensitivities pvsensiComputed = PRICER_TRADE.presentValueSensitivity(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER);
            PointSensitivities pvsensiExpected = PRICER_PRODUCT.presentValueSensitivity(BILL_PRODUCT.resolve(REF_DATA), PROVIDER).multipliedBy(QUANTITY);

            assertTrue(pvsensiComputed.equalWithTolerance(pvsensiExpected, TOLERANCE_PVSENSI));
            CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(pvsensiComputed);
            CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity(PROVIDER, p => PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_BEFORE_VAL, p));

            assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT * QUANTITY));
        }
Пример #2
0
        //-------------------------------------------------------------------------
        public virtual void presentValueSensitivity()
        {
            PointSensitivities sensiComputed = PRICER.presentValueSensitivity(BILL, PROVIDER);
            PointSensitivities sensiExpected = IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER).zeroRatePointSensitivity(MATURITY_DATE).multipliedBy(NOTIONAL.Amount).build();

            assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PV));
            CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(sensiComputed);
            CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity(PROVIDER, p => PRICER.presentValue(BILL, p));

            assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT));
        }
Пример #3
0
        /// <summary>
        /// Calculates the present value sensitivity of a bill trade.
        /// <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>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="provider">  the discounting provider </param>
        /// <returns> the present value sensitivity </returns>
        public virtual PointSensitivities presentValueSensitivity(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider)
        {
            if (provider.ValuationDate.isAfter(trade.Product.Notional.Date))
            {
                return(PointSensitivities.empty());
            }
            PointSensitivities sensiProduct = productPricer.presentValueSensitivity(trade.Product, provider).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));
        }