// Checks that the NDF present value is coherent with the standard FX forward present value.
        public virtual void test_presentValueVsForex()
        {
            CurrencyAmount      pvNDF = PRICER.presentValue(NDF, PROVIDER);
            MultiCurrencyAmount pvFX  = PRICER_FX.presentValue(FOREX, PROVIDER);

            assertEquals(pvNDF.Amount, pvFX.getAmount(USD).Amount + pvFX.getAmount(KRW).Amount *FX_MATRIX.fxRate(KRW, USD), NOMINAL_USD * TOL);
        }
        // Checks that the NDF currency exposure is coherent with the standard FX forward present value.
        public virtual void test_currencyExposureVsForex()
        {
            MultiCurrencyAmount pvNDF = PRICER.currencyExposure(NDF, PROVIDER);
            MultiCurrencyAmount pvFX  = PRICER_FX.currencyExposure(FOREX, PROVIDER);

            assertEquals(pvNDF.getAmount(USD).Amount, pvFX.getAmount(USD).Amount, NOMINAL_USD * TOL);
            assertEquals(pvNDF.getAmount(KRW).Amount, pvFX.getAmount(KRW).Amount, NOMINAL_USD * TOL * FX_MATRIX.fxRate(USD, KRW));
        }
Esempio n. 3
0
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(OPTION_TRADE, RATES_PROVIDER, VOLS);
            MultiCurrencyAmount ceExpected = PRICER_PRODUCT.currencyExposure(OPTION_PRODUCT, RATES_PROVIDER, VOLS).plus(PRICER_PAYMENT.presentValue(PREMIUM, RATES_PROVIDER));

            assertEquals(ceComputed.size(), 2);
            assertEquals(ceComputed.getAmount(EUR).Amount, ceExpected.getAmount(EUR).Amount, TOL * NOTIONAL);
            assertEquals(ceComputed.getAmount(USD).Amount, ceExpected.getAmount(USD).Amount, TOL * NOTIONAL);
        }
        public virtual void test_presentValue()
        {
            MultiCurrencyAmount computed = PRICER.presentValue(FWD, PROVIDER);
            double expected1             = NOMINAL_USD * PROVIDER.discountFactor(USD, PAYMENT_DATE);
            double expected2             = -NOMINAL_USD *FX_RATE *PROVIDER.discountFactor(KRW, PAYMENT_DATE);

            assertEquals(computed.getAmount(USD).Amount, expected1, NOMINAL_USD * TOL);
            assertEquals(computed.getAmount(KRW).Amount, expected2, NOMINAL_USD * TOL);
        }
        //-------------------------------------------------------------------------
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount computedPricer = PRICER.currencyExposure(CALL_OTM, RATES_PROVIDER, VOLS);
            CurrencyAmount      pv             = PRICER.presentValue(CALL_OTM, RATES_PROVIDER, VOLS);
            PointSensitivities  point          = PRICER.presentValueSensitivityRatesStickyStrike(CALL_OTM, RATES_PROVIDER, VOLS);
            MultiCurrencyAmount computedPoint  = RATES_PROVIDER.currencyExposure(point).plus(pv);

            assertEquals(computedPricer.getAmount(EUR).Amount, computedPoint.getAmount(EUR).Amount, NOTIONAL * TOL);
            assertEquals(computedPricer.getAmount(USD).Amount, computedPoint.getAmount(USD).Amount, NOTIONAL * TOL);
        }
        public virtual void test_currencyExposure_from_pt_sensitivity_inverse()
        {
            MultiCurrencyAmount ceDirect   = PRICER.currencyExposure(NDF_INVERSE, PROVIDER);
            PointSensitivities  pts        = PRICER.presentValueSensitivity(NDF_INVERSE, PROVIDER);
            MultiCurrencyAmount cePts      = PROVIDER.currencyExposure(pts);
            CurrencyAmount      cePv       = PRICER.presentValue(NDF_INVERSE, PROVIDER);
            MultiCurrencyAmount ceExpected = cePts.plus(cePv);

            assertEquals(ceDirect.getAmount(USD).Amount, ceExpected.getAmount(USD).Amount, NOMINAL_USD * TOL);
            assertEquals(ceDirect.getAmount(KRW).Amount, ceExpected.getAmount(KRW).Amount, NOMINAL_USD * TOL * FX_MATRIX.fxRate(USD, KRW));
        }
