//-------------------------------------------------------------------------
        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)));
        }
예제 #2
0
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test_presentValue()
        public virtual void test_presentValue()
        {
            ScenarioMarketData        md         = DsfTradeCalculationFunctionTest.marketData();
            RatesProvider             provider   = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingDsfTradePricer pricer     = DiscountingDsfTradePricer.DEFAULT;
            CurrencyAmount            expectedPv = pricer.presentValue(RTRADE, provider, REF_PRICE);
            MultiCurrencyAmount       expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider, REF_PRICE);

            assertEquals(DsfTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(DsfTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
        }
예제 #3
0
        public virtual void test_pv01()
        {
            ScenarioMarketData             md                      = SwapTradeCalculationFunctionTest.marketData();
            RatesProvider                  provider                = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingSwapTradePricer     pricer                  = DiscountingSwapTradePricer.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(SwapTradeCalculations.DEFAULT.pv01CalibratedSum(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(SwapTradeCalculations.DEFAULT.pv01CalibratedBucketed(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
예제 #4
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData md       = FxSingleBarrierOptionTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            BlackFxSingleBarrierOptionTradePricer pricer = BlackFxSingleBarrierOptionTradePricer.DEFAULT;
            MultiCurrencyAmount expectedPv = pricer.presentValue(RTRADE, provider, VOLS);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider, VOLS);
            CurrencyAmount      expectedCurrentCash      = pricer.currentCash(RTRADE, provider.ValuationDate);

            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
예제 #5
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData md       = IborCapFloorTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            VolatilityIborCapFloorTradePricer pricer     = VolatilityIborCapFloorTradePricer.DEFAULT;
            MultiCurrencyAmount expectedPv               = pricer.presentValue(RTRADE, provider, VOLS);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider, VOLS);
            MultiCurrencyAmount expectedCurrentCash      = pricer.currentCash(RTRADE, provider, VOLS);

            assertEquals(IborCapFloorTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(IborCapFloorTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(IborCapFloorTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
예제 #6
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData                    md       = FixedCouponBondTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider        provider = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingFixedCouponBondTradePricer pricer   = DiscountingFixedCouponBondTradePricer.DEFAULT;
            CurrencyAmount      expectedPv = pricer.presentValue(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            CurrencyAmount      expectedCurrentCash      = pricer.currentCash(RTRADE, provider.ValuationDate);

            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.presentValue(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.currencyExposure(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.currentCash(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
예제 #7
0
        public virtual void test_pv01()
        {
            ScenarioMarketData md       = FxSingleBarrierOptionTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            BlackFxSingleBarrierOptionTradePricer pricer           = BlackFxSingleBarrierOptionTradePricer.DEFAULT;
            PointSensitivities             pvPointSens             = pricer.presentValueSensitivityRatesStickyStrike(RTRADE, provider, VOLS);
            CurrencyParameterSensitivities pvParamSens             = provider.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount            expectedPv01Cal         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4);

            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.pv01RatesCalibratedSum(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.pv01RatesCalibratedBucketed(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
예제 #8
0
        public virtual void test_pv01_quote()
        {
            ScenarioMarketData             md                      = BillTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            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();

            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, provider), expectedPv01Cal);
            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, provider), expectedPv01CalBucketed);
        }
예제 #9
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData                       md                       = CapitalIndexedBondTradeCalculationFunctionTest.marketData();
            RatesProvider                            ratesProvider            = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            LegalEntityDiscountingProvider           ledProvider              = LED_LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingCapitalIndexedBondTradePricer pricer                   = DiscountingCapitalIndexedBondTradePricer.DEFAULT;
            CurrencyAmount                           expectedPv               = pricer.presentValue(RTRADE, ratesProvider, ledProvider);
            MultiCurrencyAmount                      expectedCurrencyExposure = pricer.currencyExposure(RTRADE, ratesProvider, ledProvider);
            CurrencyAmount                           expectedCurrentCash      = pricer.currentCash(RTRADE, ratesProvider);

            assertEquals(CapitalIndexedBondTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, LED_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(CapitalIndexedBondTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, LED_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(CapitalIndexedBondTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, LED_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
예제 #10
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData             md         = FxSingleTradeCalculationFunctionTest.marketData();
            RatesProvider                  provider   = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingFxSingleTradePricer pricer     = DiscountingFxSingleTradePricer.DEFAULT;
            MultiCurrencyAmount            expectedPv = pricer.presentValue(RTRADE, provider);
            MultiCurrencyAmount            expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            MultiCurrencyAmount            expectedCurrentCash      = pricer.currentCash(RTRADE, provider);
            FxRate expectedForwardFx = pricer.forwardFxRate(RTRADE, provider);

            assertEquals(FxSingleTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(FxSingleTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(FxSingleTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
            assertEquals(FxSingleTradeCalculations.DEFAULT.forwardFxRate(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedForwardFx)));
        }
예제 #11
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData             md            = BillTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider provider      = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            CurrencyAmount      expectedPv               = PRICER.presentValue(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExposure = PRICER.currencyExposure(RTRADE, provider);
            CurrencyAmount      expectedCurrentCash      = PRICER.currentCash(RTRADE, provider.ValuationDate);

            assertEquals(CALC.presentValue(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(CALC.currencyExposure(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(CALC.currentCash(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
            assertEquals(CALC.presentValue(RTRADE, provider), expectedPv);
            assertEquals(CALC.currencyExposure(RTRADE, provider), expectedCurrencyExposure);
            assertEquals(CALC.currentCash(RTRADE, provider), expectedCurrentCash);
        }
예제 #12
0
        public virtual void test_pv01()
        {
            ScenarioMarketData md       = CmsTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            SabrExtrapolationReplicationCmsTradePricer pricer      = new SabrExtrapolationReplicationCmsTradePricer(new SabrExtrapolationReplicationCmsProductPricer(new SabrExtrapolationReplicationCmsLegPricer(SabrExtrapolationReplicationCmsPeriodPricer.of(CMS_MODEL.CutOffStrike, CMS_MODEL.Mu))));
            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);

            CmsTradeCalculations calcs = CmsTradeCalculations.of(CMS_MODEL);

            assertEquals(calcs.pv01RatesCalibratedSum(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(calcs.pv01RatesCalibratedBucketed(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
예제 #13
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData md       = CmsTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            SabrExtrapolationReplicationCmsTradePricer pricer = new SabrExtrapolationReplicationCmsTradePricer(new SabrExtrapolationReplicationCmsProductPricer(new SabrExtrapolationReplicationCmsLegPricer(SabrExtrapolationReplicationCmsPeriodPricer.of(CMS_MODEL.CutOffStrike, CMS_MODEL.Mu))));
            MultiCurrencyAmount expectedPv = pricer.presentValue(RTRADE, provider, VOLS);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider, VOLS);
            MultiCurrencyAmount expectedCurrentCash      = pricer.currentCash(RTRADE, provider, VOLS);

            CmsTradeCalculations calcs = CmsTradeCalculations.of(CMS_MODEL);

            assertEquals(calcs.presentValue(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(calcs.currencyExposure(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(calcs.currentCash(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData       md                  = BulletPaymentTradeCalculationFunctionTest.marketData();
            RatesProvider            provider            = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingPaymentPricer pricer              = DiscountingPaymentPricer.DEFAULT;
            Payment             payment                  = RTRADE.Product.Payment;
            CurrencyAmount      expectedPv               = pricer.presentValue(payment, provider);
            CashFlows           expectedCashFlows        = pricer.cashFlows(payment, provider);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(payment, provider);
            CurrencyAmount      expectedCurrentCash      = pricer.currentCash(payment, provider);

            assertEquals(BulletPaymentTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(BulletPaymentTradeCalculations.DEFAULT.cashFlows(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedCashFlows)));
            assertEquals(BulletPaymentTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(BulletPaymentTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
예제 #15
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData md       = TermDepositTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingTermDepositTradePricer pricer     = DiscountingTermDepositTradePricer.DEFAULT;
            CurrencyAmount      expectedPv               = pricer.presentValue(RTRADE, provider);
            double              expectedParRate          = pricer.parRate(RTRADE, provider);
            double              expectedParSpread        = pricer.parSpread(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            CurrencyAmount      expectedCurrentCash      = pricer.currentCash(RTRADE, provider);

            assertEquals(TermDepositTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(TermDepositTradeCalculations.DEFAULT.parRate(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParRate)));
            assertEquals(TermDepositTradeCalculations.DEFAULT.parSpread(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)));
            assertEquals(TermDepositTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(TermDepositTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
        //-------------------------------------------------------------------------
        public virtual void calculate()
        {
            ImmutableList <CalculationTarget> targets = ImmutableList.of(TARGET);
            Column column1 = Column.of(TestingMeasures.PRESENT_VALUE);
            Column column2 = Column.of(TestingMeasures.BUCKETED_PV01);
            ImmutableList <Column> columns = ImmutableList.of(column1, column2);
            CalculationRules       rules   = CalculationRules.of(CalculationFunctions.empty());
            MarketData             md      = MarketData.empty(date(2016, 6, 30));
            ScenarioMarketData     smd     = ScenarioMarketData.empty();

            // use of try-with-resources checks class is AutoCloseable
            using (CalculationRunner test = CalculationRunner.of(MoreExecutors.newDirectExecutorService()))
            {
                assertThat(test.calculate(rules, targets, columns, md, REF_DATA).get(0, 0).Failure).True;
                assertThat(test.calculateMultiScenario(rules, targets, columns, smd, REF_DATA).get(0, 0).Failure).True;
            }
        }
예제 #17
0
        public virtual void test_multipleCurves()
        {
            Curve              curve1     = ConstantCurve.of(CURVE_NAME1, (double)1);
            Curve              curve2     = ConstantCurve.of(CURVE_NAME2, (double)2);
            CurveId            curveId1   = CurveId.of(GROUP_NAME, CURVE_NAME1);
            CurveId            curveId2   = CurveId.of(GROUP_NAME, CURVE_NAME2);
            RatesCurveGroupId  groupId    = RatesCurveGroupId.of(GROUP_NAME);
            RatesCurveGroup    curveGroup = RatesCurveGroup.of(GROUP_NAME, ImmutableMap.of(Currency.AUD, curve1, Currency.GBP, curve2), ImmutableMap.of());
            ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(groupId, curveGroup).build();
            MarketDataConfig   config     = MarketDataConfig.builder().add(GROUP_NAME, RatesCurveGroupDefinition.builder().name(GROUP_NAME).build()).build();

            CurveMarketDataFunction test    = new CurveMarketDataFunction();
            MarketDataBox <Curve>   result1 = test.build(curveId1, config, marketData, REF_DATA);

            assertEquals(result1, MarketDataBox.ofSingleValue(curve1));
            MarketDataBox <Curve> result2 = test.build(curveId2, config, marketData, REF_DATA);

            assertEquals(result2, MarketDataBox.ofSingleValue(curve2));
        }
예제 #18
0
        public virtual void test_pv01_quote()
        {
            ScenarioMarketData                    md                      = FixedCouponBondTradeCalculationFunctionTest.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();

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

            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));
        }
예제 #19
0
        public virtual void absoluteScenarios()
        {
            CurveName      curveName                  = CurveName.of("curveName");
            CurveGroupName curveGroupName             = CurveGroupName.of("curveGroupName");
            Curve          curve                      = ConstantCurve.of(curveName, 2);
            PerturbationMapping <Curve> mapping       = PerturbationMapping.of(MarketDataFilter.ofName(curveName), CurveParallelShifts.absolute(0.1, 0.2, 0.3));
            CurveId                curveId            = CurveId.of(curveGroupName, curveName);
            ScenarioMarketData     marketData         = ImmutableScenarioMarketData.builder(TestHelper.date(2011, 3, 8)).addValue(curveId, curve).build();
            ScenarioDefinition     scenarioDefinition = ScenarioDefinition.ofMappings(mapping);
            MarketDataFactory      marketDataFactory  = MarketDataFactory.of(mock(typeof(ObservableDataProvider)), mock(typeof(TimeSeriesProvider)));
            MarketDataRequirements requirements       = MarketDataRequirements.builder().addValues(curveId).build();
            ScenarioMarketData     scenarioData       = marketDataFactory.createMultiScenario(requirements, MarketDataConfig.empty(), marketData, REF_DATA, scenarioDefinition);
            MarketDataBox <Curve>  curves             = scenarioData.getValue(curveId);

            assertThat(curves.ScenarioCount).isEqualTo(3);
            checkCurveValues(curves.getValue(0), 2.1);
            checkCurveValues(curves.getValue(1), 2.2);
            checkCurveValues(curves.getValue(2), 2.3);
        }
예제 #20
0
        //-------------------------------------------------------------------------
        public virtual void test_singleCurve()
        {
            Curve              curve      = ConstantCurve.of(CURVE_NAME1, (double)1);
            CurveId            curveId1   = CurveId.of(GROUP_NAME, CURVE_NAME1, OBS_SOURCE);
            CurveId            curveId2   = CurveId.of(GROUP_NAME, CURVE_NAME2, OBS_SOURCE);
            CurveId            curveId3   = CurveId.of(GROUP_NAME2, CURVE_NAME1, OBS_SOURCE);
            RatesCurveGroupId  groupId    = RatesCurveGroupId.of(GROUP_NAME, OBS_SOURCE);
            RatesCurveGroup    curveGroup = RatesCurveGroup.of(GROUP_NAME, ImmutableMap.of(Currency.AUD, curve), ImmutableMap.of());
            ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(groupId, curveGroup).build();
            MarketDataConfig   config     = MarketDataConfig.builder().add(GROUP_NAME, RatesCurveGroupDefinition.builder().name(GROUP_NAME).build()).build();

            CurveMarketDataFunction test = new CurveMarketDataFunction();
            MarketDataRequirements  reqs = test.requirements(curveId1, config);

            assertEquals(reqs.NonObservables, ImmutableSet.of(groupId));
            MarketDataBox <Curve> result = test.build(curveId1, config, marketData, REF_DATA);

            assertEquals(result, MarketDataBox.ofSingleValue(curve));
            assertThrowsIllegalArg(() => test.build(curveId2, config, marketData, REF_DATA));
            assertThrowsIllegalArg(() => test.build(curveId3, config, marketData, REF_DATA));
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates unit price across one or more scenarios.
 /// <para>
 /// This is the price of a single unit of the security.
 /// </para>
 /// <para>
 /// Strata uses <i>decimal prices</i> for DSFs in the trade model, pricers and market data.
 /// The decimal price is based on the decimal multiplier equivalent to the implied percentage.
 /// Thus the market price of 100.182 is represented in Strata by 1.00182.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value, one entry per scenario </returns>
 public virtual DoubleScenarioArray unitPrice(ResolvedDsfTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.unitPrice(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Explains the present value calculation across one or more scenarios.
 /// <para>
 /// This provides a breakdown of how
 /// <seealso cref="#presentValue(ResolvedSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value"/>
 /// was calculated, typically used for debugging and validation.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value explanation, one entry per scenario </returns>
 public virtual ScenarioArray <ExplainMap> explainPresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.explainPresentValue(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value across one or more scenarios.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray presentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.presentValue(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the present value of each leg across one or more scenarios.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value of each leg, one entry per scenario </returns>
 public virtual ScenarioArray <LegAmounts> legPresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.legPresentValue(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates accrued interest across one or more scenarios.
 /// <para>
 /// The accrued interest since the last payment.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the accrued interest, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray accruedInterest(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.accruedInterest(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates cash flows across one or more scenarios.
 /// <para>
 /// The cash flows provide details about the payments of the trade.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the cash flows, one entry per scenario </returns>
 public virtual ScenarioArray <CashFlows> cashFlows(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.cashFlows(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates par spread across one or more scenarios.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the par spread, one entry per scenario </returns>
 public virtual DoubleScenarioArray parSpread(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.parSpread(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value"/>
 /// to a one basis point shift in the market quotes used to calibrate the curves.
 /// The result is provided for each affected curve and currency, bucketed by curve node.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual ScenarioArray <CurrencyParameterSensitivities> pv01MarketQuoteBucketed(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.pv01MarketQuoteBucketed(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value"/>
 /// to a one basis point shift in the market quotes used to calibrate the curves.
 /// The result is the sum of the sensitivities of all affected curves.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the present value sensitivity, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray pv01MarketQuoteSum(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.pv01MarketQuoteSum(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates currency exposure across one or more scenarios.
 /// <para>
 /// The currency risk, expressed as the equivalent amount in each currency.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="lookup">  the lookup used to query the market data </param>
 /// <param name="marketData">  the market data </param>
 /// <returns> the currency exposure, one entry per scenario </returns>
 public virtual MultiCurrencyScenarioArray currencyExposure(ResolvedDsfTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.currencyExposure(trade, lookup.marketDataView(marketData)));
 }