public virtual void test_pv01() { FxVanillaOptionTradeCalculationFunction function = new FxVanillaOptionTradeCalculationFunction(); ScenarioMarketData md = marketData(); RatesProvider provider = RATES_LOOKUP.ratesProvider(md.scenario(0)); BlackFxVanillaOptionTradePricer pricer = BlackFxVanillaOptionTradePricer.DEFAULT; PointSensitivities pvPointSens = pricer.presentValueSensitivityRatesStickyStrike(RTRADE, provider, VOLS); CurrencyParameterSensitivities pvParamSens = provider.parameterSensitivity(pvPointSens); MultiCurrencyAmount expectedPv01 = pvParamSens.total().multipliedBy(1e-4); CurrencyParameterSensitivities expectedBucketedPv01 = pvParamSens.multipliedBy(1e-4); ISet <Measure> measures = ImmutableSet.of(Measures.PV01_CALIBRATED_SUM, Measures.PV01_CALIBRATED_BUCKETED); assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PV01_CALIBRATED_SUM, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01)))).containsEntry(Measures.PV01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedBucketedPv01)))); }
public virtual void test_pv01_quote() { BillTradeCalculationFunction <BillTrade> function = BillTradeCalculationFunction.TRADE; ScenarioMarketData md = marketData(); LegalEntityDiscountingProvider provider = LOOKUP.marketDataView(md.scenario(0)).discountingProvider(); DiscountingBillTradePricer pricer = DiscountingBillTradePricer.DEFAULT; PointSensitivities pvPointSens = pricer.presentValueSensitivity(RTRADE, provider); CurrencyParameterSensitivities pvParamSens = provider.parameterSensitivity(pvPointSens); CurrencyParameterSensitivities expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens, provider).multipliedBy(1e-4); MultiCurrencyAmount expectedPv01Cal = expectedPv01CalBucketed.total(); ISet <Measure> measures = ImmutableSet.of(Measures.PV01_MARKET_QUOTE_SUM, Measures.PV01_MARKET_QUOTE_BUCKETED); assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PV01_MARKET_QUOTE_SUM, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)))).containsEntry(Measures.PV01_MARKET_QUOTE_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)))); }
public virtual void test_pv01() { BondFutureOptionTradeCalculationFunction <BondFutureOptionTrade> function = BondFutureOptionTradeCalculationFunction.TRADE; ScenarioMarketData md = marketData(); LegalEntityDiscountingProvider provider = LED_LOOKUP.marketDataView(md.scenario(0)).discountingProvider(); BlackBondFutureOptionMarginedTradePricer pricer = BlackBondFutureOptionMarginedTradePricer.DEFAULT; PointSensitivities pvPointSens = pricer.presentValueSensitivityRates(RTRADE, provider, VOLS); CurrencyParameterSensitivities pvParamSens = provider.parameterSensitivity(pvPointSens); MultiCurrencyAmount expectedPv01Cal = pvParamSens.total().multipliedBy(1e-4); CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4); ISet <Measure> measures = ImmutableSet.of(Measures.PV01_CALIBRATED_SUM, Measures.PV01_CALIBRATED_BUCKETED); assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PV01_CALIBRATED_SUM, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)))).containsEntry(Measures.PV01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)))); }
public virtual void test_pv01() { TermDepositTradeCalculationFunction function = new TermDepositTradeCalculationFunction(); ScenarioMarketData md = marketData(); RatesProvider provider = RATES_LOOKUP.ratesProvider(md.scenario(0)); DiscountingTermDepositProductPricer pricer = DiscountingTermDepositProductPricer.DEFAULT; ResolvedTermDeposit resolved = TRADE.Product.resolve(REF_DATA); PointSensitivities pvPointSens = pricer.presentValueSensitivity(resolved, provider); CurrencyParameterSensitivities pvParamSens = provider.parameterSensitivity(pvPointSens); MultiCurrencyAmount expectedPv01 = pvParamSens.total().multipliedBy(1e-4); CurrencyParameterSensitivities expectedBucketedPv01 = pvParamSens.multipliedBy(1e-4); ISet <Measure> measures = ImmutableSet.of(Measures.PV01_CALIBRATED_SUM, Measures.PV01_CALIBRATED_BUCKETED); assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PV01_CALIBRATED_SUM, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01)))).containsEntry(Measures.PV01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedBucketedPv01)))); }
public virtual void test_curveSensitivityMeasures() { double oneBp = 1e-4; PointSensitivities pvPointSens = PRICER.presentValueSensitivity(RTRADE, RATES_PROVIDER, CreditDataSet.REF_DATA); CurrencyParameterSensitivities pvParamSens = RATES_PROVIDER.parameterSensitivity(pvPointSens); MultiCurrencyAmount expectedPv01Cal = pvParamSens.total().multipliedBy(oneBp); CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(oneBp); CurrencyParameterSensitivity expectedCs01Bucketed = CS01_CALC.bucketedCs01(RTRADE, RATES_PROVIDER, CreditDataSet.REF_DATA); CurrencyAmount expectedCs01Parallel = CS01_CALC.parallelCs01(RTRADE, RATES_PROVIDER, CreditDataSet.REF_DATA); PointSensitivities pvPointSensOnSettle = PRICER.presentValueOnSettleSensitivity(RTRADE, RATES_PROVIDER, CreditDataSet.REF_DATA); CurrencyParameterSensitivity ir01 = RATES_PROVIDER.singleDiscountCurveParameterSensitivity(pvPointSensOnSettle, USD); CurrencyAmount expectedIr01Cal = ir01.total().multipliedBy(oneBp); CurrencyParameterSensitivity expectedIr01CalBucketed = ir01.multipliedBy(oneBp); ISet <Measure> measures = ImmutableSet.of(Measures.PV01_CALIBRATED_SUM, Measures.PV01_CALIBRATED_BUCKETED, CreditMeasures.CS01_PARALLEL, CreditMeasures.CS01_BUCKETED, CreditMeasures.IR01_CALIBRATED_PARALLEL, CreditMeasures.IR01_CALIBRATED_BUCKETED); assertThat(FUNCTION.calculate(TRADE, measures, CreditDataSet.CDS_PARAMS, CreditDataSet.MARKET_DATA, CreditDataSet.REF_DATA)).containsEntry(Measures.PV01_CALIBRATED_SUM, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)))).containsEntry(Measures.PV01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)))).containsEntry(CreditMeasures.CS01_PARALLEL, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedCs01Parallel)))).containsEntry(CreditMeasures.CS01_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedCs01Bucketed)))).containsEntry(CreditMeasures.IR01_CALIBRATED_PARALLEL, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedIr01Cal)))).containsEntry(CreditMeasures.IR01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedIr01CalBucketed)))); }
public virtual void test_pv01_quote() { FixedCouponBondTradeCalculationFunction <FixedCouponBondTrade> function = FixedCouponBondTradeCalculationFunction.TRADE; ScenarioMarketData md = marketData(); LegalEntityDiscountingProvider provider = LOOKUP.marketDataView(md.scenario(0)).discountingProvider(); DiscountingFixedCouponBondTradePricer pricer = DiscountingFixedCouponBondTradePricer.DEFAULT; PointSensitivities pvPointSens = pricer.presentValueSensitivity(RTRADE, provider); CurrencyParameterSensitivities pvParamSens = provider.parameterSensitivity(pvPointSens); CurrencyParameterSensitivities expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens, provider).multipliedBy(1e-4); MultiCurrencyAmount expectedPv01Cal = expectedPv01CalBucketed.total(); ISet <Measure> measures = ImmutableSet.of(Measures.PV01_MARKET_QUOTE_SUM, Measures.PV01_MARKET_QUOTE_BUCKETED); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> computed = function.calculate(TRADE, measures, PARAMS, md, REF_DATA); IDictionary <Measure, Result <object> > computed = function.calculate(TRADE, measures, PARAMS, md, REF_DATA); MultiCurrencyScenarioArray sumComputed = (MultiCurrencyScenarioArray)computed[Measures.PV01_MARKET_QUOTE_SUM].Value; ScenarioArray <CurrencyParameterSensitivities> bucketedComputed = (ScenarioArray <CurrencyParameterSensitivities>)computed[Measures.PV01_MARKET_QUOTE_BUCKETED].Value; assertEquals(sumComputed.ScenarioCount, 1); assertEquals(sumComputed.get(0).Currencies, ImmutableSet.of(GBP)); assertTrue(DoubleMath.fuzzyEquals(sumComputed.get(0).getAmount(GBP).Amount, expectedPv01Cal.getAmount(GBP).Amount, 1.0e-10)); assertEquals(bucketedComputed.ScenarioCount, 1); assertTrue(bucketedComputed.get(0).equalWithTolerance(expectedPv01CalBucketed, 1.0e-10)); }