@Override public SwapTrade trade(LocalDate valuationDate, MarketData marketData) { double marketQuote = marketData.getValue(spreadKey) + additionalSpread; FxRate fxRate = marketData.getValue(fxKey()); double rate = fxRate.fxRate(template.getCurrencyPair()); return template.toTrade(valuationDate, BuySell.BUY, 1, rate, marketQuote); }
// ------------------------------------------------------------------------- public void test_rate() { DiscountFxForwardRates test = DiscountFxForwardRates.of(CURRENCY_PAIR, FX_RATE, DFCURVE_GBP, DFCURVE_USD); double dfCcyBaseAtMaturity = DFCURVE_GBP.discountFactor(DATE_REF); double dfCcyCounterAtMaturity = DFCURVE_USD.discountFactor(DATE_REF); double expected = FX_RATE.fxRate(GBP, USD) * (dfCcyBaseAtMaturity / dfCcyCounterAtMaturity); assertEquals(test.rate(GBP, DATE_REF), expected, 1e-12); assertEquals(test.rate(USD, DATE_REF), 1d / expected, 1e-12); }