//------------------------------------------------------------------------- public virtual void test_multipliedBy_currency() { CurrencyParameterSensitivities multiplied = SENSI_2.multipliedBy(USD, FACTOR1); assertEquals(multiplied.size(), 2); DoubleArray test1 = multiplied.getSensitivity(NAME1, USD).Sensitivity; for (int i = 0; i < VECTOR1.size(); i++) { assertEquals(test1.get(i), VECTOR2.get(i) * FACTOR1); } DoubleArray test2 = multiplied.getSensitivity(NAME2, USD).Sensitivity; for (int i = 0; i < VECTOR1.size(); i++) { assertEquals(test2.get(i), VECTOR3.get(i) * FACTOR1); } }
//------------------------------------------------------------------------- public virtual void coverage() { coverImmutableBean(CurrencyParameterSensitivities.empty()); coverImmutableBean(SENSI_1); coverBeanEquals(SENSI_1, SENSI_2); }
//------------------------------------------------------------------------- public virtual void test_equalWithTolerance() { CurrencyParameterSensitivities sensUsdTotal = CurrencyParameterSensitivities.of(ENTRY_USD_TOTAL); CurrencyParameterSensitivities sensEur = CurrencyParameterSensitivities.of(ENTRY_EUR); CurrencyParameterSensitivities sens1plus2 = SENSI_1.combinedWith(ENTRY_USD2); CurrencyParameterSensitivities sensZeroA = CurrencyParameterSensitivities.of(ENTRY_ZERO3); CurrencyParameterSensitivities sensZeroB = CurrencyParameterSensitivities.of(ENTRY_ZERO0); CurrencyParameterSensitivities sens1plus2plus0a = SENSI_1.combinedWith(ENTRY_USD2).combinedWith(ENTRY_ZERO0); CurrencyParameterSensitivities sens1plus2plus0b = SENSI_1.combinedWith(ENTRY_USD2).combinedWith(ENTRY_ZERO3); CurrencyParameterSensitivities sens1plus2plus0 = SENSI_1.combinedWith(ENTRY_USD2).combinedWith(ENTRY_ZERO0).combinedWith(ENTRY_ZERO3); CurrencyParameterSensitivities sens2plus0 = SENSI_2.combinedWith(sensZeroA); assertEquals(SENSI_1.equalWithTolerance(sensZeroA, TOLERENCE_CMP), false); assertEquals(SENSI_1.equalWithTolerance(SENSI_1, TOLERENCE_CMP), true); assertEquals(SENSI_1.equalWithTolerance(SENSI_2, TOLERENCE_CMP), false); assertEquals(SENSI_1.equalWithTolerance(sensUsdTotal, TOLERENCE_CMP), false); assertEquals(SENSI_1.equalWithTolerance(sensEur, TOLERENCE_CMP), false); assertEquals(SENSI_1.equalWithTolerance(sens1plus2, TOLERENCE_CMP), false); assertEquals(SENSI_1.equalWithTolerance(sens2plus0, TOLERENCE_CMP), false); assertEquals(SENSI_2.equalWithTolerance(sensZeroA, TOLERENCE_CMP), false); assertEquals(SENSI_2.equalWithTolerance(SENSI_1, TOLERENCE_CMP), false); assertEquals(SENSI_2.equalWithTolerance(SENSI_2, TOLERENCE_CMP), true); assertEquals(SENSI_2.equalWithTolerance(sensUsdTotal, TOLERENCE_CMP), false); assertEquals(SENSI_2.equalWithTolerance(sensEur, TOLERENCE_CMP), false); assertEquals(SENSI_2.equalWithTolerance(sens1plus2, TOLERENCE_CMP), false); assertEquals(SENSI_2.equalWithTolerance(sens2plus0, TOLERENCE_CMP), true); assertEquals(sensZeroA.equalWithTolerance(sensZeroA, TOLERENCE_CMP), true); assertEquals(sensZeroA.equalWithTolerance(SENSI_1, TOLERENCE_CMP), false); assertEquals(sensZeroA.equalWithTolerance(SENSI_2, TOLERENCE_CMP), false); assertEquals(sensZeroA.equalWithTolerance(sensUsdTotal, TOLERENCE_CMP), false); assertEquals(sensZeroA.equalWithTolerance(sensEur, TOLERENCE_CMP), false); assertEquals(sensZeroA.equalWithTolerance(sens1plus2, TOLERENCE_CMP), false); assertEquals(sensZeroA.equalWithTolerance(sens2plus0, TOLERENCE_CMP), false); assertEquals(sensZeroA.equalWithTolerance(sensZeroB, TOLERENCE_CMP), true); assertEquals(sensZeroB.equalWithTolerance(sensZeroB, TOLERENCE_CMP), true); assertEquals(sensZeroB.equalWithTolerance(SENSI_1, TOLERENCE_CMP), false); assertEquals(sensZeroB.equalWithTolerance(SENSI_2, TOLERENCE_CMP), false); assertEquals(sensZeroB.equalWithTolerance(sensUsdTotal, TOLERENCE_CMP), false); assertEquals(sensZeroB.equalWithTolerance(sensEur, TOLERENCE_CMP), false); assertEquals(sensZeroB.equalWithTolerance(sens1plus2, TOLERENCE_CMP), false); assertEquals(sensZeroB.equalWithTolerance(sens2plus0, TOLERENCE_CMP), false); assertEquals(sensZeroB.equalWithTolerance(sensZeroA, TOLERENCE_CMP), true); assertEquals(sens1plus2.equalWithTolerance(sens1plus2, TOLERENCE_CMP), true); assertEquals(sens1plus2.equalWithTolerance(sens1plus2plus0a, TOLERENCE_CMP), true); assertEquals(sens1plus2.equalWithTolerance(sens1plus2plus0b, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0a.equalWithTolerance(sens1plus2, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0a.equalWithTolerance(sens1plus2plus0, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0a.equalWithTolerance(sens1plus2plus0a, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0a.equalWithTolerance(sens1plus2plus0b, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0b.equalWithTolerance(sens1plus2, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0b.equalWithTolerance(sens1plus2plus0, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0b.equalWithTolerance(sens1plus2plus0a, TOLERENCE_CMP), true); assertEquals(sens1plus2plus0b.equalWithTolerance(sens1plus2plus0b, TOLERENCE_CMP), true); assertEquals(sens2plus0.equalWithTolerance(sens2plus0, TOLERENCE_CMP), true); assertEquals(sensZeroA.equalWithTolerance(CurrencyParameterSensitivities.empty(), TOLERENCE_CMP), true); assertEquals(CurrencyParameterSensitivities.empty().equalWithTolerance(sensZeroA, TOLERENCE_CMP), true); }
public virtual void test_split_noSplit() { CurrencyParameterSensitivities test = SENSI_1.split(); assertEquals(test, SENSI_1); }
//------------------------------------------------------------------------- public virtual void test_split() { CurrencyParameterSensitivities test = CurrencyParameterSensitivities.of(ENTRY_COMBINED).split(); assertEquals(test, CurrencyParameterSensitivities.of(ENTRY_USD, ENTRY_EUR_IN_USD)); }
public virtual void test_convertedTo_multipleCurrency_mergeWhenSameName() { CurrencyParameterSensitivities test = SENSI_1.combinedWith(ENTRY_USD2_IN_EUR).convertedTo(USD, FX_RATE); assertEquals(test.Sensitivities, ImmutableList.of(ENTRY_USD_TOTAL)); }
public virtual void test_convertedTo_multipleCurrency() { CurrencyParameterSensitivities test = SENSI_2.convertedTo(USD, FX_RATE); assertEquals(test.Sensitivities, ImmutableList.of(ENTRY_USD2, ENTRY_EUR_IN_USD)); }
public virtual void test_of_array_none() { CurrencyParameterSensitivities test = CurrencyParameterSensitivities.of(); assertEquals(test.size(), 0); }
public virtual void test_combinedWith_empty() { CurrencyParameterSensitivities test = CurrencyParameterSensitivities.empty().combinedWith(SENSI_1); assertEquals(test, SENSI_1); }
public virtual void test_combinedWith_other() { CurrencyParameterSensitivities test = SENSI_1.combinedWith(SENSI_2); assertEquals(test.Sensitivities, ImmutableList.of(ENTRY_USD_TOTAL, ENTRY_EUR)); }
public virtual void test_combinedWith_one_normalized() { CurrencyParameterSensitivities test = SENSI_1.combinedWith(ENTRY_USD2); assertEquals(test.Sensitivities, ImmutableList.of(ENTRY_USD_TOTAL)); }
public virtual void test_builder_emptyMetadata() { assertThrows(typeof(System.ArgumentException), () => CurrencyParameterSensitivities.builder().add(ENTRY_USD)); }
//------------------------------------------------------------------------- public virtual void test_builder() { CurrencyParameterSensitivity entry1 = CurrencyParameterSensitivity.of(NAME1, METADATA1B, USD, VECTOR_USD1); CurrencyParameterSensitivity entry2 = CurrencyParameterSensitivity.of(NAME1, METADATA1B.subList(0, 2), USD, VECTOR_USD1.subArray(0, 2)); CurrencyParameterSensitivities test = CurrencyParameterSensitivities.builder().add(entry1).add(CurrencyParameterSensitivities.of(entry1)).add(entry2).build(); assertEquals(test.Sensitivities.size(), 1); assertEquals(test.Sensitivities.get(0).ParameterMetadata, METADATA1B); assertEquals(test.Sensitivities.get(0).Sensitivity, DoubleArray.of(300, 600, 600, 246)); }
public virtual void test_of_list_normalizeNotPossible() { ImmutableList <CurrencyParameterSensitivity> list = ImmutableList.of(ENTRY_USD, ENTRY_USD_SMALL); assertThrowsIllegalArg(() => CurrencyParameterSensitivities.of(list)); }
//------------------------------------------------------------------------- /// <summary> /// Builds the sensitivity from the provided data. /// <para> /// If all the values added are tenor-based, or all are date-based, then the resulting /// sensitivity will have the tenors sorted. /// /// </para> /// </summary> /// <returns> the sensitivities instance </returns> public CurrencyParameterSensitivities build() { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: return(CurrencyParameterSensitivities.of(data.Values.Select(CurrencyParameterSensitivityBuilder::build).OrderBy(CurrencyParameterSensitivity::compareKey).collect(toImmutableList()))); }
//------------------------------------------------------------------------- /// <summary> /// Adds sensitivities to the builder. /// <para> /// Values with the same market data name and currency will be merged. /// /// </para> /// </summary> /// <param name="sensitivities"> the sensitivities to add </param> /// <returns> this, for chaining </returns> public CurrencyParameterSensitivitiesBuilder add(CurrencyParameterSensitivities sensitivities) { return(add(sensitivities.Sensitivities)); }
//------------------------------------------------------------------------- public virtual void test_convertedTo_singleCurrency() { CurrencyParameterSensitivities test = SENSI_1.convertedTo(USD, FxMatrix.empty()); assertEquals(test.Sensitivities, ImmutableList.of(ENTRY_USD)); }