/** * Returns a curve node for an FX Swap using the specified instrument template and keys. * <p> * A suitable default label will be created. * * @param template the template used for building the instrument for the node * @param farForwardPointsId the identifier of the FX points at the far date * @return a node whose instrument is built from the template using a market rate */ public static FxSwapCurveNode of(FxSwapTemplate template, ObservableId farForwardPointsId) { return builder() .template(template) .farForwardPointsId(farForwardPointsId) .build(); }
/** * Returns a curve node for an FX Swap using the specified instrument template and keys and label. * * @param template the template used for building the instrument for the node * @param farForwardPointsId the identifier of the FX points at the far date * @param label the label to use for the node * @return a node whose instrument is built from the template using a market rate */ public static FxSwapCurveNode of(FxSwapTemplate template, ObservableId farForwardPointsId, String label) { return builder() .template(template) .farForwardPointsId(farForwardPointsId) .label(label) .build(); }
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_builder_defaults() { FxSwapCurveNode test = FxSwapCurveNode.builder() .template(TEMPLATE) .farForwardPointsId(QUOTE_ID_PTS) .build(); assertEquals(test.getLabel(), LABEL_AUTO); assertEquals(test.getFxRateId(), FX_RATE_ID); assertEquals(test.getFarForwardPointsId(), QUOTE_ID_PTS); assertEquals(test.getTemplate(), TEMPLATE); assertEquals(test.getDate(), CurveNodeDate.END); }
public void test_builder() { FxSwapCurveNode test = FxSwapCurveNode.builder() .label(LABEL) .template(TEMPLATE) .fxRateId(FX_RATE_ID2) .farForwardPointsId(QUOTE_ID_PTS) .date(CurveNodeDate.LAST_FIXING) .build(); assertEquals(test.getLabel(), LABEL); assertEquals(test.getFxRateId(), FX_RATE_ID2); assertEquals(test.getFarForwardPointsId(), QUOTE_ID_PTS); assertEquals(test.getTemplate(), TEMPLATE); assertEquals(test.getDate(), CurveNodeDate.LAST_FIXING); }
public void test_builder_noTemplate() { assertThrowsIllegalArg(() -> FxSwapCurveNode.builder().label(LABEL).farForwardPointsId(QUOTE_ID_PTS).build()); }
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); }