Esempio n. 7
0
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(OPTION_TRADE, RATES_PROVIDER, VOLS);
            PointSensitivities  point      = PRICER_TRADE.presentValueSensitivityRatesStickyStrike(OPTION_TRADE, RATES_PROVIDER, VOLS);
            MultiCurrencyAmount pv         = PRICER_TRADE.presentValue(OPTION_TRADE, RATES_PROVIDER, VOLS);
            MultiCurrencyAmount ceExpected = RATES_PROVIDER.currencyExposure(point).plus(pv);

            assertEquals(ceComputed.size(), 2);
            assertEquals(ceComputed.getAmount(EUR).Amount, ceExpected.getAmount(EUR).Amount, TOL * NOTIONAL);
            assertEquals(ceComputed.getAmount(USD).Amount, ceExpected.getAmount(USD).Amount, TOL * NOTIONAL);
        }
        //-------------------------------------------------------------------------
        public virtual void test_presentValue_beforeStart()
        {
            MultiCurrencyAmount computed = PRICER.presentValue(SWAP_PRODUCT, PROVIDER);
            double expected_usd          = NOMINAL_USD * (PROVIDER.discountFactor(USD, PAYMENT_DATE_NEAR) - PROVIDER.discountFactor(USD, PAYMENT_DATE_FAR));
            double expected_krw          = NOMINAL_USD * (-FX_RATE * PROVIDER.discountFactor(KRW, PAYMENT_DATE_NEAR) + (FX_RATE + FX_FWD_POINTS) * PROVIDER.discountFactor(KRW, PAYMENT_DATE_FAR));

            assertEquals(computed.getAmount(USD).Amount, expected_usd, NOMINAL_USD * TOL);
            assertEquals(computed.getAmount(KRW).Amount, expected_krw, NOMINAL_USD * FX_RATE * TOL);

            // currency exposure
            MultiCurrencyAmount exposure = PRICER.currencyExposure(SWAP_PRODUCT, PROVIDER);

            assertEquals(exposure, computed);
        }
        public virtual void test_presentValue_started()
        {
            ResolvedFxSwap      product  = ResolvedFxSwap.ofForwardPoints(CurrencyAmount.of(USD, NOMINAL_USD), KRW, FX_RATE, FX_FWD_POINTS, PAYMENT_DATE_PAST, PAYMENT_DATE_NEAR);
            MultiCurrencyAmount computed = PRICER.presentValue(product, PROVIDER);
            double expected_usd          = -NOMINAL_USD *PROVIDER.discountFactor(USD, PAYMENT_DATE_NEAR);

            double expected_krw = NOMINAL_USD * (FX_RATE + FX_FWD_POINTS) * PROVIDER.discountFactor(KRW, PAYMENT_DATE_NEAR);

            assertEquals(computed.getAmount(USD).Amount, expected_usd, NOMINAL_USD * TOL);
            assertEquals(computed.getAmount(KRW).Amount, expected_krw, NOMINAL_USD * FX_RATE * TOL);

            // currency exposure
            MultiCurrencyAmount exposure = PRICER.currencyExposure(product, PROVIDER);

            assertEquals(exposure, computed);
        }
Esempio n. 10
0
        //-------------------------------------------------------------------------
        public virtual void currency_exposure_premium_forward()
        {
            CurrencyAmount      pv = PRICER_TRADE.presentValue(SWAPTION_PREFWD_LONG_REC, MULTI_USD, NORMAL_VOLS_USD);
            MultiCurrencyAmount ce = PRICER_TRADE.currencyExposure(SWAPTION_PREFWD_LONG_REC, MULTI_USD, NORMAL_VOLS_USD);

            assertEquals(pv.Amount, ce.getAmount(USD).Amount, TOLERANCE_PV);
        }
