// Checks that the NDF forward rate is coherent with the standard FX forward present value.
        public virtual void test_forwardRateVsForex()
        {
            FxRate fwdNDF = PRICER.forwardFxRate(NDF, PROVIDER);
            FxRate fwdFX  = PRICER_FX.forwardFxRate(FOREX, PROVIDER);

            assertEquals(fwdNDF.fxRate(fwdNDF.Pair), fwdFX.fxRate(fwdFX.Pair), 1e-10);
        }
Example #2
0
 //-------------------------------------------------------------------------
 public virtual void test_price_presentValue()
 {
     for (int i = 0; i < NB_STRIKES; ++i)
     {
         ResolvedFxVanillaOption      call      = CALLS[i];
         ResolvedFxVanillaOptionTrade callTrade = ResolvedFxVanillaOptionTrade.builder().product(call).premium(Payment.of(EUR, 0, VAL_DATE)).build();
         double               computedPriceCall = PRICER.price(call, RATES_PROVIDER, VOLS);
         CurrencyAmount       computedCall      = PRICER.presentValue(call, RATES_PROVIDER, VOLS);
         double               timeToExpiry      = VOLS.relativeTime(EXPIRY);
         FxRate               forward           = FX_PRICER.forwardFxRate(UNDERLYING[i], RATES_PROVIDER);
         double               forwardRate       = forward.fxRate(CURRENCY_PAIR);
         double               strikeRate        = call.Strike;
         SmileDeltaParameters smileAtTime       = VOLS.Smile.smileForExpiry(timeToExpiry);
         double[]             strikes           = smileAtTime.strike(forwardRate).toArray();
         double[]             vols              = smileAtTime.Volatility.toArray();
         double               df                = RATES_PROVIDER.discountFactor(USD, PAY);
         double[]             weights           = this.weights(forwardRate, strikeRate, strikes, timeToExpiry, vols[1]);
         double               expectedPriceCall = BlackFormulaRepository.price(forwardRate, strikeRate, timeToExpiry, vols[1], true);
         for (int j = 0; j < 3; ++j)
         {
             expectedPriceCall += weights[j] * (BlackFormulaRepository.price(forwardRate, strikes[j], timeToExpiry, vols[j], true) - BlackFormulaRepository.price(forwardRate, strikes[j], timeToExpiry, vols[1], true));
         }
         expectedPriceCall *= df;
         assertEquals(computedPriceCall, expectedPriceCall, TOL);
         assertEquals(computedCall.Amount, expectedPriceCall * NOTIONAL, TOL * NOTIONAL);
         // test against trade pricer
         assertEquals(computedCall, TRADE_PRICER.presentValue(callTrade, RATES_PROVIDER, VOLS).getAmount(USD));
     }
 }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the forward exchange rate.
        /// </summary>
        /// <param name="ndf">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the forward rate </returns>
        public virtual FxRate forwardFxRate(ResolvedFxNdf ndf, RatesProvider provider)
        {
            Currency ccySettle   = ndf.SettlementCurrency;
            Currency ccyOther    = ndf.NonDeliverableCurrency;
            double   forwardRate = provider.fxIndexRates(ndf.Index).rate(ndf.Observation, ccySettle);

            return(FxRate.of(ccySettle, ccyOther, forwardRate));
        }
        public virtual void test_forwardValue()
        {
            FxRate         computed    = PRICER.forwardFxRate(NDF, PROVIDER);
            ResolvedFxNdf  ndfFwd      = ResolvedFxNdf.builder().settlementCurrencyNotional(CURRENCY_NOTIONAL).agreedFxRate(computed).observation(FxIndexObservation.of(INDEX, FIXING_DATE, REF_DATA)).paymentDate(PAYMENT_DATE).build();
            CurrencyAmount computedFwd = PRICER.presentValue(ndfFwd, PROVIDER);

            assertEquals(computedFwd.Amount, 0d, NOMINAL_USD * TOL);
        }
