public void test_serialization() { FxSwapTemplate test = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); assertSerialization(test); }
public void test_of_far() { FxSwapTemplate test = FxSwapTemplate.of(FAR_PERIOD, CONVENTION); assertEquals(test.getPeriodToNear(), Period.ZERO); assertEquals(test.getPeriodToFar(), FAR_PERIOD); assertEquals(test.getConvention(), CONVENTION); assertEquals(test.getCurrencyPair(), EUR_USD); }
private static CurveNode curveFxSwapCurveNode( String conventionStr, String timeStr, String label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { if (!DoubleMath.fuzzyEquals(spread, 0d, 1e-10d)) { throw new IllegalArgumentException("Additional spread must be zero for FX swaps"); } Matcher matcher = SIMPLE_YMD_TIME_REGEX.matcher(timeStr.toUpperCase(Locale.ENGLISH)); if (!matcher.matches()) { throw new IllegalArgumentException(Messages.format("Invalid time format for FX swap: {}", timeStr)); } Period periodToEnd = Period.parse("P" + matcher.group(1)); FxSwapConvention convention = FxSwapConvention.of(conventionStr); FxSwapTemplate template = FxSwapTemplate.of(periodToEnd, convention); return FxSwapCurveNode.builder() .template(template) .farForwardPointsId(quoteId) .label(label) .date(date) .dateOrder(order) .build(); }
public void test_of_near_far() { FxSwapTemplate test = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); assertEquals(test.getPeriodToNear(), NEAR_PERIOD); assertEquals(test.getPeriodToFar(), FAR_PERIOD); assertEquals(test.getConvention(), CONVENTION); assertEquals(test.getCurrencyPair(), EUR_USD); }
public void test_createTrade() { FxSwapTemplate base = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); LocalDate tradeDate = LocalDate.of(2015, 10, 29); FxSwapTrade test = base.createTrade(tradeDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA); LocalDate spotDate = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA); LocalDate nearDate = spotDate.plus(NEAR_PERIOD); LocalDate farDate = spotDate.plus(FAR_PERIOD); BusinessDayAdjustment bda = CONVENTION.getBusinessDayAdjustment(); FxSwap expected = FxSwap.ofForwardPoints( CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, bda); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getProduct(), expected); }
public void coverage() { FxSwapCurveNode test = FxSwapCurveNode.of(TEMPLATE, QUOTE_ID_PTS); coverImmutableBean(test); FxSwapCurveNode test2 = FxSwapCurveNode.builder() .label(LABEL) .template(FxSwapTemplate.of(Period.ZERO, FAR_PERIOD, CONVENTION)) .fxRateId(FX_RATE_ID2) .farForwardPointsId(QUOTE_ID_PTS2) .date(CurveNodeDate.LAST_FIXING) .build(); coverBeanEquals(test, test2); }