Esempio n. 11
0
        //-------------------------------------------------------------------------
        public virtual void currency_exposure_premium_forward()
        {
            CurrencyAmount      pv = PRICER_TRADE.presentValue(SWAPTION_PREFWD_LONG_REC, RATE_PROVIDER, VOLS);
            MultiCurrencyAmount ce = PRICER_TRADE.currencyExposure(SWAPTION_PREFWD_LONG_REC, RATE_PROVIDER, VOLS);

            assertEquals(pv.Amount, ce.getAmount(USD).Amount, NOTIONAL * TOL);
        }
Esempio n. 12
0
 //-------------------------------------------------------------------------
 public virtual void test_currencyExposure()
 {
     for (int i = 0; i < NB_STRIKES; ++i)
     {
         CurrencyAmount          pvCall       = PRICER.presentValue(CALLS[i], RATES_PROVIDER, VOLS);
         PointSensitivityBuilder pvSensiCall  = PRICER.presentValueSensitivityRatesStickyStrike(CALLS[i], RATES_PROVIDER, VOLS);
         MultiCurrencyAmount     computedCall = PRICER.currencyExposure(CALLS[i], RATES_PROVIDER, VOLS);
         MultiCurrencyAmount     expectedCall = RATES_PROVIDER.currencyExposure(pvSensiCall.build()).plus(pvCall);
         assertEquals(computedCall.getAmount(EUR).Amount, expectedCall.getAmount(EUR).Amount, NOTIONAL * TOL);
         assertEquals(computedCall.getAmount(USD).Amount, expectedCall.getAmount(USD).Amount, NOTIONAL * TOL);
         CurrencyAmount          pvPut       = PRICER.presentValue(PUTS[i], RATES_PROVIDER, VOLS);
         PointSensitivityBuilder pvSensiPut  = PRICER.presentValueSensitivityRatesStickyStrike(PUTS[i], RATES_PROVIDER, VOLS);
         MultiCurrencyAmount     computedPut = PRICER.currencyExposure(PUTS[i], RATES_PROVIDER, VOLS);
         MultiCurrencyAmount     expectedPut = RATES_PROVIDER.currencyExposure(pvSensiPut.build()).plus(pvPut);
         assertEquals(computedPut.getAmount(EUR).Amount, expectedPut.getAmount(EUR).Amount, NOTIONAL * TOL);
         assertEquals(computedPut.getAmount(USD).Amount, expectedPut.getAmount(USD).Amount, NOTIONAL * TOL);
     }
 }
Esempio n. 13
0
        //-------------------------------------------------------------------------
        public virtual void test_currencyExposureFromCleanPrice()
        {
            MultiCurrencyAmount computed = PRICER.currencyExposureFromCleanPrice(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE);
            PointSensitivities  point    = PRICER.presentValueSensitivityFromCleanPrice(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE);
            MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point).plus(PRICER.presentValueFromCleanPrice(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE));

            assertEquals(computed.Amounts.size(), 1);
            assertEquals(computed.getAmount(USD).Amount, expected.getAmount(USD).Amount, NOTIONAL * QUANTITY * TOL);
        }