Example #5
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the forward exchange rate.
        /// </summary>
        /// <param name="fx">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the forward rate </returns>
        public virtual FxRate forwardFxRate(ResolvedFxSingle fx, RatesProvider provider)
        {
            FxForwardRates fxForwardRates = provider.fxForwardRates(fx.CurrencyPair);
            Payment        basePayment    = fx.BaseCurrencyPayment;
            Payment        counterPayment = fx.CounterCurrencyPayment;
            double         forwardRate    = fxForwardRates.rate(basePayment.Currency, fx.PaymentDate);

            return(FxRate.of(basePayment.Currency, counterPayment.Currency, forwardRate));
        }
Example #6
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            FxRate rate = FxRate.of(GBP, USD, 1.5d);
            SwaptionSensitivity @base    = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD, GBP, 32d);
            SwaptionSensitivity expected = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD, USD, 32d * 1.5d);

            assertEquals(@base.convertedTo(USD, rate), expected);
            assertEquals(@base.convertedTo(GBP, rate), @base);
        }
Example #7
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            FxRate rate = FxRate.of(GBP, USD, 1.5d);
            IborCapletFloorletSabrSensitivity @base    = IborCapletFloorletSabrSensitivity.of(NAME, EXPIRY, SabrParameterType.ALPHA, GBP, 32d);
            IborCapletFloorletSabrSensitivity expected = IborCapletFloorletSabrSensitivity.of(NAME, EXPIRY, SabrParameterType.ALPHA, USD, 32d * 1.5d);

            assertEquals(@base.convertedTo(USD, rate), expected);
            assertEquals(@base.convertedTo(GBP, rate), @base);
        }
