//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "name") public void test_extendedEnum(FixedIborSwapConvention convention, String name) public virtual void test_extendedEnum(FixedIborSwapConvention convention, string name) { FixedIborSwapConvention.of(name); // ensures map is populated ImmutableMap <string, FixedIborSwapConvention> map = FixedIborSwapConvention.extendedEnum().lookupAll(); assertEquals(map.get(name), convention); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3373707: // name this.name = (SwaptionVolatilitiesName)newValue; break; case 2039569265: // convention this.convention = (FixedIborSwapConvention)newValue; break; case 1905311443: // dayCount this.dayCount = (DayCount)newValue; break; case 2096253127: // interpolator this.interpolator = (SurfaceInterpolator)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
private ResolvedSwap createUnderlyingSwap(LocalDate fixingDate) { FixedIborSwapConvention conv = INDEX.Template.Convention; LocalDate effectiveDate = conv.calculateSpotDateFromTradeDate(fixingDate, REF_DATA); LocalDate maturityDate = effectiveDate.plus(INDEX.Template.Tenor); Swap swap = conv.toTrade(fixingDate, effectiveDate, maturityDate, BuySell.BUY, 1d, 1d).Product; return(swap.resolve(REF_DATA)); }
private FixedIborSwapTemplate(Period periodToStart, Tenor tenor, FixedIborSwapConvention convention) { JodaBeanUtils.notNull(periodToStart, "periodToStart"); JodaBeanUtils.notNull(tenor, "tenor"); JodaBeanUtils.notNull(convention, "convention"); this.periodToStart = periodToStart; this.tenor = tenor; this.convention = convention; validate(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "stubIbor") public void test_stub_ibor(FixedIborSwapConvention convention, com.opengamma.strata.basics.date.Tenor tenor) public virtual void test_stub_ibor(FixedIborSwapConvention convention, Tenor tenor) { LocalDate tradeDate = LocalDate.of(2015, 10, 20); SwapTrade swap = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA); ResolvedSwap swapResolved = swap.Product.resolve(REF_DATA); LocalDate endDate = swapResolved.getLeg(PayReceive.PAY).get().EndDate; assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusMonths(1))); assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusMonths(1))); }
private SabrSwaptionDefinition(SwaptionVolatilitiesName name, FixedIborSwapConvention convention, DayCount dayCount, SurfaceInterpolator interpolator) { JodaBeanUtils.notNull(name, "name"); JodaBeanUtils.notNull(convention, "convention"); JodaBeanUtils.notNull(dayCount, "dayCount"); JodaBeanUtils.notNull(interpolator, "interpolator"); this.name = name; this.convention = convention; this.dayCount = dayCount; this.interpolator = interpolator; }
private static SwapIndex parseSwapIndex(CsvRow row) { string name = row.getField(NAME_FIELD); bool active = bool.Parse(row.getField(ACTIVE_FIELD)); FixedIborSwapConvention convention = FixedIborSwapConvention.of(row.getField(CONVENTION_FIELD)); Tenor tenor = Tenor.parse(row.getField(TENOR_FIELD)); LocalTime time = LocalTime.parse(row.getField(FIXING_TIME_FIELD), TIME_FORMAT); ZoneId zoneId = ZoneId.of(row.getField(FIXING_ZONE_FIELD)); // build result return(ImmutableSwapIndex.builder().name(name).active(active).fixingTime(time).fixingZone(zoneId).template(FixedIborSwapTemplate.of(tenor, convention)).build()); }
public virtual void test_toTrade_periodTenor() { FixedIborSwapConvention @base = ImmutableFixedIborSwapConvention.of(NAME, FIXED, IBOR); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate startDate = date(2015, 8, 7); LocalDate endDate = date(2025, 8, 7); SwapTrade test = @base.createTrade(tradeDate, Period.ofMonths(3), TENOR_10Y, BUY, NOTIONAL_2M, 0.25d, REF_DATA); Swap expected = Swap.of(FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), IBOR.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M)); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
public virtual void test_toTrade_dates() { FixedIborSwapConvention @base = ImmutableFixedIborSwapConvention.of(NAME, FIXED, IBOR); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate startDate = date(2015, 8, 5); LocalDate endDate = date(2015, 11, 5); SwapTrade test = @base.toTrade(tradeDate, startDate, endDate, BUY, NOTIONAL_2M, 0.25d); Swap expected = Swap.of(FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), IBOR.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M)); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
private static CurveNode curveFixedIborCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order) { Matcher matcher = SIMPLE_YMD_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH)); if (!matcher.matches()) { throw new System.ArgumentException(Messages.format("Invalid time format for Fixed-Ibor swap: {}", timeStr)); } Period periodToEnd = Period.parse("P" + matcher.group(1)); FixedIborSwapConvention convention = FixedIborSwapConvention.of(conventionStr); FixedIborSwapTemplate template = FixedIborSwapTemplate.of(Tenor.of(periodToEnd), convention); return(FixedIborSwapCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ImmutableConstructor private NormalSwaptionExpiryStrikeVolatilities(com.opengamma.strata.product.swap.type.FixedIborSwapConvention convention, java.time.ZonedDateTime valuationDateTime, com.opengamma.strata.market.surface.Surface surface) private NormalSwaptionExpiryStrikeVolatilities(FixedIborSwapConvention convention, ZonedDateTime valuationDateTime, Surface surface) { ArgChecker.notNull(convention, "convention"); ArgChecker.notNull(valuationDateTime, "valuationDateTime"); ArgChecker.notNull(surface, "surface"); surface.Metadata.XValueType.checkEquals(ValueType.YEAR_FRACTION, "Incorrect x-value type for Normal volatilities"); surface.Metadata.YValueType.checkEquals(ValueType.STRIKE, "Incorrect y-value type for Normal volatilities"); surface.Metadata.ZValueType.checkEquals(ValueType.NORMAL_VOLATILITY, "Incorrect z-value type for Normal volatilities"); DayCount dayCount = surface.Metadata.findInfo(SurfaceInfoType.DAY_COUNT).orElseThrow(() => new System.ArgumentException("Incorrect surface metadata, missing DayCount")); this.valuationDateTime = valuationDateTime; this.surface = surface; this.convention = convention; this.dayCount = dayCount; }
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 = (FixedIborSwapConvention)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 2039569265: // convention this.convention = (FixedIborSwapConvention)newValue; break; case -949589828: // valuationDateTime this.valuationDateTime = (ZonedDateTime)newValue; break; case -1853231955: // surface this.surface = (Surface)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
//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(FixedIborSwapConvention convention, com.opengamma.strata.basics.schedule.Frequency frequency) public virtual void test_period(FixedIborSwapConvention convention, Frequency frequency) { assertEquals(convention.FixedLeg.AccrualFrequency, frequency); }
private readonly DayCount dayCount; // cached, not a property //------------------------------------------------------------------------- /// <summary> /// Obtains an instance from the implied volatility surface and the date-time for which it is valid. /// <para> /// The surface is specified by an instance of <seealso cref="Surface"/>, such as <seealso cref="InterpolatedNodalSurface"/>. /// The surface must contain the correct metadata: /// <ul> /// <li>The x-value type must be <seealso cref="ValueType#YEAR_FRACTION"/> /// <li>The y-value type must be <seealso cref="ValueType#STRIKE"/> /// <li>The z-value type must be <seealso cref="ValueType#NORMAL_VOLATILITY"/> /// <li>The day count must be set in the additional information using <seealso cref="SurfaceInfoType#DAY_COUNT"/> /// </ul> /// Suitable surface metadata can be created using /// <seealso cref="Surfaces#normalVolatilityByExpiryStrike(String, DayCount)"/>. /// /// </para> /// </summary> /// <param name="convention"> the swap convention that the volatilities are to be used for </param> /// <param name="valuationDateTime"> the valuation date-time </param> /// <param name="surface"> the implied volatility surface </param> /// <returns> the volatilities </returns> public static NormalSwaptionExpiryStrikeVolatilities of(FixedIborSwapConvention convention, ZonedDateTime valuationDateTime, Surface surface) { return(new NormalSwaptionExpiryStrikeVolatilities(convention, valuationDateTime, surface)); }
//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(FixedIborSwapConvention convention, com.opengamma.strata.basics.date.BusinessDayConvention dayConvention) public virtual void test_day_convention(FixedIborSwapConvention convention, BusinessDayConvention dayConvention) { assertEquals(convention.FixedLeg.AccrualBusinessDayAdjustment.Convention, dayConvention); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(FixedIborSwapConvention convention, String name) public virtual void test_of_lookup(FixedIborSwapConvention convention, string name) { assertEquals(FixedIborSwapConvention.of(name), convention); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "floatLeg") public void test_float_leg(FixedIborSwapConvention convention, com.opengamma.strata.basics.index.IborIndex floatLeg) public virtual void test_float_leg(FixedIborSwapConvention convention, IborIndex floatLeg) { assertEquals(convention.FloatingLeg.Index, floatLeg); }
// For vanilla swaps the holidays calendars on the fixed leg should be // consistent with the maturity calendars on the floating leg //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "floatLeg") public void test_holiday_calendars_match(FixedIborSwapConvention convention, com.opengamma.strata.basics.index.IborIndex floatLeg) public virtual void test_holiday_calendars_match(FixedIborSwapConvention convention, IborIndex floatLeg) { assertEquals(convention.FixedLeg.AccrualBusinessDayAdjustment.Calendar, floatLeg.MaturityDateOffset.Adjustment.Calendar); }
public virtual void test_of_lookup_notFound() { assertThrowsIllegalArg(() => FixedIborSwapConvention.of("Rubbish")); }
//------------------------------------------------------------------------- /// <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 FixedIborSwapTemplate of(Tenor tenor, FixedIborSwapConvention convention) { return(of(Period.ZERO, tenor, convention)); }
private readonly DayCount dayCount; // cached, not a property //------------------------------------------------------------------------- /// <summary> /// Obtains an instance from the implied volatility surface and the date-time for which it is valid. /// <para> /// The surface is specified by an instance of <seealso cref="Surface"/>, such as <seealso cref="InterpolatedNodalSurface"/>. /// The surface must contain the correct metadata: /// <ul> /// <li>The x-value type must be <seealso cref="ValueType#YEAR_FRACTION"/> /// <li>The y-value type must be <seealso cref="ValueType#YEAR_FRACTION"/> /// <li>The z-value type must be <seealso cref="ValueType#BLACK_VOLATILITY"/> /// <li>The day count must be set in the additional information using <seealso cref="SurfaceInfoType#DAY_COUNT"/> /// </ul> /// Suitable surface metadata can be created using /// <seealso cref="Surfaces#blackVolatilityByExpiryTenor(String, DayCount)"/>. /// /// </para> /// </summary> /// <param name="convention"> the swap convention that the volatilities are to be used for </param> /// <param name="valuationDateTime"> the valuation date-time </param> /// <param name="surface"> the implied volatility surface </param> /// <returns> the volatilities </returns> public static BlackSwaptionExpiryTenorVolatilities of(FixedIborSwapConvention convention, ZonedDateTime valuationDateTime, Surface surface) { return(new BlackSwaptionExpiryTenorVolatilities(convention, valuationDateTime, surface)); }
/// <summary> /// Creates a template based on the specified period, tenor and convention. /// <para> /// The period from the spot date to the start date is 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 FixedIborSwapTemplate of(Period periodToStart, Tenor tenor, FixedIborSwapConvention convention) { return(FixedIborSwapTemplate.builder().periodToStart(periodToStart).tenor(tenor).convention(convention).build()); }
public virtual void test_of_lookup_null() { assertThrowsIllegalArg(() => FixedIborSwapConvention.of((string)null)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance from the name, convention, day count and tenors. /// </summary> /// <param name="name"> the name of the volatilities </param> /// <param name="convention"> the swap convention that the volatilities are to be used for </param> /// <param name="dayCount"> the day count to use </param> /// <param name="interpolator"> the interpolator for the alpha, rho and nu surfaces </param> /// <returns> the volatilities </returns> public static SabrSwaptionDefinition of(SwaptionVolatilitiesName name, FixedIborSwapConvention convention, DayCount dayCount, SurfaceInterpolator interpolator) { return(new SabrSwaptionDefinition(name, convention, dayCount, interpolator)); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(FixedIborSwapTemplate beanToCopy) { this.periodToStart_Renamed = beanToCopy.PeriodToStart; this.tenor_Renamed = beanToCopy.Tenor; this.convention_Renamed = beanToCopy.Convention; }
public virtual void test_serialization() { FixedIborSwapConvention test = ImmutableFixedIborSwapConvention.of(NAME, FIXED, IBOR); assertSerialization(test); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "dayCount") public void test_day_count(FixedIborSwapConvention convention, com.opengamma.strata.basics.date.DayCount dayCount) public virtual void test_day_count(FixedIborSwapConvention convention, DayCount dayCount) { assertEquals(convention.FixedLeg.DayCount, dayCount); }
public virtual void test_swapIndicies() { ImmutableMap <string, SwapIndex> mapAll = SwapIndices.ENUM_LOOKUP.lookupAll(); ImmutableList <SwapIndex> indexAll = mapAll.values().asList(); ImmutableList <string> nameAll = mapAll.Keys.asList(); int size = indexAll.size(); for (int i = 0; i < size; ++i) { // check no duplication for (int j = i + 1; j < size; ++j) { assertFalse(nameAll.get(i).Equals(nameAll.get(j))); assertFalse(indexAll.get(i).Equals(indexAll.get(j))); } } foreach (string name in nameAll) { SwapIndex index = mapAll.get(name); assertEquals(SwapIndex.of(name), index); assertEquals(index.Active, true); FixedIborSwapTemplate temp = index.Template; FixedIborSwapConvention conv = temp.Convention; Tenor tenor = temp.Tenor; LocalTime time = index.FixingTime; ZoneId zone = index.FixingZone; // test consistency between name and template assertTrue(name.Contains(tenor.ToString())); if (name.StartsWith("USD", StringComparison.Ordinal)) { assertTrue(name.Contains("1100") || name.Contains("1500")); assertTrue(conv.Equals(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M)); assertTrue(zone.Equals(NEY_YORK)); } if (name.StartsWith("GBP", StringComparison.Ordinal)) { assertTrue(name.Contains("1100")); if (tenor.Equals(Tenor.TENOR_1Y)) { assertTrue(conv.Equals(FixedIborSwapConventions.GBP_FIXED_1Y_LIBOR_3M)); } else { assertTrue(conv.Equals(FixedIborSwapConventions.GBP_FIXED_6M_LIBOR_6M)); } assertTrue(zone.Equals(LONDON)); } if (name.StartsWith("EUR", StringComparison.Ordinal)) { assertTrue(name.Contains("1100") || name.Contains("1200")); if (tenor.Equals(Tenor.TENOR_1Y)) { assertTrue(conv.Equals(FixedIborSwapConventions.EUR_FIXED_1Y_EURIBOR_3M)); } else { assertTrue(conv.Equals(FixedIborSwapConventions.EUR_FIXED_1Y_EURIBOR_6M)); } assertTrue(zone.Equals(FRANKFURT)); } if (name.Contains("1100")) { assertTrue(time.Equals(LocalTime.of(11, 0))); } if (name.Contains("1200")) { assertTrue(time.Equals(LocalTime.of(12, 0))); } if (name.Contains("1500")) { assertTrue(time.Equals(LocalTime.of(15, 0))); } assertEquals(index.calculateFixingDateTime(date(2015, 6, 30)), date(2015, 6, 30).atTime(time).atZone(zone)); } }
/// <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(FixedIborSwapConvention convention) { JodaBeanUtils.notNull(convention, "convention"); this.convention_Renamed = convention; return(this); }