ForexDiscountingMethod { public double parSpread(final Forex fx, final MulticurveProviderInterface multicurves) { ArgumentChecker.notNull(fx, "Forex"); ArgumentChecker.notNull(multicurves, "Multi-curves provider"); final Currency ccy2 = fx.getCurrency2(); final double pv2 = multicurves.getFxRates().convert(presentValue(fx, multicurves), ccy2).getAmount(); final double dfEnd = multicurves.getDiscountFactor(fx.getCurrency2(), fx.getPaymentTime()); final double notional1 = fx.getPaymentCurrency1().getAmount(); return pv2 / (notional1 * dfEnd); } private  ForexDiscountingMethod(); static ForexDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final Forex fx, final MulticurveProviderInterface multicurves); MultipleCurrencyAmount currencyExposure(final Forex fx, final MulticurveProviderInterface multicurves); double parSpread(final Forex fx, final MulticurveProviderInterface multicurves); double forwardForexRate(final Forex fx, final MulticurveProviderInterface multicurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final Forex fx, final MulticurveProviderInterface multicurves); MulticurveSensitivity parSpreadCurveSensitivity(final Forex fx, final MulticurveProviderInterface multicurves);  }
@Test public void parSpread() { final double ps = METHOD_FX.parSpread(FX, MULTICURVES); final ForexDefinition fx0Definition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, NOMINAL_1, FX_RATE + ps); final Forex fx0 = fx0Definition.toDerivative(REFERENCE_DATE); final MultipleCurrencyAmount pv0 = fx0.accept(PVDC, MULTICURVES); assertEquals("ForexDiscountingMethod: parSpread", 0, MULTICURVES.getFxRates().convert(pv0, CUR_1).getAmount(), TOLERANCE_RATE); }
@Test public void parSpreadMethodVsCalculator() { final double parSpreadMethod = METHOD_FX.parSpread(FX, MULTICURVES); final double parSpreadCalculator = FX.accept(PSMQDC, MULTICURVES); assertEquals("Forex: par spread", parSpreadMethod, parSpreadCalculator, TOLERANCE_RATE); }