ForexSwapDiscountingMethod { public double parSpread(final ForexSwap fx, final MulticurveProviderInterface multicurves) { ArgumentChecker.notNull(fx, "Forex swap"); ArgumentChecker.notNull(multicurves, "Multi-curves provider"); final Currency ccy2 = fx.getNearLeg().getCurrency2(); final double pv2 = multicurves.getFxRates().convert(presentValue(fx, multicurves), ccy2).getAmount(); final double dfEnd = multicurves.getDiscountFactor(fx.getFarLeg().getCurrency2(), fx.getFarLeg().getPaymentTime()); final double notional1 = fx.getNearLeg().getPaymentCurrency1().getAmount(); return -pv2 / (notional1 * dfEnd); } private  ForexSwapDiscountingMethod(); static ForexSwapDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final ForexSwap fx, final MulticurveProviderInterface multicurves); MultipleCurrencyAmount currencyExposure(final ForexSwap fx, final MulticurveProviderInterface multicurves); double parSpread(final ForexSwap fx, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final ForexSwap fx, final MulticurveProviderInterface multicurves); MulticurveSensitivity parSpreadCurveSensitivity(final ForexSwap fx, final MulticurveProviderInterface multicurves);  }
@Test public void parSpread() { final double parSpread = METHOD_FX_SWAP.parSpread(FX_SWAP, MULTICURVES); final ForexSwapDefinition fxSwap0Definition = new ForexSwapDefinition(CUR_1, CUR_2, NEAR_DATE, FAR_DATE, NOMINAL_1, MULTICURVES.getFxRate(CUR_1, CUR_2), FORWARD_POINTS + parSpread); final ForexSwap fxSwap0 = (ForexSwap) fxSwap0Definition.toDerivative(REFERENCE_DATE); final MultipleCurrencyAmount pv0 = METHOD_FX_SWAP.presentValue(fxSwap0, MULTICURVES); assertEquals("Forex swap: par spread", 0, MULTICURVES.getFxRates().convert(pv0, CUR_1).getAmount(), TOLERANCE_PV); }
@Test public void parSpreadMethodVsCalculator() { final double parSpreadMethod = METHOD_FX_SWAP.parSpread(FX_SWAP, MULTICURVES); final double parSpreadCalculator = FX_SWAP.accept(PSMQDC, MULTICURVES); assertEquals("Forex swap: par spread", parSpreadMethod, parSpreadCalculator, TOLERANCE_RATE); }