Esempio n. 14
0
        public virtual void test_currencyExposureWithZSpread()
        {
            MultiCurrencyAmount computed = PRICER.currencyExposureWithZSpread(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
            PointSensitivities  point    = PRICER.presentValueSensitivityWithZSpread(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
            MultiCurrencyAmount expected = RATES_PROVIDER.currencyExposure(point).plus(PRICER.presentValueWithZSpread(TRADE_STANDARD, RATES_PROVIDER, ISSUER_RATES_PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR));

            assertEquals(computed.Amounts.size(), 1);
            assertEquals(computed.getAmount(USD).Amount, expected.getAmount(USD).Amount, NOTIONAL * QUANTITY * TOL);
        }
Esempio n. 15
0
        public virtual void test_currencyExposure()
        {
            PointSensitivities  point    = PRICER.presentValueSensitivityRates(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER);
            MultiCurrencyAmount expected = RATE_PROVIDER.currencyExposure(point).plus(PRICER.presentValue(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER, LAST_PRICE));
            MultiCurrencyAmount computed = PRICER.currencyExposure(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER, LAST_PRICE);

            assertEquals(computed.size(), 1);
            assertEquals(computed.getAmount(EUR).Amount, expected.getAmount(EUR).Amount, NOTIONAL * QUANTITY * TOL);
        }
        public virtual void test_cashFlowEquivalent_pv()
        {
            ResolvedSwap                 swap       = ResolvedSwap.of(IBOR_LEG, FIXED_LEG);
            ResolvedSwapLeg              cfe        = CashFlowEquivalentCalculator.cashFlowEquivalentSwap(swap, PROVIDER);
            DiscountingSwapLegPricer     pricerLeg  = DiscountingSwapLegPricer.DEFAULT;
            DiscountingSwapProductPricer pricerSwap = DiscountingSwapProductPricer.DEFAULT;
            CurrencyAmount               pvCfe      = pricerLeg.presentValue(cfe, PROVIDER);
            MultiCurrencyAmount          pvSwap     = pricerSwap.presentValue(swap, PROVIDER);

            assertEquals(pvCfe.Amount, pvSwap.getAmount(GBP).Amount, TOLERANCE_PV);
        }
Esempio n. 17
0
        public virtual void test_presentValueZSpread_settle_after_val()
        {
            CurrencyAmount pvComputed = PRICER_TRADE.presentValueWithZSpread(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);
            CurrencyAmount pvExpected = PRICER_PRODUCT.presentValueWithZSpread(BILL_PRODUCT.resolve(REF_DATA), PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0).multipliedBy(QUANTITY).plus(PRICER_PAYMENT.presentValue(BILL_TRADE_SETTLE_AFTER_VAL.Settlement.get(), PROVIDER.repoCurveDiscountFactors(BILL_PRODUCT.SecurityId, BILL_PRODUCT.LegalEntityId, BILL_PRODUCT.Currency).DiscountFactors));

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected.Amount, TOLERANCE_PV);
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposureWithZSpread(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);

            assertEquals(ceComputed.Currencies.size(), 1);
            assertTrue(ceComputed.contains(EUR));
            assertEquals(ceComputed.getAmount(EUR).Amount, pvExpected.Amount, TOLERANCE_PV);
        }
Esempio n. 18
0
        public virtual void test_presentValueZSpread_settle_on_val()
        {
            CurrencyAmount pvComputed = PRICER_TRADE.presentValueWithZSpread(BILL_TRADE_SETTLE_ON_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);
            CurrencyAmount pvExpected = PRICER_PRODUCT.presentValueWithZSpread(BILL_PRODUCT.resolve(REF_DATA), PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0).plus(-PRICE * NOTIONAL_AMOUNT).multipliedBy(QUANTITY);

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected.Amount, TOLERANCE_PV);
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposureWithZSpread(BILL_TRADE_SETTLE_ON_VAL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0);

            assertEquals(ceComputed.Currencies.size(), 1);
            assertTrue(ceComputed.contains(EUR));
            assertEquals(ceComputed.getAmount(EUR).Amount, pvExpected.Amount, TOLERANCE_PV);
        }
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount     computed1 = PRODUCT_PRICER.currencyExposure(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     computed2 = PRODUCT_PRICER.currencyExposure(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     pv1       = PRODUCT_PRICER.presentValue(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder pt1       = PRODUCT_PRICER.presentValueSensitivityRates(CMS_ONE_LEG, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     expected1 = RATES_PROVIDER.currencyExposure(pt1.build()).plus(pv1);
            MultiCurrencyAmount     pv2       = PRODUCT_PRICER.presentValue(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            PointSensitivityBuilder pt2       = PRODUCT_PRICER.presentValueSensitivityRates(CMS_TWO_LEGS, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount     expected2 = RATES_PROVIDER.currencyExposure(pt2.build()).plus(pv2);

            assertEquals(computed1.getAmount(EUR).Amount, expected1.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
            assertEquals(computed2.getAmount(EUR).Amount, expected2.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
        }
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount computed1 = TRADE_PRICER.currencyExposure(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount computed2 = TRADE_PRICER.currencyExposure(CMS_TRADE, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount pv1       = TRADE_PRICER.presentValue(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES);
            PointSensitivities  pt1       = TRADE_PRICER.presentValueSensitivityRates(CMS_TRADE_PREMIUM, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount expected1 = RATES_PROVIDER.currencyExposure(pt1).plus(pv1);
            MultiCurrencyAmount pv2       = TRADE_PRICER.presentValue(CMS_TRADE, RATES_PROVIDER, VOLATILITIES);
            PointSensitivities  pt2       = TRADE_PRICER.presentValueSensitivityRates(CMS_TRADE, RATES_PROVIDER, VOLATILITIES);
            MultiCurrencyAmount expected2 = RATES_PROVIDER.currencyExposure(pt2).plus(pv2);

            assertEquals(computed1.getAmount(EUR).Amount, expected1.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
            assertEquals(computed2.getAmount(EUR).Amount, expected2.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
        }
Esempio n. 21
0
        public virtual void test_currencyExposure()
        {
            MultiCurrencyAmount computedWithPayLeg  = PRICER.currencyExposure(TRADE_PAYLEG, RATES, VOLS);
            MultiCurrencyAmount computedWithPremium = PRICER.currencyExposure(TRADE_PREMIUM, RATES, VOLS);
            MultiCurrencyAmount pvWithPayLeg        = PRICER.presentValue(TRADE_PAYLEG, RATES, VOLS);
            MultiCurrencyAmount pvWithPremium       = PRICER.presentValue(TRADE_PREMIUM, RATES, VOLS);
            PointSensitivities  pointWithPayLeg     = PRICER.presentValueSensitivityRates(TRADE_PAYLEG, RATES, VOLS);
            PointSensitivities  pointWithPremium    = PRICER.presentValueSensitivityRates(TRADE_PREMIUM, RATES, VOLS);
            MultiCurrencyAmount expectedWithPayLeg  = RATES.currencyExposure(pointWithPayLeg).plus(pvWithPayLeg);
            MultiCurrencyAmount expectedWithPremium = RATES.currencyExposure(pointWithPremium).plus(pvWithPremium);

            assertEquals(computedWithPayLeg.getAmount(EUR).Amount, expectedWithPayLeg.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
            assertEquals(computedWithPremium.getAmount(EUR).Amount, expectedWithPremium.getAmount(EUR).Amount, NOTIONAL_VALUE * TOL);
        }
        public virtual void currency_exposure_USD()
        {
            LocalDate               startDate     = LocalDate.of(2016, 8, 2);
            LocalDate               fixingDate    = LocalDate.of(2016, 11, 2);
            LocalDate               endDate       = LocalDate.of(2016, 11, 4);
            double                  yearFraction  = 0.25;
            double                  rate          = 0.10;
            RateAccrualPeriod       accrual       = RateAccrualPeriod.builder().startDate(startDate).endDate(endDate).yearFraction(yearFraction).rateComputation(FixedRateComputation.of(rate)).build();
            double                  notional      = 1000000;
            RatePaymentPeriod       fixedFx       = RatePaymentPeriod.builder().accrualPeriods(accrual).fxReset(FxReset.of(FxIndexObservation.of(FxIndices.GBP_USD_WM, fixingDate, REF_DATA), USD)).notional(notional).paymentDate(endDate).dayCount(DayCounts.ONE_ONE).currency(GBP).build(); // 1_000_000 USD paid in GBP at maturity
            PointSensitivityBuilder pts           = PERIOD_PRICER.presentValueSensitivity(fixedFx, PROVIDER);
            MultiCurrencyAmount     ceComputed    = PERIOD_PRICER.currencyExposure(fixedFx, PROVIDER);
            double                  dfUsd         = PROVIDER.discountFactor(USD, endDate);
            double                  ceUsdExpected = notional * yearFraction * rate * dfUsd;

            assertEquals(ceComputed.getAmount(USD).Amount, ceUsdExpected, 1.0E-6);
            MultiCurrencyAmount ceWithoutPvComputed = PROVIDER.currencyExposure(pts.build().convertedTo(USD, PROVIDER));
            CurrencyAmount      pvComputed          = CurrencyAmount.of(GBP, PERIOD_PRICER.presentValue(fixedFx, PROVIDER));
            MultiCurrencyAmount ceComputed2         = ceWithoutPvComputed.plus(pvComputed);

            assertEquals(ceComputed2.getAmount(USD).Amount, ceUsdExpected, TOLERANCE);
            assertEquals(ceComputed2.getAmount(GBP).Amount, 0.0, TOLERANCE);
        }
Esempio n. 23
0
        public virtual void test_presentValue_settle_on_val()
        {
            CurrencyAmount pvComputed = PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_ON_VAL, PROVIDER);
            CurrencyAmount pvExpected = PRICER_PRODUCT.presentValue(BILL_PRODUCT.resolve(REF_DATA), PROVIDER).plus(-PRICE * NOTIONAL_AMOUNT).multipliedBy(QUANTITY);

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected.Amount, TOLERANCE_PV);
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(BILL_TRADE_SETTLE_ON_VAL, PROVIDER);

            assertEquals(ceComputed.Currencies.size(), 1);
            assertTrue(ceComputed.contains(EUR));
            assertEquals(ceComputed.getAmount(EUR).Amount, pvExpected.Amount, TOLERANCE_PV);
            CurrencyAmount cashComputed = PRICER_TRADE.currentCash(BILL_TRADE_SETTLE_ON_VAL, VAL_DATE);

            assertEquals(cashComputed.Currency, EUR);
            assertEquals(cashComputed.Amount, -PRICE * NOTIONAL_AMOUNT * QUANTITY, TOLERANCE_PV);
        }
Esempio n. 24
0
        public virtual void test_pv01_quote()
        {
            ScenarioMarketData                    md                      = FixedCouponBondTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider        provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingFixedCouponBondTradePricer pricer                  = DiscountingFixedCouponBondTradePricer.DEFAULT;
            PointSensitivities                    pvPointSens             = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities        pvParamSens             = provider.parameterSensitivity(pvPointSens);
            CurrencyParameterSensitivities        expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens, provider).multipliedBy(1e-4);
            MultiCurrencyAmount                   expectedPv01Cal         = expectedPv01CalBucketed.total();

            MultiCurrencyScenarioArray sumComputed = FixedCouponBondTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, LOOKUP, md);
            ScenarioArray <CurrencyParameterSensitivities> bucketedComputed = FixedCouponBondTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, LOOKUP, md);

            assertEquals(sumComputed.ScenarioCount, 1);
            assertEquals(sumComputed.get(0).Currencies, ImmutableSet.of(GBP));
            assertTrue(DoubleMath.fuzzyEquals(sumComputed.get(0).getAmount(GBP).Amount, expectedPv01Cal.getAmount(GBP).Amount, 1.0e-10));
            assertEquals(bucketedComputed.ScenarioCount, 1);
            assertTrue(bucketedComputed.get(0).equalWithTolerance(expectedPv01CalBucketed, 1.0e-10));
        }