/** * Converts an FpML 'RelativeDateOffset' to a {@code DaysAdjustment}. * * @param baseEl the FpML adjustable date element * @return the days adjustment * @throws RuntimeException if unable to parse */ public DaysAdjustment parseRelativeDateOffsetDays(XmlElement baseEl) { // FpML content: ('periodMultiplier', 'period', 'dayType?', // 'businessDayConvention', 'BusinessCentersOrReference.model?' // 'dateRelativeTo', 'adjustedDate') // The 'dateRelativeTo' element is not used here // The 'adjustedDate' element is ignored Period period = parsePeriod(baseEl); if (period.toTotalMonths() != 0) { throw new FpmlParseException("Expected days-based period but found " + period); } Optional<XmlElement> dayTypeEl = baseEl.findChild("dayType"); boolean calendarDays = period.isZero() || (dayTypeEl.isPresent() && dayTypeEl.get().getContent().equals("Calendar")); BusinessDayConvention fixingBdc = convertBusinessDayConvention( baseEl.getChild("businessDayConvention").getContent()); HolidayCalendarId calendar = parseBusinessCenters(baseEl); if (calendarDays) { return DaysAdjustment.ofCalendarDays( period.getDays(), BusinessDayAdjustment.of(fixingBdc, calendar)); } else { return DaysAdjustment.ofBusinessDays(period.getDays(), calendar); } }
paymentDatesEl.getChild("paymentDatesAdjustments")); if (paymentOffsetEl.isPresent()) { Period period = document.parsePeriod(paymentOffsetEl.get()); if (period.toTotalMonths() != 0) { throw new FpmlParseException("Invalid 'paymentDatesAdjustments' value, expected days-based period: " + period);
"Unable to resolve 'dateRelativeTo' to a date: " + baseEl.getChild("dateRelativeTo").getAttribute(HREF)); Period period = parsePeriod(baseEl); Optional<XmlElement> dayTypeEl = baseEl.findChild("dayType"); boolean calendarDays = period.isZero() || (dayTypeEl.isPresent() && dayTypeEl.get().getContent().equals("Calendar"));
builder.lag(document.parsePeriod(inflationEl.getChild("inflationLag")));
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);