//-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData               md       = BondFutureTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider   provider = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingBondFutureTradePricer pricer   = DiscountingBondFutureTradePricer.DEFAULT;
            CurrencyAmount expectedPv        = pricer.presentValue(RTRADE, provider, SETTLE_PRICE);
            double         expectedParSpread = pricer.parSpread(RTRADE, provider, SETTLE_PRICE);

            assertEquals(BondFutureTradeCalculations.DEFAULT.presentValue(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(BondFutureTradeCalculations.DEFAULT.parSpread(RTRADE, LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)));
        }
        public virtual void test_pv01_calibrated()
        {
            ScenarioMarketData               md                      = BondFutureTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider   provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingBondFutureTradePricer pricer                  = DiscountingBondFutureTradePricer.DEFAULT;
            PointSensitivities               pvPointSens             = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities   pvParamSens             = provider.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount              expectedPv01Cal         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities   expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4);

            assertEquals(BondFutureTradeCalculations.DEFAULT.pv01CalibratedSum(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(BondFutureTradeCalculations.DEFAULT.pv01CalibratedBucketed(RTRADE, LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
        public virtual void test_pv01_quote()
        {
            ScenarioMarketData               md                      = BondFutureTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider   provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingBondFutureTradePricer pricer                  = DiscountingBondFutureTradePricer.DEFAULT;
            PointSensitivities               pvPointSens             = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities   pvParamSens             = provider.parameterSensitivity(pvPointSens);
            CurrencyParameterSensitivities   expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens.multipliedBy(1e-4), provider);
            MultiCurrencyAmount              expectedPv01Cal         = expectedPv01CalBucketed.total();

            MultiCurrencyScenarioArray sumComputed = BondFutureTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, LOOKUP, md);
            ScenarioArray <CurrencyParameterSensitivities> bucketedComputed = BondFutureTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, LOOKUP, md);

            assertEquals(sumComputed.ScenarioCount, 1);
            assertEquals(sumComputed.get(0).Currencies, ImmutableSet.of(USD));
            assertTrue(DoubleMath.fuzzyEquals(sumComputed.get(0).getAmount(USD).Amount, expectedPv01Cal.getAmount(USD).Amount, 1.0e-10));
            assertEquals(bucketedComputed.ScenarioCount, 1);
            assertTrue(bucketedComputed.get(0).equalWithTolerance(expectedPv01CalBucketed, 1.0e-10));
        }
Beispiel #4
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="tradePricer">  the pricer for <seealso cref="ResolvedBondFutureTrade"/> </param>
 internal BondFutureMeasureCalculations(DiscountingBondFutureTradePricer tradePricer)
 {
     this.tradePricer = ArgChecker.notNull(tradePricer, "tradePricer");
 }
Beispiel #5
0
 /// <summary>
 /// Creates an instance.
 /// <para>
 /// In most cases, applications should use the <seealso cref="#DEFAULT"/> instance.
 ///
 /// </para>
 /// </summary>
 /// <param name="tradePricer">  the pricer for <seealso cref="ResolvedBondFutureTrade"/> </param>
 public BondFutureTradeCalculations(DiscountingBondFutureTradePricer tradePricer)
 {
     this.calc = new BondFutureMeasureCalculations(tradePricer);
 }