private FxSwapCurveNode(FxSwapTemplate template, FxRateId fxRateId, ObservableId farForwardPointsId, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder) { JodaBeanUtils.notNull(template, "template"); JodaBeanUtils.notNull(fxRateId, "fxRateId"); JodaBeanUtils.notNull(farForwardPointsId, "farForwardPointsId"); JodaBeanUtils.notEmpty(label, "label"); JodaBeanUtils.notNull(dateOrder, "dateOrder"); this.template = template; this.fxRateId = fxRateId; this.farForwardPointsId = farForwardPointsId; this.label = label; this.date_Renamed = date; this.dateOrder = dateOrder; }
private XCcyIborIborSwapCurveNode(XCcyIborIborSwapTemplate template, FxRateId fxRateId, ObservableId spreadId, double additionalSpread, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder) { JodaBeanUtils.notNull(template, "template"); JodaBeanUtils.notNull(fxRateId, "fxRateId"); JodaBeanUtils.notNull(spreadId, "spreadId"); JodaBeanUtils.notEmpty(label, "label"); JodaBeanUtils.notNull(dateOrder, "dateOrder"); this.template = template; this.fxRateId = fxRateId; this.spreadId = spreadId; this.additionalSpread = additionalSpread; this.label = label; this.date_Renamed = date; this.dateOrder = dateOrder; }
// parse date order private static CurveNodeDate parseDate(string dateStr) { if (dateStr.Length == 0) { return(CurveNodeDate.END); } if (dateStr.Length == 10 && dateStr[4] == '-' && dateStr[7] == '-') { return(CurveNodeDate.of(LoaderUtils.parseDate(dateStr))); } string dateUpper = dateStr.ToUpper(Locale.ENGLISH); if (dateUpper.Equals("END")) { return(CurveNodeDate.END); } if (dateUpper.Equals("LASTFIXING")) { return(CurveNodeDate.LAST_FIXING); } throw new System.ArgumentException(Messages.format("Invalid format for node date, should be date in 'yyyy-MM-dd' format, 'End' or 'LastFixing': {}", dateUpper)); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case -1321546630: // template this.template_Renamed = (XCcyIborIborSwapTemplate)newValue; break; case -1054985843: // fxRateId this.fxRateId_Renamed = (FxRateId)newValue; break; case -1759090194: // spreadId this.spreadId_Renamed = (ObservableId)newValue; break; case 291232890: // additionalSpread this.additionalSpread_Renamed = (double?)newValue.Value; break; case 102727412: // label this.label_Renamed = (string)newValue; break; case 3076014: // date this.date_Renamed = (CurveNodeDate)newValue; break; case -263699392: // dateOrder this.dateOrder_Renamed = (CurveNodeDateOrder)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
public virtual void test_metadata_fixed() { LocalDate nodeDate = VAL_DATE.plusMonths(1); FixedOvernightSwapCurveNode node = FixedOvernightSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL).withDate(CurveNodeDate.of(nodeDate)); LocalDate valuationDate = LocalDate.of(2015, 1, 22); DatedParameterMetadata metadata = node.metadata(valuationDate, REF_DATA); assertEquals(metadata.Date, nodeDate); assertEquals(metadata.Label, node.Label); }
static CalibrationDiscountFactorUsd2FomcDatesOisIrsTest() { DSC_NAMES[DSCON_CURVE_NAME] = USD; ISet <Index> usdFedFundSet = new HashSet <Index>(); usdFedFundSet.Add(USD_FED_FUND); IDX_NAMES[DSCON_CURVE_NAME] = usdFedFundSet; ISet <Index> usdLibor3Set = new HashSet <Index>(); usdLibor3Set.Add(USD_LIBOR_3M); IDX_NAMES[FWD3_CURVE_NAME] = usdLibor3Set; double fixingValue = 0.002345; LocalDateDoubleTimeSeries tsBdUsdLibor3M = LocalDateDoubleTimeSeries.builder().put(VAL_DATE_BD, fixingValue).build(); TS_BD_LIBOR3M = ImmutableMarketData.builder(VAL_DATE_BD).addTimeSeries(IndexQuoteId.of(USD_LIBOR_3M), tsBdUsdLibor3M).build(); for (int i = 0; i < DSC_NB_DEPO_NODES; i++) { BusinessDayAdjustment bda = BusinessDayAdjustment.of(FOLLOWING, USNY); TermDepositConvention convention = ImmutableTermDepositConvention.of("USD-Dep", USD, bda, ACT_360, DaysAdjustment.ofBusinessDays(DSC_DEPO_OFFSET[i], USNY)); LocalDate nodeDate = FOMC_NODES[i]; if (nodeDate != null) { DSC_NODES[i] = TermDepositCurveNode.builder().template(TermDepositTemplate.of(Period.ofDays(1), convention)).rateId(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i]))).date(CurveNodeDate.of(nodeDate)).build(); } else { DSC_NODES[i] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), convention), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i]))); } } for (int i = 0; i < DSC_NB_OIS_NODES; i++) { LocalDate nodeDate = FOMC_NODES[DSC_NB_DEPO_NODES + i]; if (nodeDate != null) { DSC_NODES[DSC_NB_DEPO_NODES + i] = FixedOvernightSwapCurveNode.builder().template(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS)).rateId(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[DSC_NB_DEPO_NODES + i]))).date(CurveNodeDate.of(nodeDate)).build(); } else { DSC_NODES[DSC_NB_DEPO_NODES + i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[DSC_NB_DEPO_NODES + i]))); } } FWD3_NODES[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[0]))); for (int i = 0; i < FWD3_NB_FRA_NODES; i++) { FWD3_NODES[i + 1] = FraCurveNode.of(FraTemplate.of(FWD3_FRA_TENORS[i], USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i + 1]))); } for (int i = 0; i < FWD3_NB_IRS_NODES; i++) { FWD3_NODES[i + 1 + FWD3_NB_FRA_NODES] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD3_IRS_TENORS[i]), USD_FIXED_6M_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i + 1 + FWD3_NB_FRA_NODES]))); } ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE_BD); for (int i = 0; i < FWD3_NB_NODES; i++) { builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])), FWD3_MARKET_QUOTES[i]); } for (int i = 0; i < DSC_NB_NODES; i++) { builder.addValue(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])), DSC_MARKET_QUOTES[i]); } ALL_QUOTES_BD = builder.build(); IList <CurveNode[]> groupDsc = new List <CurveNode[]>(); groupDsc.Add(DSC_NODES); CURVES_NODES.Add(groupDsc); IList <CurveNode[]> groupFwd3 = new List <CurveNode[]>(); groupFwd3.Add(FWD3_NODES); CURVES_NODES.Add(groupFwd3); IList <CurveMetadata> groupDsc = new List <CurveMetadata>(); groupDsc.Add(DefaultCurveMetadata.builder().curveName(DSCON_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build()); CURVES_METADATA.Add(groupDsc); IList <CurveMetadata> groupFwd3 = new List <CurveMetadata>(); groupFwd3.Add(DefaultCurveMetadata.builder().curveName(FWD3_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build()); CURVES_METADATA.Add(groupFwd3); }
private FixedIborSwapCurveNode(FixedIborSwapTemplate template, ObservableId rateId, double additionalSpread, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder) { JodaBeanUtils.notNull(template, "template"); JodaBeanUtils.notNull(rateId, "rateId"); JodaBeanUtils.notEmpty(label, "label"); JodaBeanUtils.notNull(date, "date"); JodaBeanUtils.notNull(dateOrder, "dateOrder"); this.template = template; this.rateId = rateId; this.additionalSpread = additionalSpread; this.label = label; this.date_Renamed = date; this.dateOrder = dateOrder; }
public virtual void test_metadata_fixed() { FixedInflationSwapCurveNode node = FixedInflationSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL).withDate(CurveNodeDate.of(VAL_DATE)); LocalDate valuationDate = LocalDate.of(2015, 1, 22); DatedParameterMetadata metadata = node.metadata(valuationDate, REF_DATA); assertEquals(metadata.Date, VAL_DATE); assertEquals(metadata.Label, node.Label); }
private static CurveNode curveFraCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { Matcher matcher = FRA_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH)); if (!matcher.matches()) { throw new System.ArgumentException(Messages.format("Invalid time format for FRA: {}", timeStr)); } Period periodToStart = Period.parse("P" + matcher.group(1) + "M"); Period periodToEnd = Period.parse("P" + matcher.group(2) + "M"); FraConvention convention = FraConvention.of(conventionStr); FraTemplate template = FraTemplate.of(periodToStart, periodToEnd, convention); return(FraCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); }
private static CurveNode curveIborFixingDepositCurveNode(string conventionStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { IborFixingDepositConvention convention = IborFixingDepositConvention.of(conventionStr); IborFixingDepositTemplate template = IborFixingDepositTemplate.of(convention.Index.Tenor.Period, convention); return(IborFixingDepositCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); }
//------------------------------------------------------------------------- // create the curve node private static CurveNode createCurveNode(string typeStr, string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { if ("DEP".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "TermDeposit".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveTermDepositCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("FIX".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "IborFixingDeposit".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveIborFixingDepositCurveNode(conventionStr, label, quoteId, spread, date, order)); } if ("FRA".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveFraCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("IFU".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "IborFuture".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveIborFutureCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("OIS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FixedOvernightSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveFixedOvernightCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("IRS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FixedIborSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveFixedIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("BAS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "IborIborSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveIborIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("BS3".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "ThreeLegBasisSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveThreeLegBasisCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("ONI".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "OvernightIborBasisSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveOvernightIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("XCS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "XCcyIborIborSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveXCcyIborIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("FXS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FxSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveFxSwapCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } if ("INF".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FixedInflationSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase)) { return(curveFixedInflationCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order)); } throw new System.ArgumentException(Messages.format("Invalid curve node type: {}", typeStr)); }
private IborFutureCurveNode(IborFutureTemplate template, QuoteId rateId, double additionalSpread, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder) { JodaBeanUtils.notNull(template, "template"); JodaBeanUtils.notNull(rateId, "rateId"); JodaBeanUtils.notNull(label, "label"); JodaBeanUtils.notNull(dateOrder, "dateOrder"); this.template = template; this.rateId = rateId; this.additionalSpread = additionalSpread; this.label = label; this.date_Renamed = date; this.dateOrder = dateOrder; }
//------------------------------------------------------------------------- /// <summary> /// Returns a copy of this node with the specified date. /// </summary> /// <param name="date"> the date to use </param> /// <returns> the node based on this node with the specified date </returns> public ThreeLegBasisSwapCurveNode withDate(CurveNodeDate date) { return(new ThreeLegBasisSwapCurveNode(template, rateId, additionalSpread, label, date, dateOrder)); }
//------------------------------------------------------------------------- /// <summary> /// Returns a copy of this node with the specified date. /// </summary> /// <param name="date"> the date to use </param> /// <returns> the node based on this node with the specified date </returns> public IborFixingDepositCurveNode withDate(CurveNodeDate date) { return(new IborFixingDepositCurveNode(template, rateId, additionalSpread, label, date, dateOrder)); }
private static CurveNode curveIborFutureCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { Matcher matcher = FUT_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH)); if (matcher.matches()) { Period periodToStart = Period.parse("P" + matcher.group(1)); int sequenceNumber = int.Parse(matcher.group(2)); IborFutureConvention convention = IborFutureConvention.of(conventionStr); IborFutureTemplate template = IborFutureTemplate.of(periodToStart, sequenceNumber, convention); return(IborFutureCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); } Matcher matcher2 = FUT_MONTH_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH)); if (matcher2.matches()) { YearMonth yearMonth = YearMonth.parse(matcher2.group(1), YM_FORMATTER); IborFutureConvention convention = IborFutureConvention.of(conventionStr); IborFutureTemplate template = IborFutureTemplate.of(yearMonth, convention); return(IborFutureCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); } throw new System.ArgumentException(Messages.format("Invalid time format for Ibor Future: {}", timeStr)); }
/// <summary> /// Sets the method by which the date of the node is calculated, defaulted to 'End'. </summary> /// <param name="date"> the new value </param> /// <returns> this, for chaining, not null </returns> public Builder date(CurveNodeDate date) { this.date_Renamed = date; return(this); }
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 System.ArgumentException("Additional spread must be zero for FX swaps"); } Matcher matcher = SIMPLE_YMD_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH)); if (!matcher.matches()) { throw new System.ArgumentException(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()); }
//------------------------------------------------------------------------- /// <summary> /// Returns a copy of this node with the specified date. /// </summary> /// <param name="date"> the date to use </param> /// <returns> the node based on this node with the specified date </returns> public FixedIborSwapCurveNode withDate(CurveNodeDate date) { return(new FixedIborSwapCurveNode(template, rateId, additionalSpread, label, date, dateOrder)); }
private static CurveNode curveFixedInflationCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { Matcher matcher = SIMPLE_YM_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH)); if (!matcher.matches()) { throw new System.ArgumentException(Messages.format("Invalid time format for Fixed-Inflation swap: {}", timeStr)); } Period periodToEnd = Period.parse("P" + matcher.group(1)); FixedInflationSwapConvention convention = FixedInflationSwapConvention.of(conventionStr); FixedInflationSwapTemplate template = FixedInflationSwapTemplate.of(Tenor.of(periodToEnd), convention); return(FixedInflationSwapCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); }
/// <summary> /// Sets the method by which the date of the node is calculated, defaulted to 'End'. </summary> /// <param name="date"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder date(CurveNodeDate date) { JodaBeanUtils.notNull(date, "date"); this.date_Renamed = date; return(this); }
//------------------------------------------------------------------------- /// <summary> /// Returns a copy of this node with the specified date. /// </summary> /// <param name="date"> the date to use </param> /// <returns> the node based on this node with the specified date </returns> public XCcyIborIborSwapCurveNode withDate(CurveNodeDate date) { return(new XCcyIborIborSwapCurveNode(template, fxRateId, spreadId, additionalSpread, label, date, dateOrder)); }
public virtual void test_metadata_fixed() { LocalDate nodeDate = VAL_DATE.plusMonths(1); IborFutureCurveNode node = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL).withDate(CurveNodeDate.of(nodeDate)); DatedParameterMetadata metadata = node.metadata(VAL_DATE, REF_DATA); assertEquals(metadata.Date, nodeDate); assertEquals(metadata.Label, node.Label); }
//------------------------------------------------------------------------- /// <summary> /// Returns a copy of this node with the specified date. /// </summary> /// <param name="date"> the date to use </param> /// <returns> the node based on this node with the specified date </returns> public FxSwapCurveNode withDate(CurveNodeDate date) { return(new FxSwapCurveNode(template, fxRateId, farForwardPointsId, label, date, dateOrder)); }