private XCcyIborIborSwapTemplate(Period periodToStart, Tenor tenor, XCcyIborIborSwapConvention convention) { JodaBeanUtils.notNull(periodToStart, "periodToStart"); JodaBeanUtils.notNull(tenor, "tenor"); JodaBeanUtils.notNull(convention, "convention"); this.periodToStart = periodToStart; this.tenor = tenor; this.convention = convention; validate(); }
//------------------------------------------------------------------------- public virtual void coverage() { XCcyIborIborSwapTemplate test = XCcyIborIborSwapTemplate.of(Period.ofMonths(3), TENOR_10Y, CONV); coverImmutableBean(test); DaysAdjustment bda2 = DaysAdjustment.ofBusinessDays(1, EUTA); XCcyIborIborSwapConvention conv2 = ImmutableXCcyIborIborSwapConvention.of("XXX", USD3M, EUR3M, bda2); XCcyIborIborSwapTemplate test2 = XCcyIborIborSwapTemplate.of(Period.ofMonths(2), TENOR_2Y, conv2); coverBeanEquals(test, test2); }
private static CurveNode curveXCcyIborIborCurveNode(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 Cross Currency Swap: {}", timeStr)); } Period periodToEnd = Period.parse("P" + matcher.group(1)); XCcyIborIborSwapConvention convention = XCcyIborIborSwapConvention.of(conventionStr); XCcyIborIborSwapTemplate template = XCcyIborIborSwapTemplate.of(Tenor.of(periodToEnd), convention); return(XCcyIborIborSwapCurveNode.builder().template(template).spreadId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); }
// create a swap from known start/end dates private static SwapTrade createSwap(TradeInfo info, string conventionStr, LocalDate startDate, LocalDate endDate, BuySell buySell, double notional, double fixedRate, double?fxRateOpt) { if (fxRateOpt.HasValue) { XCcyIborIborSwapConvention convention = XCcyIborIborSwapConvention.of(conventionStr); double notionalFlat = notional * fxRateOpt.Value; return(convention.toTrade(info, startDate, endDate, buySell, notional, notionalFlat, fixedRate)); } else { SingleCurrencySwapConvention convention = SingleCurrencySwapConvention.of(conventionStr); return(convention.toTrade(info, startDate, endDate, buySell, notional, fixedRate)); } }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case -574688858: // periodToStart this.periodToStart_Renamed = (Period)newValue; break; case 110246592: // tenor this.tenor_Renamed = (Tenor)newValue; break; case 2039569265: // convention this.convention_Renamed = (XCcyIborIborSwapConvention)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
//------------------------------------------------------------------------- /// <summary> /// Obtains a template based on the specified tenor and convention. /// <para> /// The swap will start on the spot date. /// /// </para> /// </summary> /// <param name="tenor"> the tenor of the swap </param> /// <param name="convention"> the market convention </param> /// <returns> the template </returns> public static XCcyIborIborSwapTemplate of(Tenor tenor, XCcyIborIborSwapConvention convention) { return(of(Period.ZERO, tenor, convention)); }
/// <summary> /// Sets the market convention of the swap. </summary> /// <param name="convention"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder convention(XCcyIborIborSwapConvention convention) { JodaBeanUtils.notNull(convention, "convention"); this.convention_Renamed = convention; return(this); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(XCcyIborIborSwapTemplate beanToCopy) { this.periodToStart_Renamed = beanToCopy.PeriodToStart; this.tenor_Renamed = beanToCopy.Tenor; this.convention_Renamed = beanToCopy.Convention; }
/// <summary> /// Obtains a template based on the specified period, tenor and convention. /// <para> /// The period from the spot date to the start date is specified. /// The tenor from the start date to the end date is also specified. /// /// </para> /// </summary> /// <param name="periodToStart"> the period between the spot date and the start date </param> /// <param name="tenor"> the tenor of the swap </param> /// <param name="convention"> the market convention </param> /// <returns> the template </returns> public static XCcyIborIborSwapTemplate of(Period periodToStart, Tenor tenor, XCcyIborIborSwapConvention convention) { return(XCcyIborIborSwapTemplate.builder().periodToStart(periodToStart).tenor(tenor).convention(convention).build()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "period") public void test_period(XCcyIborIborSwapConvention convention, com.opengamma.strata.basics.schedule.Frequency frequency) public virtual void test_period(XCcyIborIborSwapConvention convention, Frequency frequency) { assertEquals(convention.SpreadLeg.PaymentFrequency, frequency); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "notionalExchange") public void test_notional_exchange(XCcyIborIborSwapConvention convention, boolean notionalExchange) public virtual void test_notional_exchange(XCcyIborIborSwapConvention convention, bool notionalExchange) { assertEquals(convention.SpreadLeg.NotionalExchange, notionalExchange); assertEquals(convention.FlatLeg.NotionalExchange, notionalExchange); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "dayConvention") public void test_day_convention(XCcyIborIborSwapConvention convention, com.opengamma.strata.basics.date.BusinessDayConvention dayConvention) public virtual void test_day_convention(XCcyIborIborSwapConvention convention, BusinessDayConvention dayConvention) { assertEquals(convention.SpreadLeg.AccrualBusinessDayAdjustment.Convention, dayConvention); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "flatLegBda") public void test_flat_leg_bdc(XCcyIborIborSwapConvention convention, com.opengamma.strata.basics.date.BusinessDayAdjustment bda) public virtual void test_flat_leg_bdc(XCcyIborIborSwapConvention convention, BusinessDayAdjustment bda) { assertEquals(convention.FlatLeg.AccrualBusinessDayAdjustment, bda); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "flatLegIndex") public void test_flat_leg(XCcyIborIborSwapConvention convention, com.opengamma.strata.basics.index.IborIndex index) public virtual void test_flat_leg(XCcyIborIborSwapConvention convention, IborIndex index) { assertEquals(convention.FlatLeg.Index, index); }
// parse a trade based on a convention internal static SwapTrade parseWithConvention(CsvRow row, TradeInfo info, TradeCsvInfoResolver resolver, string conventionStr) { BuySell buySell = LoaderUtils.parseBuySell(row.getValue(BUY_SELL_FIELD)); double notional = LoaderUtils.parseDouble(row.getValue(NOTIONAL_FIELD)); double fixedRate = LoaderUtils.parseDoublePercent(row.getValue(FIXED_RATE_FIELD)); Optional <Period> periodToStartOpt = row.findValue(PERIOD_TO_START_FIELD).map(s => LoaderUtils.parsePeriod(s)); Optional <Tenor> tenorOpt = row.findValue(TENOR_FIELD).map(s => LoaderUtils.parseTenor(s)); Optional <LocalDate> startDateOpt = row.findValue(START_DATE_FIELD).map(s => LoaderUtils.parseDate(s)); Optional <LocalDate> endDateOpt = row.findValue(END_DATE_FIELD).map(s => LoaderUtils.parseDate(s)); Optional <RollConvention> rollCnvOpt = row.findValue(ROLL_CONVENTION_FIELD).map(s => LoaderUtils.parseRollConvention(s)); Optional <StubConvention> stubCnvOpt = row.findValue(STUB_CONVENTION_FIELD).map(s => StubConvention.of(s)); Optional <LocalDate> firstRegStartDateOpt = row.findValue(FIRST_REGULAR_START_DATE_FIELD).map(s => LoaderUtils.parseDate(s)); Optional <LocalDate> lastRegEndDateOpt = row.findValue(LAST_REGULAR_END_DATE_FIELD).map(s => LoaderUtils.parseDate(s)); BusinessDayConvention dateCnv = row.findValue(DATE_ADJ_CNV_FIELD).map(s => LoaderUtils.parseBusinessDayConvention(s)).orElse(BusinessDayConventions.MODIFIED_FOLLOWING); Optional <HolidayCalendarId> dateCalOpt = row.findValue(DATE_ADJ_CAL_FIELD).map(s => HolidayCalendarId.of(s)); double? fxRateOpt = row.findValue(FX_RATE_FIELD).map(str => LoaderUtils.parseDouble(str)); // explicit dates take precedence over relative ones if (startDateOpt.Present && endDateOpt.Present) { if (periodToStartOpt.Present || tenorOpt.Present) { throw new System.ArgumentException("Swap trade had invalid combination of fields. When these fields are found " + ImmutableList.of(CONVENTION_FIELD, START_DATE_FIELD, END_DATE_FIELD) + " then these fields must not be present " + ImmutableList.of(PERIOD_TO_START_FIELD, TENOR_FIELD)); } LocalDate startDate = startDateOpt.get(); LocalDate endDate = endDateOpt.get(); SwapTrade trade = createSwap(info, conventionStr, startDate, endDate, buySell, notional, fixedRate, fxRateOpt); return(adjustTrade(trade, rollCnvOpt, stubCnvOpt, firstRegStartDateOpt, lastRegEndDateOpt, dateCnv, dateCalOpt)); } // start date + tenor if (startDateOpt.Present && tenorOpt.Present) { if (periodToStartOpt.Present || endDateOpt.Present) { throw new System.ArgumentException("Swap trade had invalid combination of fields. When these fields are found " + ImmutableList.of(CONVENTION_FIELD, START_DATE_FIELD, TENOR_FIELD) + " then these fields must not be present " + ImmutableList.of(PERIOD_TO_START_FIELD, END_DATE_FIELD)); } LocalDate startDate = startDateOpt.get(); Tenor tenor = tenorOpt.get(); LocalDate endDate = startDate.plus(tenor); SwapTrade trade = createSwap(info, conventionStr, startDate, endDate, buySell, notional, fixedRate, fxRateOpt); return(adjustTrade(trade, rollCnvOpt, stubCnvOpt, firstRegStartDateOpt, lastRegEndDateOpt, dateCnv, dateCalOpt)); } // relative dates if (periodToStartOpt.Present && tenorOpt.Present && info.TradeDate.Present) { if (startDateOpt.Present || endDateOpt.Present) { throw new System.ArgumentException("Swap trade had invalid combination of fields. When these fields are found " + ImmutableList.of(CONVENTION_FIELD, PERIOD_TO_START_FIELD, TENOR_FIELD, TRADE_DATE_FIELD) + " then these fields must not be present " + ImmutableList.of(START_DATE_FIELD, END_DATE_FIELD)); } LocalDate tradeDate = info.TradeDate.get(); Period periodToStart = periodToStartOpt.get(); Tenor tenor = tenorOpt.get(); if (fxRateOpt.HasValue) { XCcyIborIborSwapConvention convention = XCcyIborIborSwapConvention.of(conventionStr); double notionalFlat = notional * fxRateOpt.Value; SwapTrade trade = convention.createTrade(tradeDate, periodToStart, tenor, buySell, notional, notionalFlat, fixedRate, resolver.ReferenceData); trade = trade.toBuilder().info(info).build(); return(adjustTrade(trade, rollCnvOpt, stubCnvOpt, firstRegStartDateOpt, lastRegEndDateOpt, dateCnv, dateCalOpt)); } else { SingleCurrencySwapConvention convention = SingleCurrencySwapConvention.of(conventionStr); SwapTrade trade = convention.createTrade(tradeDate, periodToStart, tenor, buySell, notional, fixedRate, resolver.ReferenceData); trade = trade.toBuilder().info(info).build(); return(adjustTrade(trade, rollCnvOpt, stubCnvOpt, firstRegStartDateOpt, lastRegEndDateOpt, dateCnv, dateCalOpt)); } } // no match throw new System.ArgumentException("Swap trade had invalid combination of fields. These fields are mandatory:" + ImmutableList.of(BUY_SELL_FIELD, NOTIONAL_FIELD, FIXED_RATE_FIELD) + " and one of these combinations is mandatory: " + ImmutableList.of(CONVENTION_FIELD, TRADE_DATE_FIELD, PERIOD_TO_START_FIELD, TENOR_FIELD) + " or " + ImmutableList.of(CONVENTION_FIELD, START_DATE_FIELD, TENOR_FIELD) + " or " + ImmutableList.of(CONVENTION_FIELD, START_DATE_FIELD, END_DATE_FIELD)); }