/** * Converts an FpML 'BusinessCenter' to a {@code HolidayCalendar}. * * @param baseEl the FpML calendar element to parse * @return the calendar * @throws RuntimeException if unable to parse */ public HolidayCalendarId parseBusinessCenter(XmlElement baseEl) { validateScheme(baseEl, "businessCenterScheme", "http://www.fpml.org/coding-scheme/business-center"); return convertHolidayCalendar(baseEl.getContent()); }
/** * Converts an FpML 'DayCountFraction' to a {@code DayCount}. * * @param baseEl the FpML day count element to parse * @return the day count * @throws RuntimeException if unable to parse */ public DayCount parseDayCountFraction(XmlElement baseEl) { validateScheme( baseEl, "dayCountFractionScheme", "http://www.fpml.org/coding-scheme/day-count-fraction", // standard form "http://www.fpml.org/spec/2004/day-count-fraction"); // seen in the wild return convertDayCount(baseEl.getContent()); }
/** * Converts an FpML 'Currency' to a {@code Currency}. * * @param baseEl the FpML currency element to parse * @return the currency * @throws RuntimeException if unable to parse */ public Currency parseCurrency(XmlElement baseEl) { // allow various schemes // http://www.fpml.org/docs/FpML-AWG-Expanding-the-Currency-Codes-v2016.pdf validateScheme( baseEl, "currencyScheme", "http://www.fpml.org/coding-scheme/external/iso4217", // standard form "http://www.fpml.org/ext/iso4217", // seen in the wild "http://www.fpml.org/coding-scheme/currency", // newer, see link above "http://www.fpml.org/codingscheme/non-iso-currency"); // newer, see link above return Currency.of(baseEl.getContent()); }
/** * Converts an FpML 'FloatingRateIndex' with multiple tenors to an {@code Index}. * * @param baseEl the FpML floating rate index element to parse * @return the index * @throws RuntimeException if unable to parse */ public List<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.getContent()); List<XmlElement> tenorEls = baseEl.getChildren("indexTenor"); if (tenorEls.isEmpty()) { return ImmutableList.of(floatingName.toOvernightIndex()); } else { return tenorEls.stream() .map(el -> floatingName.toIborIndex(parseIndexTenor(el))) .collect(toImmutableList()); } }
/** * Converts an FpML 'FloatingRateIndex.model' to a {@code PriceIndex}. * * @param baseEl the FpML floating rate model element to parse * @return the index * @throws RuntimeException if unable to parse */ 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.getContent()); return floatingName.toPriceIndex(); }