Skip to content

Commit

Permalink
Support Overnight-Overnight nodes in curves
Browse files Browse the repository at this point in the history
Add conventions and templates
Fixes #1911
  • Loading branch information
jodastephen committed Apr 16, 2021
1 parent d2c5222 commit d96fc6f
Show file tree
Hide file tree
Showing 9 changed files with 2,155 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public static ExtendedEnum<OvernightIndex> extendedEnum() {
public abstract int getPublicationDateOffset();

/**
* Gets the number of days to add to the fixing date to obtain the effective date.
* Gets the number of business days to add to the fixing date to obtain the effective date.
* <p>
* In most cases, the settlement date and start of the implied deposit is on the fixing date.
* In a few cases, the settlement date is the following business day.
* This property is zero if settlement is on the fixing date, or one if it is the next day.
* Maturity is always one business day after the settlement date.
*
* @return the effective date offset
* @return the effective date offset in business days
*/
public abstract int getEffectiveDateOffset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.opengamma.strata.market.curve.node.IborIborSwapCurveNode;
import com.opengamma.strata.market.curve.node.OvernightFutureCurveNode;
import com.opengamma.strata.market.curve.node.OvernightIborSwapCurveNode;
import com.opengamma.strata.market.curve.node.OvernightOvernightSwapCurveNode;
import com.opengamma.strata.market.curve.node.TermDepositCurveNode;
import com.opengamma.strata.market.curve.node.ThreeLegBasisSwapCurveNode;
import com.opengamma.strata.market.curve.node.XCcyIborIborSwapCurveNode;
Expand All @@ -83,6 +84,8 @@
import com.opengamma.strata.product.swap.type.IborIborSwapTemplate;
import com.opengamma.strata.product.swap.type.OvernightIborSwapConvention;
import com.opengamma.strata.product.swap.type.OvernightIborSwapTemplate;
import com.opengamma.strata.product.swap.type.OvernightOvernightSwapConvention;
import com.opengamma.strata.product.swap.type.OvernightOvernightSwapTemplate;
import com.opengamma.strata.product.swap.type.ThreeLegBasisSwapConvention;
import com.opengamma.strata.product.swap.type.ThreeLegBasisSwapTemplate;
import com.opengamma.strata.product.swap.type.XCcyIborIborSwapConvention;
Expand Down Expand Up @@ -453,6 +456,9 @@ private static CurveNode createCurveNode(
if ("ONI".equalsIgnoreCase(typeStr) || "OvernightIborBasisSwap".equalsIgnoreCase(typeStr)) {
return curveOvernightIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order);
}
if ("ONO".equalsIgnoreCase(typeStr) || "OvernightOvernightSwap".equalsIgnoreCase(typeStr)) {
return curveOvernightOvernightCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order);
}
if ("XCS".equalsIgnoreCase(typeStr) || "XCcyIborIborSwap".equalsIgnoreCase(typeStr)) {
return curveXCcyIborIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order);
}
Expand Down Expand Up @@ -777,6 +783,33 @@ private static CurveNode curveOvernightIborCurveNode(
.build();
}

private static CurveNode curveOvernightOvernightCurveNode(
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 Overnight-Overnight swap: {}", timeStr));
}
Period periodToEnd = Period.parse("P" + matcher.group(1));
OvernightOvernightSwapConvention convention = OvernightOvernightSwapConvention.of(conventionStr);
OvernightOvernightSwapTemplate template = OvernightOvernightSwapTemplate.of(Tenor.of(periodToEnd), convention);
return OvernightOvernightSwapCurveNode.builder()
.template(template)
.rateId(quoteId)
.additionalSpread(spread)
.label(label)
.date(date)
.dateOrder(order)
.build();
}

private static CurveNode curveFxSwapCurveNode(
String conventionStr,
String timeStr,
Expand Down
Loading

0 comments on commit d96fc6f

Please sign in to comment.