//------------------------------------------------------------------------- public virtual void test_addScenarioValueMap() { FxRateId eurGbpId = FxRateId.of(Currency.EUR, Currency.GBP); FxRateId eurUsdId = FxRateId.of(Currency.EUR, Currency.USD); FxRateScenarioArray eurGbpRates = FxRateScenarioArray.of(Currency.EUR, Currency.GBP, DoubleArray.of(0.79, 0.8, 0.81)); FxRateScenarioArray eurUsdRates = FxRateScenarioArray.of(Currency.EUR, Currency.USD, DoubleArray.of(1.09, 1.1, 1.11)); IDictionary <FxRateId, FxRateScenarioArray> values = ImmutableMap.of(eurGbpId, eurGbpRates, eurUsdId, eurUsdRates); ImmutableScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addScenarioValueMap(values).build(); assertEquals(marketData.ScenarioCount, 3); assertEquals(marketData.Ids, ImmutableSet.of(eurGbpId, eurUsdId)); assertEquals(marketData.getValue(eurGbpId), MarketDataBox.ofScenarioValue(eurGbpRates)); assertEquals(marketData.getValue(eurUsdId), MarketDataBox.ofScenarioValue(eurUsdRates)); }
public virtual void test_addSingleAndBox() { FxRateId eurGbpId = FxRateId.of(Currency.EUR, Currency.GBP); FxRateId eurUsdId = FxRateId.of(Currency.EUR, Currency.USD); FxRate eurGbpRate = FxRate.of(Currency.EUR, Currency.GBP, 0.8); FxRate eurUsdRate1 = FxRate.of(Currency.EUR, Currency.USD, 1.1); FxRate eurUsdRate2 = FxRate.of(Currency.EUR, Currency.USD, 1.2); ImmutableScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(eurGbpId, eurGbpRate).addBox(eurUsdId, MarketDataBox.ofScenarioValues(eurUsdRate1, eurUsdRate2)).build(); assertEquals(marketData.ScenarioCount, 2); assertEquals(marketData.Ids, ImmutableSet.of(eurGbpId, eurUsdId)); assertEquals(marketData.getValue(eurGbpId), MarketDataBox.ofSingleValue(eurGbpRate)); assertEquals(marketData.getValue(eurUsdId), MarketDataBox.ofScenarioValues(eurUsdRate1, eurUsdRate2)); }
//------------------------------------------------------------------------- public virtual void test_addValueMap() { FxRateId eurGbpId = FxRateId.of(Currency.EUR, Currency.GBP); FxRateId eurUsdId = FxRateId.of(Currency.EUR, Currency.USD); FxRate eurGbpRate = FxRate.of(Currency.EUR, Currency.GBP, 0.8); FxRate eurUsdRate = FxRate.of(Currency.EUR, Currency.USD, 1.1); IDictionary <FxRateId, FxRate> values = ImmutableMap.of(eurGbpId, eurGbpRate, eurUsdId, eurUsdRate); ImmutableScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValueMap(values).build(); assertEquals(marketData.ScenarioCount, 1); assertEquals(marketData.Ids, ImmutableSet.of(eurGbpId, eurUsdId)); assertEquals(marketData.getValue(eurGbpId), MarketDataBox.ofSingleValue(eurGbpRate)); assertEquals(marketData.getValue(eurUsdId), MarketDataBox.ofSingleValue(eurUsdRate)); }