コード例 #1
0
        //-------------------------------------------------------------------------
        // notional schedule
        private static NotionalSchedule parseNotionalSchedule(CsvRow row, string leg)
        {
            NotionalSchedule.Builder builder = NotionalSchedule.builder();
            // basics
            Currency currency = Currency.of(getValueWithFallback(row, leg, CURRENCY_FIELD));

            builder.currency(currency);
            builder.amount(ValueSchedule.of(LoaderUtils.parseDouble(getValueWithFallback(row, leg, NOTIONAL_FIELD))));
            // fx reset
            Optional <FxIndex>  fxIndexOpt          = findValue(row, leg, FX_RESET_INDEX_FIELD).map(s => FxIndex.of(s));
            Optional <Currency> notionalCurrencyOpt = findValue(row, leg, NOTIONAL_CURRENCY_FIELD).map(s => Currency.of(s));
            Optional <FxResetFixingRelativeTo> fxFixingRelativeToOpt = findValue(row, leg, FX_RESET_RELATIVE_TO_FIELD).map(s => FxResetFixingRelativeTo.of(s));
            Optional <DaysAdjustment>          fxResetAdjOpt         = parseDaysAdjustment(row, leg, FX_RESET_OFFSET_DAYS_FIELD, FX_RESET_OFFSET_CAL_FIELD, FX_RESET_OFFSET_ADJ_CNV_FIELD, FX_RESET_OFFSET_ADJ_CAL_FIELD);

            if (fxIndexOpt.Present)
            {
                FxIndex fxIndex = fxIndexOpt.get();
                FxResetCalculation.Builder fxResetBuilder = FxResetCalculation.builder();
                fxResetBuilder.index(fxIndex);
                fxResetBuilder.referenceCurrency(notionalCurrencyOpt.orElse(fxIndex.CurrencyPair.other(currency)));
                fxFixingRelativeToOpt.ifPresent(v => fxResetBuilder.fixingRelativeTo(v));
                fxResetAdjOpt.ifPresent(v => fxResetBuilder.fixingDateOffset(v));
                builder.fxReset(fxResetBuilder.build());
            }
            else if (notionalCurrencyOpt.Present || fxFixingRelativeToOpt.Present || fxResetAdjOpt.Present)
            {
                throw new System.ArgumentException("Swap trade FX Reset must define field '" + leg + FX_RESET_INDEX_FIELD + "'");
            }
            // optionals
            findValue(row, leg, NOTIONAL_INITIAL_EXCHANGE_FIELD).map(s => LoaderUtils.parseBoolean(s)).ifPresent(v => builder.initialExchange(v));
            findValue(row, leg, NOTIONAL_INTERMEDIATE_EXCHANGE_FIELD).map(s => LoaderUtils.parseBoolean(s)).ifPresent(v => builder.intermediateExchange(v));
            findValue(row, leg, NOTIONAL_FINAL_EXCHANGE_FIELD).map(s => LoaderUtils.parseBoolean(s)).ifPresent(v => builder.finalExchange(v));
            return(builder.build());
        }
コード例 #2
0
        // parses the notional schedule
        private NotionalSchedule parseSwapNotionalSchedule(XmlElement legEl, XmlElement calcEl, FpmlDocument document)
        {
            // supported elements:
            //  'principalExchanges/initialExchange'
            //  'principalExchanges/finalExchange'
            //  'principalExchanges/intermediateExchange'
            //  'calculationPeriodAmount/calculation/notionalSchedule/notionalStepSchedule'
            //  'calculationPeriodAmount/calculation/notionalSchedule/notionalStepParameters'
            NotionalSchedule.Builder notionalScheduleBuilder = NotionalSchedule.builder();
            // exchanges
            legEl.findChild("principalExchanges").ifPresent(el =>
            {
                notionalScheduleBuilder.initialExchange(bool.Parse(el.getChild("initialExchange").Content));
                notionalScheduleBuilder.intermediateExchange(bool.Parse(el.getChild("intermediateExchange").Content));
                notionalScheduleBuilder.finalExchange(bool.Parse(el.getChild("finalExchange").Content));
            });
            // notional schedule
            XmlElement            notionalEl         = calcEl.getChild("notionalSchedule");
            XmlElement            stepScheduleEl     = notionalEl.getChild("notionalStepSchedule");
            Optional <XmlElement> paramScheduleElOpt = notionalEl.findChild("notionalStepParameters");
            double            initialValue           = document.parseDecimal(stepScheduleEl.getChild("initialValue"));
            ValueStepSequence seq = paramScheduleElOpt.map(el => parseAmountSchedule(el, initialValue, document)).orElse(null);

            notionalScheduleBuilder.amount(parseSchedule(stepScheduleEl, initialValue, seq, document));
            notionalScheduleBuilder.currency(document.parseCurrency(stepScheduleEl.getChild("currency")));
            return(notionalScheduleBuilder.build());
        }