public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 100346066:         // index
                    this.index = (FxIndex)newValue;
                    break;

                case -1002932800:         // fxForwardRates
                    this.fxForwardRates = (FxForwardRates)newValue;
                    break;

                case -843784602:         // fixings
                    this.fixings = (LocalDateDoubleTimeSeries)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void test_ecb_eur_gbp_dates()
        {
            FxIndex test = FxIndices.EUR_GBP_ECB;

            assertEquals(test.FixingDateOffset, DaysAdjustment.ofBusinessDays(-2, EUTA.combinedWith(GBLO)));
            assertEquals(test.MaturityDateOffset, DaysAdjustment.ofBusinessDays(2, EUTA.combinedWith(GBLO)));
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 13), REF_DATA), date(2014, 10, 15));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 15), REF_DATA), date(2014, 10, 13));
            // weekend
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 16), REF_DATA), date(2014, 10, 20));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 20), REF_DATA), date(2014, 10, 16));
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 17), REF_DATA), date(2014, 10, 21));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 21), REF_DATA), date(2014, 10, 17));
            // input date is Sunday
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 19), REF_DATA), date(2014, 10, 22));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 19), REF_DATA), date(2014, 10, 16));
            // skip maturity over EUR (1st May) and GBP (5th May) holiday
            assertEquals(test.calculateMaturityFromFixing(date(2014, 4, 30), REF_DATA), date(2014, 5, 6));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 5, 6), REF_DATA), date(2014, 4, 30));
            // resolve
            assertEquals(test.resolve(REF_DATA).apply(date(2014, 5, 6)), FxIndexObservation.of(test, date(2014, 5, 6), REF_DATA));
        }
        //-------------------------------------------------------------------------
        // 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());
        }
 /// <summary>
 /// Obtains an instance based on discount factors and historic fixings.
 /// <para>
 /// The instance is based on the discount factors for each currency.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="fxForwardRates">  the underlying forward FX rates </param>
 /// <param name="fixings">  the time-series of fixings </param>
 /// <returns> the rates instance </returns>
 public static ForwardFxIndexRates of(FxIndex index, FxForwardRates fxForwardRates, LocalDateDoubleTimeSeries fixings)
 {
     return(new ForwardFxIndexRates(index, fxForwardRates, fixings));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance based on discount factors with no historic fixings.
 /// <para>
 /// The instance is based on the discount factors for each currency.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index </param>
 /// <param name="fxForwardRates">  the underlying forward FX rates </param>
 /// <returns> the rates instance </returns>
 public static ForwardFxIndexRates of(FxIndex index, FxForwardRates fxForwardRates)
 {
     return(of(index, fxForwardRates, LocalDateDoubleTimeSeries.empty()));
 }
Exemplo n.º 6
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => FxIndex.of("Rubbish"));
 }
Exemplo n.º 7
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_extendedEnum(FxIndex convention, String name)
        public virtual void test_extendedEnum(FxIndex convention, string name)
        {
            ImmutableMap <string, FxIndex> map = FxIndex.extendedEnum().lookupAll();

            assertEquals(map.get(name), convention);
        }
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the FX index used to obtain the FX reset rate.
 /// <para>
 /// This is the index of FX used to obtain the FX reset rate.
 /// An FX index is a daily rate of exchange between two currencies.
 /// Note that the order of the currencies in the index does not matter, as the
 /// conversion direction is fully defined by the reference and swap leg currencies.
 /// </para>
 /// </summary>
 /// <param name="index">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder index(FxIndex index)
 {
     JodaBeanUtils.notNull(index, "index");
     this.index_Renamed = index;
     return(this);
 }
Exemplo n.º 9
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_toString(FxIndex convention, String name)
        public virtual void test_toString(FxIndex convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
Exemplo n.º 10
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_name(FxIndex convention, String name)
        public virtual void test_name(FxIndex convention, string name)
        {
            assertEquals(convention.Name, name);
        }
Exemplo n.º 11
0
        public virtual void test_inr()
        {
            FxIndex test = FxIndex.of("USD/INR-FBIL-INR01");

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

            assertEquals(test.Name, "USD/CNY-SAEC-CNY01");
        }
Exemplo n.º 13
0
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => FxIndex.of((string)null));
 }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Creates an instance from an index and fixing date.
        /// <para>
        /// The reference data is used to find the maturity date from the fixing date.
        ///
        /// </para>
        /// </summary>
        /// <param name="index">  the index </param>
        /// <param name="fixingDate">  the fixing date </param>
        /// <param name="refData">  the reference data to use when resolving holiday calendars </param>
        /// <returns> the rate observation </returns>
        public static FxIndexObservation of(FxIndex index, LocalDate fixingDate, ReferenceData refData)
        {
            LocalDate maturityDate = index.calculateMaturityFromFixing(fixingDate, refData);

            return(new FxIndexObservation(index, fixingDate, maturityDate));
        }
Exemplo n.º 15
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.º 16
0
 public FxIndexRates fxIndexRates(FxIndex index)
 {
     return(fxIndexRates_Renamed);
 }
Exemplo n.º 17
0
 private FxNdf(CurrencyAmount settlementCurrencyNotional, FxRate agreedFxRate, FxIndex index, LocalDate paymentDate)
 {
     JodaBeanUtils.notNull(settlementCurrencyNotional, "settlementCurrencyNotional");
     JodaBeanUtils.notNull(agreedFxRate, "agreedFxRate");
     JodaBeanUtils.notNull(index, "index");
     JodaBeanUtils.notNull(paymentDate, "paymentDate");
     this.settlementCurrencyNotional = settlementCurrencyNotional;
     this.agreedFxRate = agreedFxRate;
     this.index        = index;
     this.paymentDate  = paymentDate;
     validate();
 }