//-------------------------------------------------------------------------
 // inflation rate calculation
 private static RateCalculation parseInflationRateCalculation(CsvRow row, string leg, PriceIndex priceIndex, Currency currency)
 {
     InflationRateCalculation.Builder builder = InflationRateCalculation.builder();
     // basics
     builder.index(priceIndex);
     builder.lag(parseInflationLag(findValue(row, leg, INFLATION_LAG_FIELD), currency));
     builder.indexCalculationMethod(parseInflationMethod(findValue(row, leg, INFLATION_METHOD_FIELD), currency));
     // optionals
     findValue(row, leg, INFLATION_FIRST_INDEX_VALUE_FIELD).map(s => LoaderUtils.parseDouble(s)).ifPresent(v => builder.firstIndexValue(v));
     findValue(row, leg, GEARING_FIELD).map(s => LoaderUtils.parseDouble(s)).ifPresent(v => builder.gearing(ValueSchedule.of(v)));
     return(builder.build());
 }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates a leg based on this convention.
 /// <para>
 /// This returns a leg based on the specified date.
 /// The notional is unsigned, with pay/receive determining the direction of the leg.
 /// If the leg is 'Pay', the fixed rate is paid to the counterparty.
 /// If the leg is 'Receive', the fixed rate is received from the counterparty.
 ///
 /// </para>
 /// </summary>
 /// <param name="startDate">  the start date </param>
 /// <param name="endDate">  the end date </param>
 /// <param name="payReceive">  determines if the leg is to be paid or received </param>
 /// <param name="notional">  the business day adjustment to apply to accrual schedule dates </param>
 /// <returns> the leg </returns>
 public RateCalculationSwapLeg toLeg(LocalDate startDate, LocalDate endDate, PayReceive payReceive, double notional)
 {
     return(RateCalculationSwapLeg.builder().payReceive(payReceive).accrualSchedule(PeriodicSchedule.builder().startDate(startDate).endDate(endDate).frequency(Frequency.TERM).businessDayAdjustment(accrualBusinessDayAdjustment).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(Frequency.TERM).paymentDateOffset(paymentDateOffset).build()).calculation(InflationRateCalculation.builder().index(index).indexCalculationMethod(indexCalculationMethod).lag(lag).build()).notionalSchedule(NotionalSchedule.of(Currency, notional)).build());
 }
 internal static CapitalIndexedBond sut2()
 {
     return(CapitalIndexedBond.builder().securityId(SECURITY_ID2).notional(5.0e7).currency(GBP).dayCount(NL_365).rateCalculation(InflationRateCalculation.builder().index(GB_RPI).lag(Period.ofMonths(2)).indexCalculationMethod(INTERPOLATED).firstIndexValue(124.556).build()).exCouponPeriod(EX_COUPON).legalEntityId(LegalEntityId.of("OG-Ticker", "US-Govt-1")).yieldConvention(GB_IL_FLOAT).settlementDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).accrualSchedule(PeriodicSchedule.of(START, END, FREQUENCY, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, GBLO), StubConvention.NONE, RollConventions.NONE)).build());
 }