Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData         md                = SwapTradeCalculationFunctionTest.marketData();
            RatesProvider              provider          = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingSwapTradePricer pricer            = DiscountingSwapTradePricer.DEFAULT;
            MultiCurrencyAmount        expectedPv        = pricer.presentValue(RTRADE, provider);
            ExplainMap          expectedExplainPv        = pricer.explainPresentValue(RTRADE, provider);
            double              expectedParRate          = pricer.parRate(RTRADE, provider);
            double              expectedParSpread        = pricer.parSpread(RTRADE, provider);
            CashFlows           expectedCashFlows        = pricer.cashFlows(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            MultiCurrencyAmount expectedCurrentCash      = pricer.currentCash(RTRADE, provider);

            assertEquals(SwapTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(SwapTradeCalculations.DEFAULT.explainPresentValue(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedExplainPv)));
            assertEquals(SwapTradeCalculations.DEFAULT.parRate(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParRate)));
            assertEquals(SwapTradeCalculations.DEFAULT.parSpread(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)));
            assertEquals(SwapTradeCalculations.DEFAULT.cashFlows(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedCashFlows)));
            assertEquals(SwapTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(SwapTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        // calculates unit price for all scenarios
        internal DoubleScenarioArray unitPrice(ResolvedIborFutureOptionTrade trade, RatesScenarioMarketData ratesMarketData, IborFutureOptionScenarioMarketData optionMarketData)
        {
            IborIndex index = trade.Product.UnderlyingFuture.Index;

            return(DoubleScenarioArray.of(ratesMarketData.ScenarioCount, i => unitPrice(trade, ratesMarketData.scenario(i).ratesProvider(), optionMarketData.scenario(i).volatilities(index))));
        }
Ejemplo n.º 3
0
 //-------------------------------------------------------------------------
 // calculates par spread for all scenarios
 internal DoubleScenarioArray parSpread(ResolvedTermDepositTrade trade, RatesScenarioMarketData marketData)
 {
     return(DoubleScenarioArray.of(marketData.ScenarioCount, i => parSpread(trade, marketData.scenario(i).ratesProvider())));
 }
 //-------------------------------------------------------------------------
 // calculates unit price for all scenarios
 internal DoubleScenarioArray unitPrice(ResolvedOvernightFutureTrade trade, RatesScenarioMarketData marketData)
 {
     return(DoubleScenarioArray.of(marketData.ScenarioCount, i => unitPrice(trade, marketData.scenario(i).ratesProvider())));
 }
Ejemplo n.º 5
0
 //-------------------------------------------------------------------------
 // calculates unit price for all scenarios
 internal DoubleScenarioArray unitPrice(ResolvedBondFutureTrade trade, LegalEntityDiscountingScenarioMarketData marketData)
 {
     return(DoubleScenarioArray.of(marketData.ScenarioCount, i => unitPrice(trade, marketData.scenario(i).discountingProvider())));
 }
Ejemplo n.º 6
0
 //-------------------------------------------------------------------------
 // calculates price for all scenarios
 internal DoubleScenarioArray unitPrice(ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
 {
     return(DoubleScenarioArray.of(marketData.ScenarioCount, i => unitPrice(trade, marketData.scenario(i).creditRatesProvider(), refData)));
 }
Ejemplo n.º 7
0
        //-------------------------------------------------------------------------
        // calculates unit price for all scenarios
        internal DoubleScenarioArray unitPrice(ResolvedBondFutureOptionTrade trade, LegalEntityDiscountingScenarioMarketData legalEntityMarketData, BondFutureOptionScenarioMarketData optionMarketData)
        {
            SecurityId securityId = trade.Product.UnderlyingFuture.SecurityId;

            return(DoubleScenarioArray.of(legalEntityMarketData.ScenarioCount, i => unitPrice(trade, legalEntityMarketData.scenario(i).discountingProvider(), optionMarketData.scenario(i).volatilities(securityId))));
        }
        //-------------------------------------------------------------------------
        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)));
        }