//-------------------------------------------------------------------------
        // 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());
        }
Exemplo n.º 2
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => FxIndex.of("Rubbish"));
 }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(FxIndex convention, String name)
        public virtual void test_of_lookup(FxIndex convention, string name)
        {
            assertEquals(FxIndex.of(name), convention);
        }
Exemplo n.º 4
0
        public virtual void test_inr()
        {
            FxIndex test = FxIndex.of("USD/INR-FBIL-INR01");

            assertEquals(test.Name, "USD/INR-FBIL-INR01");
        }
Exemplo n.º 5
0
        public virtual void test_cny()
        {
            FxIndex test = FxIndex.of("USD/CNY-SAEC-CNY01");

            assertEquals(test.Name, "USD/CNY-SAEC-CNY01");
        }
Exemplo n.º 6
0
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => FxIndex.of((string)null));
 }