GeneratorSwapXCcyIborIbor extends GeneratorInstrument<GeneratorAttributeFX> { @Override public SwapXCcyIborIborDefinition generateInstrument(final ZonedDateTime date, final double spread, final double notional, final GeneratorAttributeFX attribute) { ArgumentChecker.notNull(date, "Reference date"); ArgumentChecker.notNull(attribute, "Attributes"); final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, _spotLag, _calendar1); final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spot, attribute.getStartPeriod(), _iborIndex1, _calendar1); final double fx = attribute.getFXMatrix().getFxRate(_iborIndex1.getCurrency(), _iborIndex2.getCurrency()); return SwapXCcyIborIborDefinition.from(startDate, attribute.getEndPeriod(), this, notional, fx * notional, spread, true, _calendar1, _calendar2); } GeneratorSwapXCcyIborIbor(final String name, final IborIndex iborIndex1, final IborIndex iborIndex2, final Calendar calendar1, final Calendar calendar2);  GeneratorSwapXCcyIborIbor(final String name, final IborIndex iborIndex1, final IborIndex iborIndex2, final BusinessDayConvention businessDayConvention,
      final boolean endOfMonth, final int spotLag, final Calendar calendar1, final Calendar calendar2); IborIndex getIborIndex1(); IborIndex getIborIndex2(); BusinessDayConvention getBusinessDayConvention(); int getSpotLag(); Boolean isEndOfMonth(); Calendar getCalendar1(); Calendar getCalendar2(); @Override SwapXCcyIborIborDefinition generateInstrument(final ZonedDateTime date, final double spread, final double notional, final GeneratorAttributeFX attribute); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void generateInstrument() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 7, 17); final Period tenor = Period.ofMonths(6); final double spread = -0.0050; final double notional = 12345; final double fxRateEURUSD = 1.25; final FXMatrix fxMatrix = new FXMatrix(EURIBOR3M.getCurrency(), USDLIBOR3M.getCurrency(), fxRateEURUSD); final GeneratorAttributeFX attribute = new GeneratorAttributeFX(tenor, fxMatrix); final SwapXCcyIborIborDefinition insGenerated = EURIBOR3MUSDLIBOR3M.generateInstrument(referenceDate, spread, notional, attribute); final ZonedDateTime settleDate = ScheduleCalculator.getAdjustedDate(referenceDate, EURIBOR3MUSDLIBOR3M.getSpotLag(), NYC); final SwapXCcyIborIborDefinition insExpected = SwapXCcyIborIborDefinition.from(settleDate, tenor, EURIBOR3MUSDLIBOR3M, notional, notional * fxRateEURUSD, spread, true, NYC, NYC); assertEquals("GeneratorSwap: generate instrument", insExpected, insGenerated); final SwapDefinition insGenerated2 = EURIBOR3MUSDLIBOR3M_2.generateInstrument(referenceDate, spread, -notional, attribute); assertEquals("GeneratorSwap: generate instrument", insExpected.getFirstLeg(), insGenerated2.getFirstLeg()); assertEquals("GeneratorSwap: generate instrument", insExpected.getSecondLeg(), insGenerated2.getSecondLeg()); }