Example #8
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            FxRate rate = FxRate.of(GBP, USD, 1.5d);
            SwaptionSabrSensitivity @base    = SwaptionSabrSensitivity.of(NAME, EXPIRY, TENOR, SabrParameterType.ALPHA, GBP, 32d);
            SwaptionSabrSensitivity expected = SwaptionSabrSensitivity.of(NAME, EXPIRY, TENOR, SabrParameterType.ALPHA, USD, 32d * 1.5d);

            assertEquals(@base.convertedTo(USD, rate), expected);
            assertEquals(@base.convertedTo(GBP, rate), @base);
        }
        public virtual void test_of_rate_switchOrder()
        {
            FxSingle test = FxSingle.of(USD_M1600, FxRate.of(USD, GBP, 1d / 1.6d), DATE_2015_06_30);

            assertEquals(test.BaseCurrencyAmount, GBP_P1000);
            assertEquals(test.CounterCurrencyAmount, USD_M1600);
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, GBP_P1000);
        }
        public virtual void test_of_rate_bothZero()
        {
            FxSingle test = FxSingle.of(CurrencyAmount.zero(GBP), FxRate.of(USD, GBP, 1.6d), DATE_2015_06_30);

            assertEquals(test.BaseCurrencyAmount, CurrencyAmount.zero(GBP));
            assertEquals(test.CounterCurrencyAmount.Amount, CurrencyAmount.zero(USD).Amount, 1e-12);
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, CurrencyAmount.of(USD, 0d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_rate_rightOrder()
        {
            ResolvedFxSingle test = ResolvedFxSingle.of(GBP_P1000, FxRate.of(GBP, USD, 1.6d), DATE_2015_06_30);

            assertEquals(test.BaseCurrencyPayment, Payment.of(GBP_P1000, DATE_2015_06_30));
            assertEquals(test.CounterCurrencyPayment, Payment.of(USD_M1600, DATE_2015_06_30));
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, GBP_P1000);
        }
        public virtual void test_forwardFxRate()
        {
            // forward rate is computed by discounting for any RatesProvider input.
            FxRate computed = PRICER.forwardFxRate(FWD, PROVIDER);
            double df1      = PROVIDER.discountFactor(USD, PAYMENT_DATE);
            double df2      = PROVIDER.discountFactor(KRW, PAYMENT_DATE);
            double spot     = PROVIDER.fxRate(USD, KRW);
            FxRate expected = FxRate.of(USD, KRW, spot * df1 / df2);

            assertEquals(computed, expected);
        }
Example #13
0
        public virtual void test_ofForwardPoints_withAdjustment()
        {
            double   nearRate   = 1.6;
            double   fwdPoint   = 0.1;
            FxSwap   test       = FxSwap.ofForwardPoints(GBP_P1000, FxRate.of(GBP, USD, nearRate), fwdPoint, DATE_2011_11_21, DATE_2011_12_21, BDA);
            FxSingle nearLegExp = FxSingle.of(GBP_P1000, CurrencyAmount.of(USD, -1000.0 * nearRate), DATE_2011_11_21, BDA);
            FxSingle farLegExp  = FxSingle.of(GBP_M1000, CurrencyAmount.of(USD, 1000.0 * (nearRate + fwdPoint)), DATE_2011_12_21, BDA);

            assertEquals(test.NearLeg, nearLegExp);
            assertEquals(test.FarLeg, farLegExp);
        }
        public virtual void test_of_rate_withAdjustment()
        {
            FxSingle test = FxSingle.of(GBP_P1000, FxRate.of(GBP, USD, 1.6d), DATE_2015_06_30, BDA);

            assertEquals(test.BaseCurrencyAmount, GBP_P1000);
            assertEquals(test.CounterCurrencyAmount, USD_M1600);
            assertEquals(test.PaymentDate, DATE_2015_06_30);
            assertEquals(test.PaymentDateAdjustment, BDA);
            assertEquals(test.CurrencyPair, CurrencyPair.of(GBP, USD));
            assertEquals(test.ReceiveCurrencyAmount, GBP_P1000);
        }
Example #15
0
        public virtual void getValues()
        {
            FxRateScenarioArray rates = FxRateScenarioArray.of(Currency.EUR, Currency.USD, DoubleArray.of(1.07, 1.08, 1.09));

            assertThat(rates.Pair).isEqualTo(CurrencyPair.of(Currency.EUR, Currency.USD));
            assertThat(rates.ScenarioCount).isEqualTo(3);
            assertThat(rates.get(0)).isEqualTo(FxRate.of(Currency.EUR, Currency.USD, 1.07));
            assertThat(rates.get(1)).isEqualTo(FxRate.of(Currency.EUR, Currency.USD, 1.08));
            assertThat(rates.get(2)).isEqualTo(FxRate.of(Currency.EUR, Currency.USD, 1.09));
            assertThrows(typeof(System.IndexOutOfRangeException), () => rates.get(3));
        }
        //-------------------------------------------------------------------------
        public virtual void convertedTo()
        {
            SwapLegAmount legAmount       = SwapLegAmount.builder().amount(CurrencyAmount.of(Currency.GBP, 10)).payReceive(PayReceive.PAY).type(SwapLegType.FIXED).currency(Currency.GBP).build();
            SwapLegAmount convertedAmount = legAmount.convertedTo(Currency.USD, FxRate.of(Currency.GBP, Currency.USD, 1.6));

            assertThat(convertedAmount.Amount.Currency).isEqualTo(Currency.USD);
            assertThat(convertedAmount.Amount.Amount).isEqualTo(16.0);
            assertThat(convertedAmount.PayReceive).isEqualTo(legAmount.PayReceive);
            assertThat(convertedAmount.Type).isEqualTo(legAmount.Type);
            assertThat(convertedAmount.Currency).isEqualTo(legAmount.Currency);
        }
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            CashFlow @base = CashFlow.ofForecastValue(PAYMENT_DATE, GBP, FORECAST_VALUE, DISCOUNT_FACTOR);
            CashFlow test  = @base.convertedTo(USD, FxRate.of(GBP, USD, 1.5));

            assertThat(test.PaymentDate).isEqualTo(PAYMENT_DATE);
            assertThat(test.PresentValue).hasCurrency(USD);
            assertThat(test.PresentValue).hasAmount(PRESENT_VALUE * 1.5, TOLERANCE);
            assertThat(test.ForecastValue).hasCurrency(USD);
            assertThat(test.ForecastValue).hasAmount(FORECAST_VALUE * 1.5, TOLERANCE);
            assertThat(test.DiscountFactor).isCloseTo(DISCOUNT_FACTOR, TOLERANCE);
        }
        public virtual void test_builder_inverse()
        {
            FxRate fxRate = FxRate.of(USD, GBP, 0.7d);
            FxNdf  test   = FxNdf.builder().agreedFxRate(fxRate).settlementCurrencyNotional(CURRENCY_NOTIONAL).index(GBP_USD_WM).paymentDate(PAYMENT_DATE).build();

            assertEquals(test.AgreedFxRate, fxRate);
            assertEquals(test.Index, GBP_USD_WM);
            assertEquals(test.NonDeliverableCurrency, USD);
            assertEquals(test.SettlementCurrencyNotional, CURRENCY_NOTIONAL);
            assertEquals(test.PaymentDate, PAYMENT_DATE);
            assertEquals(test.SettlementCurrency, GBP);
        }
