//-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the currency exposure of the FX barrier option trade.
        /// </summary>
        /// <param name="trade">  the option trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="volatilities">  the Black volatility provider </param>
        /// <returns> the currency exposure </returns>
        public virtual MultiCurrencyAmount currencyExposure(ResolvedFxSingleBarrierOptionTrade trade, RatesProvider ratesProvider, BlackFxOptionVolatilities volatilities)
        {
            Payment        premium   = trade.Premium;
            CurrencyAmount pvPremium = paymentPricer.presentValue(premium, ratesProvider);
            ResolvedFxSingleBarrierOption product = trade.Product;

            return(productPricer.currencyExposure(product, ratesProvider, volatilities).plus(pvPremium));
        }
Ejemplo n.º 2
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);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test_black_currencyExposure()
        public virtual void test_black_currencyExposure()
        {
            double tol = 7.0e-2;     // large tol due to approximated delta

            for (int i = 0; i < 8; ++i)
            {
                // up barrier
                double lowerBarrier = 1.1 + 0.025 * i;
                SimpleConstantContinuousBarrier dko        = SimpleConstantContinuousBarrier.of(BarrierType.DOWN, KnockType.KNOCK_OUT, lowerBarrier);
                ResolvedFxSingleBarrierOption   optionDko  = ResolvedFxSingleBarrierOption.of(CALL, dko, REBATE_BASE);
                MultiCurrencyAmount             ceDkoBlack = BLACK_PRICER.currencyExposure(optionDko, RATE_PROVIDER_FLAT, VOLS_FLAT);
                MultiCurrencyAmount             ceDko      = PRICER_70.currencyExposure(optionDko, RATE_PROVIDER_FLAT, VOLS_FLAT, DATA_70_FLAT);
                assertEquals(ceDko.getAmount(EUR).Amount, ceDkoBlack.getAmount(EUR).Amount, NOTIONAL * tol);
                assertEquals(ceDko.getAmount(USD).Amount, ceDkoBlack.getAmount(USD).Amount, NOTIONAL * tol);
                SimpleConstantContinuousBarrier dki        = SimpleConstantContinuousBarrier.of(BarrierType.DOWN, KnockType.KNOCK_IN, lowerBarrier);
                ResolvedFxSingleBarrierOption   optionDki  = ResolvedFxSingleBarrierOption.of(CALL, dki, REBATE);
                MultiCurrencyAmount             ceDkiBlack = BLACK_PRICER.currencyExposure(optionDki, RATE_PROVIDER_FLAT, VOLS_FLAT);
                MultiCurrencyAmount             ceDki      = PRICER_70.currencyExposure(optionDki, RATE_PROVIDER_FLAT, VOLS_FLAT, DATA_70_FLAT);
                assertEquals(ceDki.getAmount(EUR).Amount, ceDkiBlack.getAmount(EUR).Amount, NOTIONAL * tol);
                assertEquals(ceDki.getAmount(USD).Amount, ceDkiBlack.getAmount(USD).Amount, NOTIONAL * tol);
                // down barrier
                double higherBarrier = 1.45 + 0.025 * i;
                SimpleConstantContinuousBarrier uko        = SimpleConstantContinuousBarrier.of(BarrierType.UP, KnockType.KNOCK_OUT, higherBarrier);
                ResolvedFxSingleBarrierOption   optionUko  = ResolvedFxSingleBarrierOption.of(CALL, uko, REBATE);
                MultiCurrencyAmount             ceUkoBlack = BLACK_PRICER.currencyExposure(optionUko, RATE_PROVIDER_FLAT, VOLS_FLAT);
                MultiCurrencyAmount             ceUko      = PRICER_70.currencyExposure(optionUko, RATE_PROVIDER_FLAT, VOLS_FLAT, DATA_70_FLAT);
                assertEquals(ceUko.getAmount(EUR).Amount, ceUkoBlack.getAmount(EUR).Amount, NOTIONAL * tol);
                assertEquals(ceUko.getAmount(USD).Amount, ceUkoBlack.getAmount(USD).Amount, NOTIONAL * tol);
                SimpleConstantContinuousBarrier uki        = SimpleConstantContinuousBarrier.of(BarrierType.UP, KnockType.KNOCK_IN, higherBarrier);
                ResolvedFxSingleBarrierOption   optionUki  = ResolvedFxSingleBarrierOption.of(CALL, uki, REBATE_BASE);
                MultiCurrencyAmount             ceUkiBlack = BLACK_PRICER.currencyExposure(optionUki, RATE_PROVIDER_FLAT, VOLS_FLAT);
                MultiCurrencyAmount             ceUki      = PRICER_70.currencyExposure(optionUki, RATE_PROVIDER_FLAT, VOLS_FLAT, DATA_70_FLAT);
                assertEquals(ceUki.getAmount(EUR).Amount, ceUkiBlack.getAmount(EUR).Amount, NOTIONAL * tol);
                assertEquals(ceUki.getAmount(USD).Amount, ceUkiBlack.getAmount(USD).Amount, NOTIONAL * tol);
            }
        }