示例#1
0
        // Converts an FpML 'InflationRateCalculation' to a {@code RateCalculation}.
        private RateCalculation parseInflation(XmlElement legEl, XmlElement calcEl, XmlElement inflationEl, PeriodicSchedule accrualSchedule, FpmlDocument document)
        {
            // supported elements:
            //  'calculationPeriodAmount/calculation/inflationRateCalculation'
            //  'calculationPeriodAmount/calculation/inflationRateCalculation/floatingRateIndex'
            //  'calculationPeriodAmount/calculation/inflationRateCalculation/indexTenor?'
            //  'calculationPeriodAmount/calculation/inflationRateCalculation/floatingRateMultiplierSchedule?'
            //  'calculationPeriodAmount/calculation/inflationRateCalculation/inflationLag'
            //  'calculationPeriodAmount/calculation/inflationRateCalculation/interpolationMethod'
            //  'calculationPeriodAmount/calculation/inflationRateCalculation/initialIndexLevel?'
            //  'calculationPeriodAmount/calculation/dayCountFraction'
            // ignored elements:
            // 'calculationPeriodAmount/calculation/inflationRateCalculation/indexSource'
            // 'calculationPeriodAmount/calculation/inflationRateCalculation/mainPublication'
            // 'calculationPeriodAmount/calculation/inflationRateCalculation/fallbackBondApplicable'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/initialRate?'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/finalRateRounding?'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/averagingMethod?'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/negativeInterestRateTreatment?'
            //  'resetDates'
            // rejected elements:
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/spreadSchedule*'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/rateTreatment?'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/capRateSchedule?'
            //  'calculationPeriodAmount/calculation/floatingRateCalculation/floorRateSchedule?'
            //  'stubCalculationPeriodAmount'
            document.validateNotPresent(inflationEl, "spreadSchedule");
            document.validateNotPresent(inflationEl, "rateTreatment");
            document.validateNotPresent(inflationEl, "capRateSchedule");
            document.validateNotPresent(inflationEl, "floorRateSchedule");
            document.validateNotPresent(legEl, "stubCalculationPeriodAmount");     // TODO: parse fixed stub rate
            InflationRateCalculation.Builder builder = InflationRateCalculation.builder();
            // index
            builder.index(document.parsePriceIndex(inflationEl));
            // lag
            builder.lag(document.parsePeriod(inflationEl.getChild("inflationLag")));
            // interpolation
            string interpStr = inflationEl.getChild("interpolationMethod").Content;

            builder.indexCalculationMethod(interpStr.ToLower(Locale.ENGLISH).Contains("linear") ? PriceIndexCalculationMethod.INTERPOLATED : PriceIndexCalculationMethod.MONTHLY);
            // initial index
            inflationEl.findChild("initialIndexLevel").ifPresent(el =>
            {
                builder.firstIndexValue(document.parseDecimal(el));
            });
            // gearing
            inflationEl.findChild("floatingRateMultiplierSchedule").ifPresent(el =>
            {
                builder.gearing(parseSchedule(el, document));
            });
            return(builder.build());
        }