Example #19
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData             md         = FxSingleTradeCalculationFunctionTest.marketData();
            RatesProvider                  provider   = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingFxSingleTradePricer pricer     = DiscountingFxSingleTradePricer.DEFAULT;
            MultiCurrencyAmount            expectedPv = pricer.presentValue(RTRADE, provider);
            MultiCurrencyAmount            expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            MultiCurrencyAmount            expectedCurrentCash      = pricer.currentCash(RTRADE, provider);
            FxRate expectedForwardFx = pricer.forwardFxRate(RTRADE, provider);

            assertEquals(FxSingleTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(FxSingleTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(FxSingleTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
            assertEquals(FxSingleTradeCalculations.DEFAULT.forwardFxRate(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedForwardFx)));
        }
        public virtual void test_of()
        {
            SwapPaymentPeriod pp = mock(typeof(SwapPaymentPeriod));

            when(pp.Currency).thenReturn(Currency.GBP);
            ResolvedSwapLeg leg       = ResolvedSwapLeg.builder().type(SwapLegType.FIXED).payReceive(PayReceive.PAY).paymentPeriods(pp).build();
            SwapLegAmount   legAmount = SwapLegAmount.of(leg, CurrencyAmount.of(Currency.GBP, 10));
            SwapLegAmount   test      = legAmount.convertedTo(Currency.USD, FxRate.of(Currency.GBP, Currency.USD, 1.6));

            assertThat(test.Amount.Currency).isEqualTo(Currency.USD);
            assertThat(test.Amount.Amount).isEqualTo(16.0);
            assertThat(test.PayReceive).isEqualTo(legAmount.PayReceive);
            assertThat(test.Type).isEqualTo(legAmount.Type);
            assertThat(test.Currency).isEqualTo(legAmount.Currency);
        }
        // convention-based
        // ideally we'd use the trade date plus "period to start" to get the spot/payment date
        // but we don't have all the data and it gets complicated in places like TRY, RUB and AED
        private static FxSingleTrade parseConvention(CsvRow row, TradeInfo info)
        {
            CurrencyPair pair        = CurrencyPair.parse(row.getValue(CONVENTION_FIELD));
            BuySell      buySell     = LoaderUtils.parseBuySell(row.getValue(BUY_SELL_FIELD));
            Currency     currency    = Currency.parse(row.getValue(CURRENCY_FIELD));
            double       notional    = LoaderUtils.parseDouble(row.getValue(NOTIONAL_FIELD));
            double       fxRate      = LoaderUtils.parseDouble(row.getValue(FX_RATE_FIELD));
            LocalDate    paymentDate = LoaderUtils.parseDate(row.getValue(PAYMENT_DATE_FIELD));
            Optional <BusinessDayAdjustment> paymentAdj = parsePaymentDateAdjustment(row);

            CurrencyAmount amount = CurrencyAmount.of(currency, buySell.normalize(notional));
            FxSingle       fx     = paymentAdj.map(adj => FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate, adj)).orElseGet(() => FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate));

            return(FxSingleTrade.of(info, fx));
        }
