コード例 #1
0
        //-------------------------------------------------------------------------
        // ibor rate calculation
        private static RateCalculation parseIborRateCalculation(CsvRow row, string leg, IborIndex iborIndex, BusinessDayAdjustment bda, Currency currency)
        {
            IborRateCalculation.Builder builder = IborRateCalculation.builder();
            // basics
            builder.index(iborIndex);
            // reset
            Optional <Frequency>  resetFrequencyOpt = findValue(row, leg, RESET_FREQUENCY_FIELD).map(v => Frequency.parse(v));
            IborRateResetMethod   resetMethod       = findValue(row, leg, RESET_METHOD_FIELD).map(v => IborRateResetMethod.of(v)).orElse(IborRateResetMethod.WEIGHTED);
            BusinessDayAdjustment resetDateAdj      = parseBusinessDayAdjustment(row, leg, RESET_DATE_CNV_FIELD, RESET_DATE_CAL_FIELD).orElse(bda);

            resetFrequencyOpt.ifPresent(freq => builder.resetPeriods(ResetSchedule.builder().resetFrequency(freq).resetMethod(resetMethod).businessDayAdjustment(resetDateAdj).build()));
            // optionals, no ability to set firstFixingDateOffset
            findValue(row, leg, DAY_COUNT_FIELD).map(s => LoaderUtils.parseDayCount(s)).ifPresent(v => builder.dayCount(v));
            findValue(row, leg, FIXING_RELATIVE_TO_FIELD).map(s => FixingRelativeTo.of(s)).ifPresent(v => builder.fixingRelativeTo(v));
            Optional <DaysAdjustment> fixingAdjOpt = parseDaysAdjustment(row, leg, FIXING_OFFSET_DAYS_FIELD, FIXING_OFFSET_CAL_FIELD, FIXING_OFFSET_ADJ_CNV_FIELD, FIXING_OFFSET_ADJ_CAL_FIELD);

            fixingAdjOpt.ifPresent(v => builder.fixingDateOffset(v));
            findValue(row, leg, NEGATIVE_RATE_METHOD_FIELD).map(s => NegativeRateMethod.of(s)).ifPresent(v => builder.negativeRateMethod(v));
            findValue(row, leg, FIRST_RATE_FIELD).map(s => LoaderUtils.parseDoublePercent(s)).ifPresent(v => builder.firstRate(v));
            findValue(row, leg, GEARING_FIELD).map(s => LoaderUtils.parseDouble(s)).ifPresent(v => builder.gearing(ValueSchedule.of(v)));
            findValue(row, leg, SPREAD_FIELD).map(s => LoaderUtils.parseDoublePercent(s)).ifPresent(v => builder.spread(ValueSchedule.of(v)));
            // initial stub
            Optional <IborRateStubCalculation> initialStub = parseIborStub(row, leg, currency, builder, INITIAL_STUB_RATE_FIELD, INITIAL_STUB_AMOUNT_FIELD, INITIAL_STUB_INDEX_FIELD, INITIAL_STUB_INTERPOLATED_INDEX_FIELD);

            initialStub.ifPresent(stub => builder.initialStub(stub));
            // final stub
            Optional <IborRateStubCalculation> finalStub = parseIborStub(row, leg, currency, builder, FINAL_STUB_RATE_FIELD, FINAL_STUB_AMOUNT_FIELD, FINAL_STUB_INDEX_FIELD, FINAL_STUB_INTERPOLATED_INDEX_FIELD);

            finalStub.ifPresent(stub => builder.finalStub(stub));
            return(builder.build());
        }
コード例 #2
0
 //-------------------------------------------------------------------------
 // overnight rate calculation
 private static RateCalculation parseOvernightRateCalculation(CsvRow row, string leg, OvernightIndex overnightIndex, OvernightAccrualMethod accrualMethod)
 {
     OvernightRateCalculation.Builder builder = OvernightRateCalculation.builder();
     // basics
     builder.index(overnightIndex);
     builder.accrualMethod(findValue(row, leg, ACCRUAL_METHOD_FIELD).map(s => OvernightAccrualMethod.of(s)).orElse(accrualMethod));
     // optionals
     findValue(row, leg, DAY_COUNT_FIELD).map(s => LoaderUtils.parseDayCount(s)).ifPresent(v => builder.dayCount(v));
     findValue(row, leg, RATE_CUT_OFF_DAYS_FIELD).map(s => Convert.ToInt32(s)).ifPresent(v => builder.rateCutOffDays(v));
     findValue(row, leg, NEGATIVE_RATE_METHOD_FIELD).map(s => NegativeRateMethod.of(s)).ifPresent(v => builder.negativeRateMethod(v));
     findValue(row, leg, GEARING_FIELD).map(s => LoaderUtils.parseDouble(s)).ifPresent(v => builder.gearing(ValueSchedule.of(v)));
     findValue(row, leg, SPREAD_FIELD).map(s => LoaderUtils.parseDoublePercent(s)).ifPresent(v => builder.spread(ValueSchedule.of(v)));
     return(builder.build());
 }