/** * Returns a curve node for a three leg basis swap using the specified instrument template, rate key and spread. * <p> * A suitable default label will be created. * * @param template the template defining the node instrument * @param rateId the identifier of the market data providing the rate for the node instrument * @param additionalSpread the additional spread amount added to the market quote * @return a node whose instrument is built from the template using a market rate */ public static ThreeLegBasisSwapCurveNode of( ThreeLegBasisSwapTemplate template, ObservableId rateId, double additionalSpread) { return builder() .template(template) .rateId(rateId) .additionalSpread(additionalSpread) .build(); }
private static CurveNode curveThreeLegBasisCurveNode( String conventionStr, String timeStr, String label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { Matcher matcher = SIMPLE_YM_TIME_REGEX.matcher(timeStr.toUpperCase(Locale.ENGLISH)); if (!matcher.matches()) { throw new IllegalArgumentException(Messages.format("Invalid time format for Three legs basis swap: {}", timeStr)); } Period periodToEnd = Period.parse("P" + matcher.group(1)); ThreeLegBasisSwapConvention convention = ThreeLegBasisSwapConvention.of(conventionStr); ThreeLegBasisSwapTemplate template = ThreeLegBasisSwapTemplate.of(Tenor.of(periodToEnd), convention); return ThreeLegBasisSwapCurveNode.builder() .template(template) .rateId(quoteId) .additionalSpread(spread) .label(label) .date(date) .dateOrder(order) .build(); }
public void test_builder() { ThreeLegBasisSwapCurveNode test = ThreeLegBasisSwapCurveNode.builder() .label(LABEL) .template(TEMPLATE) .rateId(QUOTE_ID) .additionalSpread(SPREAD) .build(); assertEquals(test.getLabel(), LABEL); assertEquals(test.getRateId(), QUOTE_ID); assertEquals(test.getAdditionalSpread(), SPREAD); assertEquals(test.getTemplate(), TEMPLATE); assertEquals(test.getDate(), CurveNodeDate.END); }