Example #22
0
        private Trade parseNdf(FpmlDocument document, XmlElement fxEl, XmlElement ndfEl, CurrencyAmount curr1Amount, CurrencyAmount curr2Amount, LocalDate valueDate, TradeInfoBuilder tradeInfoBuilder)
        {
            // rate
            XmlElement rateEl = fxEl.getChild("exchangeRate");
            double     rate   = document.parseDecimal(rateEl.getChild("rate"));
            XmlElement pairEl = rateEl.getChild("quotedCurrencyPair");
            Currency   curr1  = document.parseCurrency(pairEl.getChild("currency1"));
            Currency   curr2  = document.parseCurrency(pairEl.getChild("currency2"));
            string     basis  = pairEl.getChild("quoteBasis").Content;
            FxRate     fxRate;

            if ("Currency2PerCurrency1".Equals(basis))
            {
                fxRate = FxRate.of(curr1, curr2, rate);
            }
            else if ("Currency1PerCurrency2".Equals(basis))
            {
                fxRate = FxRate.of(curr2, curr1, rate);
            }
            else
            {
                throw new FpmlParseException("Unknown quote basis: " + basis);
            }
            // settlement currency
            Currency       settleCurr       = document.parseCurrency(ndfEl.getChild("settlementCurrency"));
            CurrencyAmount settleCurrAmount = curr1Amount.Currency.Equals(settleCurr) ? curr1Amount : curr2Amount;
            // index
            XmlElement        fixingEl        = ndfEl.getChild("fixing"); // only support one of these in pricing model
            LocalDate         fixingDate      = document.parseDate(fixingEl.getChild("fixingDate"));
            DaysAdjustment    offset          = DaysAdjustment.ofCalendarDays(Math.toIntExact(valueDate.until(fixingDate, DAYS)));
            XmlElement        sourceEl        = fixingEl.getChild("fxSpotRateSource"); // required for our model
            XmlElement        primarySourceEl = sourceEl.getChild("primaryRateSource");
            string            primarySource   = primarySourceEl.getChild("rateSource").Content;
            string            primaryPage     = primarySourceEl.findChild("rateSourcePage").map(e => e.Content).orElse("");
            LocalTime         time            = document.parseTime(sourceEl.getChild("fixingTime").getChild("hourMinuteTime")); // required for our model
            HolidayCalendarId calendar        = document.parseBusinessCenter(sourceEl.getChild("fixingTime").getChild("businessCenter"));
            FxIndex           index           = ImmutableFxIndex.builder().name(primarySource + "/" + primaryPage + "/" + time).currencyPair(CurrencyPair.of(curr1, curr2)).fixingCalendar(calendar).maturityDateOffset(offset).build();

            return(FxNdfTrade.builder().info(tradeInfoBuilder.build()).product(FxNdf.builder().settlementCurrencyNotional(settleCurrAmount).agreedFxRate(fxRate).index(index).paymentDate(valueDate).build()).build());
        }
