public virtual void test_getFloatingRateName() { foreach (PriceIndex index in PriceIndex.extendedEnum().lookupAll().values()) { assertEquals(index.FloatingRateName, FloatingRateName.of(index.Name)); } }
// for historical compatibility, we determine known format by looking for these specific things // the new approach is to require either the 'Reference' or the 'Sensitivity Type' column private static bool knownReference(string refStr) { try { Optional <IborIndex> ibor = IborIndex.extendedEnum().find(refStr); if (ibor.Present) { return(true); } else { Optional <FloatingRateName> frName = FloatingRateName.extendedEnum().find(refStr); if (frName.Present) { return(true); } else if (refStr.Length == 3) { Currency.of(refStr); // this may throw an exception validating the string return(true); } else { return(false); } } } catch (Exception) { return(false); } }
//------------------------------------------------------------------------- // parse the index and default fixed leg day count private static FloatingRateIndex parseIndex(CsvRow row, string leg) { Optional <string> fixedRateOpt = findValue(row, leg, FIXED_RATE_FIELD); Optional <string> indexOpt = findValue(row, leg, INDEX_FIELD); if (fixedRateOpt.Present) { if (indexOpt.Present) { throw new System.ArgumentException("Swap leg must not define both '" + leg + FIXED_RATE_FIELD + "' and '" + leg + INDEX_FIELD + "'"); } return(null); } if (!indexOpt.Present) { throw new System.ArgumentException("Swap leg must define either '" + leg + FIXED_RATE_FIELD + "' or '" + leg + INDEX_FIELD + "'"); } // use FloatingRateName to identify Ibor vs other string indexStr = indexOpt.get(); FloatingRateName frn = FloatingRateName.parse(indexStr); if (frn.Type == FloatingRateType.IBOR) { // re-parse Ibor using tenor, which ensures tenor picked up from indexStr if present Frequency freq = Frequency.parse(getValue(row, leg, FREQUENCY_FIELD)); Tenor iborTenor = freq.Term ? frn.DefaultTenor : Tenor.of(freq.Period); return(FloatingRateIndex.parse(indexStr, iborTenor)); } return(frn.toFloatingRateIndex()); }
//------------------------------------------------------------------------- // rate calculation private static RateCalculation parseRateCalculation(CsvRow row, string leg, FloatingRateIndex index, DayCount defaultFixedLegDayCount, BusinessDayAdjustment bda, Currency currency) { if (index is IborIndex) { return(parseIborRateCalculation(row, leg, (IborIndex)index, bda, currency)); } else if (index is OvernightIndex) { Optional <FloatingRateName> frnOpt = FloatingRateName.extendedEnum().find(getValue(row, leg, INDEX_FIELD)); if (frnOpt.Present) { FloatingRateName frn = frnOpt.get(); if (frn.Type == FloatingRateType.OVERNIGHT_AVERAGED) { return(parseOvernightRateCalculation(row, leg, (OvernightIndex)index, OvernightAccrualMethod.AVERAGED)); } } return(parseOvernightRateCalculation(row, leg, (OvernightIndex)index, OvernightAccrualMethod.COMPOUNDED)); } else if (index is PriceIndex) { return(parseInflationRateCalculation(row, leg, (PriceIndex)index, currency)); } else { return(parseFixedRateCalculation(row, leg, currency, defaultFixedLegDayCount)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "nameType") public void test_name(String name, String indexName, FloatingRateType type) public virtual void test_name(string name, string indexName, FloatingRateType type) { FloatingRateName test = FloatingRateName.of(name); assertEquals(test.Name, name); assertEquals(test.Type, type); assertEquals(test.Currency, test.toFloatingRateIndex().Currency); }
public FloatingRateName normalized() { if (type.Ibor && indexName.EndsWith("-", StringComparison.Ordinal)) { return(FloatingRateName.of(indexName.Substring(0, indexName.Length - 1))); } return(FloatingRateName.of(indexName)); }
//------------------------------------------------------------------------- public virtual void coverage() { coverPrivateConstructor(typeof(FloatingRateNames)); ImmutableBean test = (ImmutableBean)FloatingRateName.of("GBP-LIBOR-BBA"); coverImmutableBean(test); coverBeanEquals(test, (ImmutableBean)FloatingRateName.of("USD-Federal Funds-H.15")); }
public virtual void test_getFloatingRateName() { foreach (IborIndex index in IborIndex.extendedEnum().lookupAll().values()) { string name = index.Name.Substring(0, index.Name.LastIndexOf('-')); assertEquals(index.FloatingRateName, FloatingRateName.of(name)); } }
public virtual void test_tiee() { assertEquals(FloatingRateName.of("MXN-TIIE").DefaultTenor, Tenor.TENOR_13W); assertEquals(FloatingRateName.of("MXN-TIIE").toFloatingRateIndex(), IborIndices.MXN_TIIE_13W); assertEquals(FloatingRateName.of("MXN-TIIE").toFloatingRateIndex(Tenor.TENOR_4W), IborIndices.MXN_TIIE_4W); assertEquals(FloatingRateName.of("MXN-TIIE").toIborIndex(Tenor.TENOR_4W), IborIndices.MXN_TIIE_4W); assertEquals(FloatingRateName.of("MXN-TIIE").toIborIndexFixingOffset(), DaysAdjustment.ofBusinessDays(-1, MXMC)); }
//------------------------------------------------------------------------- public virtual void test_defaultIborIndex() { assertEquals(FloatingRateName.defaultIborIndex(Currency.GBP), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.defaultIborIndex(Currency.EUR), FloatingRateNames.EUR_EURIBOR); assertEquals(FloatingRateName.defaultIborIndex(Currency.USD), FloatingRateNames.USD_LIBOR); assertEquals(FloatingRateName.defaultIborIndex(Currency.AUD), FloatingRateNames.AUD_BBSW); assertEquals(FloatingRateName.defaultIborIndex(Currency.CAD), FloatingRateNames.CAD_CDOR); assertEquals(FloatingRateName.defaultIborIndex(Currency.NZD), FloatingRateNames.NZD_BKBM); }
public virtual void test_parse() { assertEquals(FloatingRateName.parse("GBP-LIBOR"), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.parse("GBP-LIBOR-3M"), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.parse("GBP-SONIA"), FloatingRateNames.GBP_SONIA); assertEquals(FloatingRateName.parse("GB-RPI"), FloatingRateNames.GB_RPI); assertThrowsIllegalArg(() => FloatingRateName.parse(null)); assertThrowsIllegalArg(() => FloatingRateName.parse("NotAnIndex")); }
//------------------------------------------------------------------------- /// <summary> /// Converts an FpML 'FloatingRateIndex.model' to a {@code PriceIndex}. /// </summary> /// <param name="baseEl"> the FpML floating rate model element to parse </param> /// <returns> the index </returns> /// <exception cref="RuntimeException"> if unable to parse </exception> public PriceIndex parsePriceIndex(XmlElement baseEl) { XmlElement indexEl = baseEl.getChild("floatingRateIndex"); validateScheme(indexEl, "floatingRateIndexScheme", "http://www.fpml.org/coding-scheme/inflation-index-description"); FloatingRateName floatingName = FloatingRateName.of(indexEl.Content); return(floatingName.toPriceIndex()); }
//------------------------------------------------------------------------- public virtual void test_normalized() { assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").normalized(), FloatingRateName.of("GBP-LIBOR")); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").normalized(), FloatingRateName.of("GBP-SONIA")); foreach (FloatingRateName name in FloatingRateName.extendedEnum().lookupAll().values()) { assertNotNull(name.normalized()); } }
public virtual void test_tryParse() { assertEquals(FloatingRateName.tryParse("GBP-LIBOR"), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.tryParse("GBP-LIBOR-3M"), FloatingRateNames.GBP_LIBOR); assertEquals(FloatingRateName.tryParse("GBP-SONIA"), FloatingRateNames.GBP_SONIA); assertEquals(FloatingRateName.tryParse("GB-RPI"), FloatingRateNames.GB_RPI); assertEquals(FloatingRateName.tryParse(null), null); assertEquals(FloatingRateName.tryParse("NotAnIndex"), null); }
//------------------------------------------------------------------------- public virtual void test_cibor() { assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").DefaultTenor, Tenor.TENOR_3M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toFloatingRateIndex(), IborIndices.DKK_CIBOR_3M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toFloatingRateIndex(Tenor.TENOR_1M), IborIndices.DKK_CIBOR_1M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toIborIndex(Tenor.TENOR_6M), IborIndices.DKK_CIBOR_6M); assertEquals(FloatingRateName.of("DKK-CIBOR2-DKNA13").toIborIndex(Tenor.TENOR_6M), IborIndices.DKK_CIBOR_6M); assertEquals(FloatingRateName.of("DKK-CIBOR-DKNA13").toIborIndexFixingOffset(), DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(PRECEDING, DKCO))); assertEquals(FloatingRateName.of("DKK-CIBOR2-DKNA13").toIborIndexFixingOffset(), DaysAdjustment.ofBusinessDays(-2, DKCO)); }
public virtual void test_priceIndex() { assertEquals(FloatingRateName.of("UK-HICP").DefaultTenor, Tenor.TENOR_1Y); assertEquals(FloatingRateName.of("UK-HICP").toFloatingRateIndex(), PriceIndices.GB_HICP); assertEquals(FloatingRateName.of("UK-HICP").toFloatingRateIndex(Tenor.TENOR_1M), PriceIndices.GB_HICP); assertEquals(FloatingRateName.of("UK-HICP").toPriceIndex(), PriceIndices.GB_HICP); assertThrows(() => FloatingRateName.of("GBP-LIBOR-BBA").toPriceIndex(), typeof(System.InvalidOperationException)); assertEquals(FloatingRateName.of("UK-HICP").Tenors, ImmutableSet.of()); assertThrows(() => FloatingRateName.of("UK-HICP").toIborIndexFixingOffset(), typeof(System.InvalidOperationException)); }
public virtual void test_overnightIndex() { assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").DefaultTenor, Tenor.TENOR_1D); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toFloatingRateIndex(), OvernightIndices.GBP_SONIA); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toFloatingRateIndex(Tenor.TENOR_1M), OvernightIndices.GBP_SONIA); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toOvernightIndex(), OvernightIndices.GBP_SONIA); assertEquals(FloatingRateNames.USD_FED_FUND.toOvernightIndex(), OvernightIndices.USD_FED_FUND); assertEquals(FloatingRateNames.USD_FED_FUND_AVG.toOvernightIndex(), OvernightIndices.USD_FED_FUND); assertThrows(() => FloatingRateName.of("GBP-LIBOR-BBA").toOvernightIndex(), typeof(System.InvalidOperationException)); assertEquals(FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").Tenors, ImmutableSet.of()); assertThrows(() => FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toIborIndexFixingOffset(), typeof(System.InvalidOperationException)); }
public virtual void test_gbpHicp() { PriceIndex test = PriceIndex.of("GB-HICP"); assertEquals(test.Name, "GB-HICP"); assertEquals(test.Currency, GBP); assertEquals(test.Region, GB); assertEquals(test.Active, true); assertEquals(test.PublicationFrequency, Frequency.P1M); assertEquals(test.FloatingRateName, FloatingRateName.of("GB-HICP")); assertEquals(test.ToString(), "GB-HICP"); }
//------------------------------------------------------------------------- public virtual void test_iborIndex_tenor() { assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").DefaultTenor, Tenor.TENOR_3M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toFloatingRateIndex(), IborIndices.GBP_LIBOR_3M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toFloatingRateIndex(Tenor.TENOR_1M), IborIndices.GBP_LIBOR_1M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndex(Tenor.TENOR_6M), IborIndices.GBP_LIBOR_6M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndex(Tenor.TENOR_12M), IborIndices.GBP_LIBOR_12M); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndex(Tenor.TENOR_1Y), IborIndices.GBP_LIBOR_12M); assertThrows(() => FloatingRateName.of("GBP-WMBA-SONIA-COMPOUND").toIborIndex(Tenor.TENOR_6M), typeof(System.InvalidOperationException)); assertEquals(ImmutableList.copyOf(FloatingRateName.of("GBP-LIBOR-BBA").Tenors), ImmutableList.of(Tenor.TENOR_1W, Tenor.TENOR_1M, Tenor.TENOR_2M, Tenor.TENOR_3M, Tenor.TENOR_6M, Tenor.TENOR_12M)); assertEquals(FloatingRateName.of("GBP-LIBOR-BBA").toIborIndexFixingOffset(), DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(PRECEDING, GBLO))); }
public virtual void test_gbpSonia() { OvernightIndex test = OvernightIndex.of("GBP-SONIA"); assertEquals(test.Name, "GBP-SONIA"); assertEquals(test.Currency, GBP); assertEquals(test.Active, true); assertEquals(test.FixingCalendar, GBLO); assertEquals(test.PublicationDateOffset, 0); assertEquals(test.EffectiveDateOffset, 0); assertEquals(test.DayCount, ACT_365F); assertEquals(test.DefaultFixedLegDayCount, ACT_365F); assertEquals(test.FloatingRateName, FloatingRateName.of("GBP-SONIA")); assertEquals(test.ToString(), "GBP-SONIA"); }
public virtual void test_chfSaron() { OvernightIndex test = OvernightIndex.of("CHF-SARON"); assertEquals(test.Name, "CHF-SARON"); assertEquals(test.Currency, CHF); assertEquals(test.Active, true); assertEquals(test.FixingCalendar, CHZU); assertEquals(test.PublicationDateOffset, 0); assertEquals(test.EffectiveDateOffset, 0); assertEquals(test.DayCount, ACT_360); assertEquals(test.DefaultFixedLegDayCount, ACT_360); assertEquals(test.FloatingRateName, FloatingRateName.of("CHF-SARON")); assertEquals(test.ToString(), "CHF-SARON"); }
public virtual void test_euribor3m() { IborIndex test = IborIndex.of("EUR-EURIBOR-3M"); assertEquals(test.Currency, EUR); assertEquals(test.Name, "EUR-EURIBOR-3M"); assertEquals(test.Tenor, TENOR_3M); assertEquals(test.FixingCalendar, EUTA); assertEquals(test.FixingDateOffset, DaysAdjustment.ofBusinessDays(-2, EUTA)); assertEquals(test.EffectiveDateOffset, DaysAdjustment.ofBusinessDays(2, EUTA)); assertEquals(test.MaturityDateOffset, TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA))); assertEquals(test.DayCount, ACT_360); assertEquals(test.DefaultFixedLegDayCount, THIRTY_U_360); assertEquals(test.FloatingRateName, FloatingRateName.of("EUR-EURIBOR")); assertEquals(test.ToString(), "EUR-EURIBOR-3M"); }
public virtual void test_tibor_euroyen3m() { IborIndex test = IborIndex.of("JPY-TIBOR-EUROYEN-3M"); assertEquals(test.Currency, JPY); assertEquals(test.Name, "JPY-TIBOR-EUROYEN-3M"); assertEquals(test.Tenor, TENOR_3M); assertEquals(test.FixingCalendar, JPTO); assertEquals(test.FixingDateOffset, DaysAdjustment.ofBusinessDays(-2, JPTO)); assertEquals(test.EffectiveDateOffset, DaysAdjustment.ofBusinessDays(2, JPTO)); assertEquals(test.MaturityDateOffset, TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, JPTO))); assertEquals(test.DayCount, ACT_360); assertEquals(test.DefaultFixedLegDayCount, ACT_365F); assertEquals(test.FloatingRateName, FloatingRateName.of("JPY-TIBOR-EUROYEN")); assertEquals(test.ToString(), "JPY-TIBOR-EUROYEN-3M"); }
//------------------------------------------------------------------------- public virtual void test_usdLibor3m() { IborIndex test = IborIndex.of("USD-LIBOR-3M"); assertEquals(test.Currency, USD); assertEquals(test.Name, "USD-LIBOR-3M"); assertEquals(test.Tenor, TENOR_3M); assertEquals(test.FixingCalendar, GBLO); assertEquals(test.FixingDateOffset, DaysAdjustment.ofBusinessDays(-2, GBLO)); assertEquals(test.EffectiveDateOffset, DaysAdjustment.ofBusinessDays(2, GBLO, BusinessDayAdjustment.of(FOLLOWING, GBLO.combinedWith(USNY)))); assertEquals(test.MaturityDateOffset, TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO.combinedWith(USNY)))); assertEquals(test.DayCount, ACT_360); assertEquals(test.DefaultFixedLegDayCount, ACT_360); assertEquals(test.FloatingRateName, FloatingRateName.of("USD-LIBOR")); assertEquals(test.ToString(), "USD-LIBOR-3M"); }
//------------------------------------------------------------------------- // load currency defaults internal static ImmutableMap <Currency, FloatingRateName> parseOvernightDefaults(IniFile ini, ImmutableMap <string, FloatingRateName> names) { ImmutableMap.Builder <Currency, FloatingRateName> map = ImmutableMap.builder(); PropertySet section = ini.section("currencyDefaultOvernight"); foreach (string key in section.keys()) { FloatingRateName frname = names.get(section.value(key)); if (frname == null) { throw new System.ArgumentException("Invalid default Overnight index for currency " + key); } map.put(Currency.of(key), frname); } return(map.build()); }
private static readonly HolidayCalendarId NZBD = HolidayCalendarId.of("NZBD"); // no constant for this public virtual void test_gbpLibor3m() { IborIndex test = IborIndex.of("GBP-LIBOR-3M"); assertEquals(test.Name, "GBP-LIBOR-3M"); assertEquals(test.Currency, GBP); assertEquals(test.Active, true); assertEquals(test.Tenor, TENOR_3M); assertEquals(test.FixingCalendar, GBLO); assertEquals(test.FixingDateOffset, DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(PRECEDING, GBLO))); assertEquals(test.EffectiveDateOffset, DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(FOLLOWING, GBLO))); assertEquals(test.MaturityDateOffset, TenorAdjustment.ofLastBusinessDay(TENOR_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO))); assertEquals(test.DayCount, ACT_365F); assertEquals(test.DefaultFixedLegDayCount, ACT_365F); assertEquals(test.FloatingRateName, FloatingRateName.of("GBP-LIBOR")); assertEquals(test.ToString(), "GBP-LIBOR-3M"); }
/// <summary> /// Converts an FpML 'FloatingRateIndex' with multiple tenors to an {@code Index}. /// </summary> /// <param name="baseEl"> the FpML floating rate index element to parse </param> /// <returns> the index </returns> /// <exception cref="RuntimeException"> if unable to parse </exception> public IList <Index> parseIndexes(XmlElement baseEl) { XmlElement indexEl = baseEl.getChild("floatingRateIndex"); validateScheme(indexEl, "floatingRateIndexScheme", "http://www.fpml.org/coding-scheme/floating-rate-index"); FloatingRateName floatingName = FloatingRateName.of(indexEl.Content); IList <XmlElement> tenorEls = baseEl.getChildren("indexTenor"); if (tenorEls.Count == 0) { return(ImmutableList.of(floatingName.toOvernightIndex())); } else { //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: return(tenorEls.Select(el => floatingName.toIborIndex(parseIndexTenor(el))).collect(toImmutableList())); } }
//------------------------------------------------------------------------- // parses the currency as a column or from the reference private static Currency parseCurrency(CsvRow row, CurveName reference) { Optional <string> currencyStr = row.findValue(CURRENCY_HEADER); if (currencyStr.Present) { return(LoaderUtils.parseCurrency(currencyStr.get())); } string referenceStr = reference.Name.ToUpper(Locale.ENGLISH); try { Optional <IborIndex> ibor = IborIndex.extendedEnum().find(referenceStr); if (ibor.Present) { return(ibor.get().Currency); } else { Optional <FloatingRateName> frName = FloatingRateName.extendedEnum().find(referenceStr); if (frName.Present) { return(frName.get().Currency); } else if (referenceStr.Length == 3) { return(Currency.of(referenceStr)); } else if (referenceStr.Length > 3 && referenceStr[3] == '-' || referenceStr[3] == '_') { return(LoaderUtils.parseCurrency(referenceStr.Substring(0, 3))); } else { // drop out to exception } } } catch (Exception) { // drop out to exception } throw new System.ArgumentException("Unable to parse currency from reference, consider adding a 'Currency' column"); }
public virtual void test_serialization() { assertSerialization(FloatingRateName.of("GBP-LIBOR-BBA")); }
// Converts an FpML 'FloatingRateCalculation' to a {@code RateCalculation}. private RateCalculation parseFloat(XmlElement legEl, XmlElement calcEl, XmlElement floatingEl, PeriodicSchedule accrualSchedule, FpmlDocument document) { // supported elements: // 'calculationPeriodAmount/calculation/floatingRateCalculation' // 'calculationPeriodAmount/calculation/floatingRateCalculation/floatingRateIndex' // 'calculationPeriodAmount/calculation/floatingRateCalculation/indexTenor?' // 'calculationPeriodAmount/calculation/floatingRateCalculation/floatingRateMultiplierSchedule?' // 'calculationPeriodAmount/calculation/floatingRateCalculation/spreadSchedule*' // 'calculationPeriodAmount/calculation/floatingRateCalculation/initialRate?' (Ibor only) // 'calculationPeriodAmount/calculation/floatingRateCalculation/averagingMethod?' // 'calculationPeriodAmount/calculation/floatingRateCalculation/negativeInterestRateTreatment?' // 'calculationPeriodAmount/calculation/dayCountFraction' // 'resetDates/resetRelativeTo' // 'resetDates/fixingDates' // 'resetDates/rateCutOffDaysOffset' (OIS only) // 'resetDates/resetFrequency' // 'resetDates/resetDatesAdjustments' // 'stubCalculationPeriodAmount/initalStub' (Ibor only, Overnight must match index) // 'stubCalculationPeriodAmount/finalStub' (Ibor only, Overnight must match index) // ignored elements: // 'calculationPeriodAmount/calculation/floatingRateCalculation/finalRateRounding?' // 'calculationPeriodAmount/calculation/discounting?' // 'resetDates/calculationPeriodDatesReference' // rejected elements: // 'calculationPeriodAmount/calculation/floatingRateCalculation/spreadSchedule/type?' // 'calculationPeriodAmount/calculation/floatingRateCalculation/rateTreatment?' // 'calculationPeriodAmount/calculation/floatingRateCalculation/capRateSchedule?' // 'calculationPeriodAmount/calculation/floatingRateCalculation/floorRateSchedule?' // 'resetDates/initialFixingDate' document.validateNotPresent(floatingEl, "rateTreatment"); document.validateNotPresent(floatingEl, "capRateSchedule"); document.validateNotPresent(floatingEl, "floorRateSchedule"); Index index = document.parseIndex(floatingEl); if (index is IborIndex) { IborRateCalculation.Builder iborRateBuilder = IborRateCalculation.builder(); // day count iborRateBuilder.dayCount(document.parseDayCountFraction(calcEl.getChild("dayCountFraction"))); // index iborRateBuilder.index((IborIndex)document.parseIndex(floatingEl)); // gearing floatingEl.findChild("floatingRateMultiplierSchedule").ifPresent(el => { iborRateBuilder.gearing(parseSchedule(el, document)); }); // spread if (floatingEl.getChildren("spreadSchedule").size() > 1) { throw new FpmlParseException("Only one 'spreadSchedule' is supported"); } floatingEl.findChild("spreadSchedule").ifPresent(el => { document.validateNotPresent(el, "type"); iborRateBuilder.spread(parseSchedule(el, document)); }); // initial fixed rate floatingEl.findChild("initialRate").ifPresent(el => { iborRateBuilder.firstRegularRate(document.parseDecimal(el)); }); // negative rates floatingEl.findChild("negativeInterestRateTreatment").ifPresent(el => { iborRateBuilder.negativeRateMethod(parseNegativeInterestRateTreatment(el)); }); // resets legEl.findChild("resetDates").ifPresent(resetDatesEl => { document.validateNotPresent(resetDatesEl, "initialFixingDate"); document.validateNotPresent(resetDatesEl, "rateCutOffDaysOffset"); resetDatesEl.findChild("resetRelativeTo").ifPresent(el => { iborRateBuilder.fixingRelativeTo(parseResetRelativeTo(el)); }); iborRateBuilder.fixingDateOffset(document.parseRelativeDateOffsetDays(resetDatesEl.getChild("fixingDates"))); Frequency resetFreq = document.parseFrequency(resetDatesEl.getChild("resetFrequency")); if (!accrualSchedule.Frequency.Equals(resetFreq)) { ResetSchedule.Builder resetScheduleBuilder = ResetSchedule.builder(); resetScheduleBuilder.resetFrequency(resetFreq); floatingEl.findChild("averagingMethod").ifPresent(el => { resetScheduleBuilder.resetMethod(parseAveragingMethod(el)); }); resetScheduleBuilder.businessDayAdjustment(document.parseBusinessDayAdjustments(resetDatesEl.getChild("resetDatesAdjustments"))); iborRateBuilder.resetPeriods(resetScheduleBuilder.build()); } }); // stubs legEl.findChild("stubCalculationPeriodAmount").ifPresent(stubsEl => { stubsEl.findChild("initialStub").ifPresent(el => { iborRateBuilder.initialStub(parseStubCalculation(el, document)); }); stubsEl.findChild("finalStub").ifPresent(el => { iborRateBuilder.finalStub(parseStubCalculation(el, document)); }); }); return(iborRateBuilder.build()); } else if (index is OvernightIndex) { OvernightRateCalculation.Builder overnightRateBuilder = OvernightRateCalculation.builder(); document.validateNotPresent(floatingEl, "initialRate"); // TODO: should support this in the model // stubs legEl.findChild("stubCalculationPeriodAmount").ifPresent(stubsEl => { stubsEl.findChild("initialStub").ifPresent(el => { checkStubForOvernightIndex(el, document, (OvernightIndex)index); }); stubsEl.findChild("finalStub").ifPresent(el => { checkStubForOvernightIndex(el, document, (OvernightIndex)index); }); }); // day count overnightRateBuilder.dayCount(document.parseDayCountFraction(calcEl.getChild("dayCountFraction"))); // index overnightRateBuilder.index((OvernightIndex)document.parseIndex(floatingEl)); // accrual method FloatingRateName idx = FloatingRateName.of(floatingEl.getChild("floatingRateIndex").Content); if (idx.Type == FloatingRateType.OVERNIGHT_COMPOUNDED) { overnightRateBuilder.accrualMethod(OvernightAccrualMethod.COMPOUNDED); } // gearing floatingEl.findChild("floatingRateMultiplierSchedule").ifPresent(el => { overnightRateBuilder.gearing(parseSchedule(el, document)); }); // spread if (floatingEl.getChildren("spreadSchedule").size() > 1) { throw new FpmlParseException("Only one 'spreadSchedule' is supported"); } floatingEl.findChild("spreadSchedule").ifPresent(el => { document.validateNotPresent(el, "type"); overnightRateBuilder.spread(parseSchedule(el, document)); }); // negative rates floatingEl.findChild("negativeInterestRateTreatment").ifPresent(el => { overnightRateBuilder.negativeRateMethod(parseNegativeInterestRateTreatment(el)); }); // rate cut off legEl.findChild("resetDates").ifPresent(resetDatesEl => { document.validateNotPresent(resetDatesEl, "initialFixingDate"); resetDatesEl.findChild("rateCutOffDaysOffset").ifPresent(el => { Period cutOff = document.parsePeriod(el); if (cutOff.toTotalMonths() != 0) { throw new FpmlParseException("Invalid 'rateCutOffDaysOffset' value, expected days-based period: " + cutOff); } overnightRateBuilder.rateCutOffDays(-cutOff.Days); }); }); return(overnightRateBuilder.build()); } else { throw new FpmlParseException("Invalid 'floatingRateIndex' type, not Ibor or Overnight"); } }