Example #23
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValueSensitivityVolatility()
        {
            for (int i = 0; i < NB_STRIKES; ++i)
            {
                PointSensitivities   computedCall = PRICER.presentValueSensitivityModelParamsVolatility(CALLS[i], RATES_PROVIDER, VOLS).build();
                double               timeToExpiry = VOLS.relativeTime(EXPIRY);
                FxRate               forward      = FX_PRICER.forwardFxRate(UNDERLYING[i], RATES_PROVIDER);
                double               forwardRate  = forward.fxRate(CURRENCY_PAIR);
                double               strikeRate   = CALLS[i].Strike;
                SmileDeltaParameters smileAtTime  = VOLS.Smile.smileForExpiry(timeToExpiry);
                double[]             strikes      = smileAtTime.strike(forwardRate).toArray();
                double[]             vols         = smileAtTime.Volatility.toArray();
                double               df           = RATES_PROVIDER.discountFactor(USD, PAY);
                double[]             weights      = this.weights(forwardRate, strikeRate, strikes, timeToExpiry, vols[1]);
                double[]             vegas        = new double[3];
                vegas[2] = BlackFormulaRepository.vega(forwardRate, strikeRate, timeToExpiry, vols[1]) * df * NOTIONAL;
                for (int j = 0; j < 3; j += 2)
                {
                    vegas[2] -= weights[j] * NOTIONAL *df *BlackFormulaRepository.vega(forwardRate, strikes[j], timeToExpiry, vols[1]);
                }
                vegas[0] = weights[0] * NOTIONAL *df *BlackFormulaRepository.vega(forwardRate, strikes[0], timeToExpiry, vols[0]);

                vegas[1] = weights[2] * NOTIONAL *df *BlackFormulaRepository.vega(forwardRate, strikes[2], timeToExpiry, vols[2]);

                double[] expStrikes = new double[] { strikes[0], strikes[2], strikes[1] };
                for (int j = 0; j < 3; ++j)
                {
                    FxOptionSensitivity sensi = (FxOptionSensitivity)computedCall.Sensitivities.get(j);
                    assertEquals(sensi.Sensitivity, vegas[j], TOL * NOTIONAL);
                    assertEquals(sensi.Strike, expStrikes[j], TOL);
                    assertEquals(sensi.Forward, forwardRate, TOL);
                    assertEquals(sensi.Currency, USD);
                    assertEquals(sensi.CurrencyPair, CURRENCY_PAIR);
                    assertEquals(sensi.Expiry, timeToExpiry);
                }
            }
        }
        public virtual void test_builder_wrongRate()
        {
            FxRate fxRate = FxRate.of(GBP, EUR, 1.1d);

            assertThrowsIllegalArg(() => FxNdf.builder().agreedFxRate(fxRate).settlementCurrencyNotional(CURRENCY_NOTIONAL).index(GBP_USD_WM).paymentDate(PAYMENT_DATE).build());
        }
 public virtual void test_of_rate_wrongCurrency()
 {
     assertThrowsIllegalArg(() => FxSingle.of(GBP_P1000, FxRate.of(USD, EUR, 1.45d), DATE_2015_06_30));
 }
        public virtual void test_ofRates_currency_source()
        {
            FxRateLookup test       = FxRateLookup.ofRates(EUR, OBS_SOURCE);
            MarketData   marketData = ImmutableMarketData.builder(VAL_DATE).addValue(FxRateId.of(GBP, USD, OBS_SOURCE), FxRate.of(GBP, USD, 1.5d)).build();

            assertEquals(test.fxRateProvider(marketData).fxRate(GBP, USD), 1.5d);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            DiscountFxForwardRates test1 = DiscountFxForwardRates.of(CURRENCY_PAIR, FX_RATE, DFCURVE_GBP, DFCURVE_USD);

            coverImmutableBean(test1);
            DiscountFxForwardRates test2 = DiscountFxForwardRates.of(CURRENCY_PAIR, FX_RATE.inverse(), DFCURVE_GBP2, DFCURVE_USD2);

            coverBeanEquals(test1, test2);
            DiscountFxForwardRates test3 = DiscountFxForwardRates.of(CurrencyPair.of(USD, EUR), FxRate.of(EUR, USD, 1.2d), DFCURVE_USD, ZeroRateDiscountFactors.of(EUR, DATE_VAL, CURVE2));

            coverBeanEquals(test1, test3);
        }
        public virtual void test_builder_wrongRate()
        {
            FxRate fxRate = FxRate.of(GBP, EUR, 1.1d);

            assertThrowsIllegalArg(() => ResolvedFxNdf.builder().agreedFxRate(fxRate).observation(FxIndexObservation.of(GBP_USD_WM, FIXING_DATE, REF_DATA)).paymentDate(PAYMENT_DATE).settlementCurrencyNotional(CURRENCY_NOTIONAL).build());
        }
        internal static ResolvedFxNdf sut2()
        {
            FxRate fxRate = FxRate.of(GBP, EUR, 1.1d);

            return(ResolvedFxNdf.builder().agreedFxRate(fxRate).observation(FxIndexObservation.of(EUR_GBP_ECB, FIXING_DATE, REF_DATA)).paymentDate(PAYMENT_DATE).settlementCurrencyNotional(CURRENCY_NOTIONAL).build());
        }
Example #30
0
        //-------------------------------------------------------------------------
        public virtual void test_getValue_fxIdentity()
        {
            BuiltScenarioMarketData test = BuiltScenarioMarketData.builder(MarketDataBox.ofSingleValue(VAL_DATE)).build();

            assertEquals(test.ScenarioCount, 1);
            assertEquals(test.getValue(FxRateId.of(GBP, GBP)), MarketDataBox.ofSingleValue(FxRate.of(GBP, GBP, 1)));
        }