Exemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            BondFutureOptionSecurity test            = sut();
            BondFuture         future                = PRODUCT.UnderlyingFuture;
            BondFutureSecurity futureSec             = BondFutureSecurityTest.sut();
            ImmutableList <FixedCouponBond> basket   = future.DeliveryBasket;
            FixedCouponBondSecurity         bondSec0 = FixedCouponBondSecurityTest.createSecurity(future.DeliveryBasket.get(0));
            FixedCouponBondSecurity         bondSec1 = FixedCouponBondSecurityTest.createSecurity(future.DeliveryBasket.get(1));
            ReferenceData    refData = ImmutableReferenceData.of(ImmutableMap.of(test.UnderlyingFutureId, futureSec, basket.get(0).SecurityId, bondSec0, basket.get(1).SecurityId, bondSec1));
            BondFutureOption product = test.createProduct(refData);

            assertEquals(product.UnderlyingFuture.DeliveryBasket.get(0), future.DeliveryBasket.get(0));
            assertEquals(product.UnderlyingFuture.DeliveryBasket.get(1), future.DeliveryBasket.get(1));
            TradeInfo             tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            BondFutureOptionTrade expectedTrade = BondFutureOptionTrade.builder().info(tradeInfo).product(product).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, refData), expectedTrade);

            PositionInfo             positionInfo      = PositionInfo.empty();
            BondFutureOptionPosition expectedPosition1 = BondFutureOptionPosition.builder().info(positionInfo).product(product).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, refData), expectedPosition1);
            BondFutureOptionPosition expectedPosition2 = BondFutureOptionPosition.builder().info(positionInfo).product(product).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, refData), expectedPosition2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            CapitalIndexedBondSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo tradeInfo = TradeInfo.builder().tradeDate(date(2016, 6, 30)).settlementDate(date(2016, 7, 1)).build();
            CapitalIndexedBondTrade expectedTrade = CapitalIndexedBondTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, ReferenceData.empty()), expectedTrade);
        }
Exemplo n.º 3
0
        public virtual void test_createProduct_wrongType()
        {
            BondFutureSecurity test = sut();
            ImmutableList <FixedCouponBond> basket = PRODUCT.DeliveryBasket;
            SecurityId      secId   = basket.get(0).SecurityId;
            GenericSecurity sec     = GenericSecurity.of(INFO);
            ReferenceData   refData = ImmutableReferenceData.of(secId, sec);

            assertThrows(() => test.createProduct(refData), typeof(System.InvalidCastException));
        }
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            FixedCouponBondSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo            tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            FixedCouponBondTrade expectedTrade = FixedCouponBondTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, ReferenceData.empty()), expectedTrade);
        }
Exemplo n.º 5
0
        public virtual void test_createProduct_wrongType()
        {
            IborFutureOptionSecurity test = sut();
            IborFuture      future        = OPTION.UnderlyingFuture;
            SecurityId      secId         = future.SecurityId;
            GenericSecurity sec           = GenericSecurity.of(INFO);
            ReferenceData   refData       = ImmutableReferenceData.of(secId, sec);

            assertThrows(() => test.createProduct(refData), typeof(System.InvalidCastException));
        }
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            BillSecurity @base           = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            Bill         expectedProduct = Bill.builder().dayCount(DAY_COUNT).securityId(SECURITY_ID).dayCount(DAY_COUNT).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();

            assertEquals(@base.createProduct(ReferenceData.empty()), expectedProduct);
            TradeInfo tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            BillTrade expectedTrade = BillTrade.builder().info(tradeInfo).product(expectedProduct).quantity(100).price(1.235).build();

            assertEquals(@base.createTrade(tradeInfo, 100, 1.235, ReferenceData.empty()), expectedTrade);
        }
        public virtual void test_createPosition()
        {
            FixedCouponBondSecurity test              = sut();
            PositionInfo            positionInfo      = PositionInfo.empty();
            FixedCouponBondPosition expectedPosition1 = FixedCouponBondPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            assertEquals(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            FixedCouponBondPosition expectedPosition2 = FixedCouponBondPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
        public virtual void test_createPosition()
        {
            BillSecurity test              = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            Bill         product           = Bill.builder().dayCount(DAY_COUNT).securityId(SECURITY_ID).dayCount(DAY_COUNT).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            PositionInfo positionInfo      = PositionInfo.empty();
            BillPosition expectedPosition1 = BillPosition.builder().info(positionInfo).product(product).longQuantity(100).build();

            assertEquals(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            BillPosition expectedPosition2 = BillPosition.builder().info(positionInfo).product(product).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
Exemplo n.º 9
0
        public virtual void test()
        {
            EtdOptionSecurity test = sut();

            assertEquals(test.Variant, EtdVariant.MONTHLY);
            assertEquals(test.Type, EtdType.OPTION);
            assertEquals(test.Currency, Currency.GBP);
            assertEquals(test.UnderlyingIds, ImmutableSet.of());
            assertEquals(test.createProduct(REF_DATA), test);
            assertEquals(test.createTrade(TradeInfo.empty(), 1, 2, ReferenceData.empty()), EtdOptionTrade.of(TradeInfo.empty(), test, 1, 2));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, ReferenceData.empty()), EtdOptionPosition.ofNet(PositionInfo.empty(), test, 1));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, 2, ReferenceData.empty()), EtdOptionPosition.ofLongShort(PositionInfo.empty(), test, 1, 2));
        }
Exemplo n.º 10
0
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            GenericSecurity test = sut();

            assertEquals(test.Info, INFO);
            assertEquals(test.SecurityId, INFO.Id);
            assertEquals(test.Currency, INFO.PriceInfo.Currency);
            assertEquals(test.UnderlyingIds, ImmutableSet.of());
            assertEquals(test, GenericSecurity.of(INFO));
            assertEquals(test.createProduct(ReferenceData.empty()), test);
            assertEquals(test.createTrade(TradeInfo.empty(), 1, 2, ReferenceData.empty()), GenericSecurityTrade.of(TradeInfo.empty(), GenericSecurity.of(INFO), 1, 2));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, ReferenceData.empty()), GenericSecurityPosition.ofNet(PositionInfo.empty(), GenericSecurity.of(INFO), 1));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, 2, ReferenceData.empty()), GenericSecurityPosition.ofLongShort(PositionInfo.empty(), GenericSecurity.of(INFO), 1, 2));
        }
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            DsfSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo tradeInfo     = TradeInfo.of(PRODUCT.LastTradeDate.minusDays(1));
            DsfTrade  expectedTrade = DsfTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, ReferenceData.empty()), expectedTrade);

            PositionInfo positionInfo      = PositionInfo.empty();
            DsfPosition  expectedPosition1 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            DsfPosition expectedPosition2 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
Exemplo n.º 12
0
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            IborFutureSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo       tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            IborFutureTrade expectedTrade = IborFutureTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(0.995).build();

            assertEquals(test.createTrade(tradeInfo, 100, 0.995, ReferenceData.empty()), expectedTrade);

            PositionInfo       positionInfo      = PositionInfo.empty();
            IborFuturePosition expectedPosition1 = IborFuturePosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            IborFuturePosition expectedPosition2 = IborFuturePosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
Exemplo n.º 13
0
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            IborFutureOptionSecurity test    = sut();
            ReferenceData            refData = ImmutableReferenceData.of(FUTURE_ID, FUTURE_SECURITY);

            assertEquals(test.createProduct(refData), OPTION);
            TradeInfo             tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            IborFutureOptionTrade expectedTrade = IborFutureOptionTrade.builder().info(tradeInfo).product(OPTION).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, refData), expectedTrade);

            PositionInfo             positionInfo      = PositionInfo.empty();
            IborFutureOptionPosition expectedPosition1 = IborFutureOptionPosition.builder().info(positionInfo).product(OPTION).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, refData), expectedPosition1);
            IborFutureOptionPosition expectedPosition2 = IborFutureOptionPosition.builder().info(positionInfo).product(OPTION).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, refData), expectedPosition2);
        }
Exemplo n.º 14
0
 // calculates jump-to-default for one scenario
 internal JumpToDefault jumpToDefault(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
 {
     return(tradePricer.jumpToDefault(trade, ratesProvider, refData));
 }
Exemplo n.º 15
0
        // calculates calibrated bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            PointSensitivities pointSensitivity = tradePricer.presentValueSensitivity(trade, ratesProvider, refData);

            return(ratesProvider.parameterSensitivity(pointSensitivity).multipliedBy(ONE_BASIS_POINT));
        }
Exemplo n.º 16
0
        // calculates market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider, refData);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
Exemplo n.º 17
0
 //-------------------------------------------------------------------------
 // calculates market quote sum PV01 for all scenarios
 internal MultiCurrencyScenarioArray pv01MarketQuoteSum(ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => pv01MarketQuoteSum(trade, marketData.scenario(i).creditRatesProvider(), refData)));
 }
Exemplo n.º 18
0
 //-------------------------------------------------------------------------
 // calculates bucketed CS01 for all scenarios
 internal ScenarioArray <CurrencyParameterSensitivity> cs01Bucketed(ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => cs01Bucketed(trade, marketData.scenario(i).creditRatesProvider(), refData)));
 }
Exemplo n.º 19
0
 // calculates parallel CS01 for one scenario
 internal CurrencyAmount cs01Parallel(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
 {
     return(cs01Calculator.parallelCs01(trade, ratesProvider, refData));
 }
Exemplo n.º 20
0
 //-------------------------------------------------------------------------
 // calculates principal for all scenarios
 internal CurrencyScenarioArray principal(ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
 {
     return(CurrencyScenarioArray.of(marketData.ScenarioCount, i => principal(trade, marketData.scenario(i).creditRatesProvider(), refData)));
 }
Exemplo n.º 21
0
 // calculates principal for one scenario
 internal CurrencyAmount principal(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
 {
     return(tradePricer.presentValueOnSettle(trade, ratesProvider, PriceType.CLEAN, refData));
 }
Exemplo n.º 22
0
 // calculates bucketed CS01 for one scenario
 internal CurrencyParameterSensitivity cs01Bucketed(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
 {
     return(cs01Calculator.bucketedCs01(trade, ratesProvider, refData));
 }
Exemplo n.º 23
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the currency exposure of the bond trade.
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <param name="discountingProvider">  the discount factors provider </param>
        /// <param name="refData">  the reference data used to calculate the settlement date </param>
        /// <param name="cleanRealPrice">  the clean real price </param>
        /// <returns> the currency exposure of the trade </returns>
        public virtual MultiCurrencyAmount currencyExposureFromCleanPrice(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData, double cleanRealPrice)
        {
            CurrencyAmount pv = presentValueFromCleanPrice(trade, ratesProvider, discountingProvider, refData, cleanRealPrice);

            return(MultiCurrencyAmount.of(pv));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Calculates the present value of the settlement of the bond trade from the clean price with z-spread.
        /// <para>
        /// Since the sign of the settlement notional is opposite to that of the product, negative amount will be returned
        /// for positive quantity of trade.
        /// </para>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic
        /// compounded rates of the discounting curve.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <param name="discountingProvider">  the discount factors provider </param>
        /// <param name="refData">  the reference data used to calculate the settlement date </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <param name="cleanRealPrice">  the clean real price </param>
        /// <returns> the present value of the settlement </returns>
        public virtual CurrencyAmount presentValueFromCleanPriceWithZSpread(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData, double cleanRealPrice, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            validate(ratesProvider, discountingProvider);
            LocalDate valuationDate          = ratesProvider.ValuationDate;
            ResolvedCapitalIndexedBond bond  = trade.Product;
            LocalDate standardSettlementDate = bond.calculateSettlementDateFromValuation(valuationDate, refData);
            LocalDate tradeSettlementDate    = settlementDate(trade, valuationDate);
            RepoCurveDiscountFactors repoDf  = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(bond, discountingProvider);
            double         df         = repoDf.discountFactor(standardSettlementDate);
            CurrencyAmount pvStandard = forecastValueStandardFromCleanPrice(bond, ratesProvider, standardSettlementDate, cleanRealPrice).multipliedBy(df);

            if (standardSettlementDate.isEqual(tradeSettlementDate))
            {
                return(presentValueFromProductPresentValue(trade, ratesProvider, discountingProvider, pvStandard));
            }
            // check coupon payment between two settlement dates
            IssuerCurveDiscountFactors issuerDf = DiscountingCapitalIndexedBondProductPricer.issuerCurveDf(bond, discountingProvider);
            double pvDiff = 0d;

            if (standardSettlementDate.isAfter(tradeSettlementDate))
            {
                pvDiff = -productPricer.presentValueCouponWithZSpread(bond, ratesProvider, issuerDf, tradeSettlementDate, standardSettlementDate, zSpread, compoundedRateType, periodsPerYear);
            }
            else
            {
                pvDiff = productPricer.presentValueCouponWithZSpread(bond, ratesProvider, issuerDf, standardSettlementDate, tradeSettlementDate, zSpread, compoundedRateType, periodsPerYear);
            }
            return(presentValueFromProductPresentValue(trade, ratesProvider, discountingProvider, pvStandard.plus(pvDiff)));
        }
Exemplo n.º 25
0
 //-------------------------------------------------------------------------
 // calculates jump-to-default for all scenarios
 internal ScenarioArray <JumpToDefault> jumpToDefault(ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => jumpToDefault(trade, marketData.scenario(i).creditRatesProvider(), refData)));
 }
Exemplo n.º 26
0
 // calculates recovery01 for one scenario
 internal CurrencyAmount recovery01(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
 {
     return(tradePricer.recovery01OnSettle(trade, ratesProvider, refData));
 }
Exemplo n.º 27
0
        /// <summary>
        /// Calculates the present value sensitivity of the settlement of the bond trade from the real clean price
        /// with z-spread.
        /// <para>
        /// The present value sensitivity of the settlement is the sensitivity of the present value to
        /// the underlying curves.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <param name="refData">  the reference data used to calculate the settlement date </param>
        /// <param name="discountingProvider">  the discount factors provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <param name="cleanRealPrice">  the clean real price </param>
        /// <returns> the present value sensitivity of the settlement </returns>
        public virtual PointSensitivities presentValueSensitivityFromCleanPriceWithZSpread(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData, double cleanRealPrice, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            validate(ratesProvider, discountingProvider);
            LocalDate valuationDate          = ratesProvider.ValuationDate;
            ResolvedCapitalIndexedBond bond  = trade.Product;
            LocalDate standardSettlementDate = bond.calculateSettlementDateFromValuation(valuationDate, refData);
            LocalDate tradeSettlementDate    = settlementDate(trade, valuationDate);
            RepoCurveDiscountFactors repoDf  = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(bond, discountingProvider);
            double df = repoDf.discountFactor(standardSettlementDate);
            PointSensitivityBuilder dfSensi         = repoDf.zeroRatePointSensitivity(standardSettlementDate);
            PointSensitivityBuilder pvSensiStandard = forecastValueSensitivityStandardFromCleanPrice(bond, ratesProvider, standardSettlementDate, cleanRealPrice).multipliedBy(df).combinedWith(dfSensi.multipliedBy(forecastValueStandardFromCleanPrice(bond, ratesProvider, standardSettlementDate, cleanRealPrice).Amount));

            if (standardSettlementDate.isEqual(tradeSettlementDate))
            {
                return(presentValueSensitivityFromProductPresentValueSensitivity(trade, ratesProvider, discountingProvider, pvSensiStandard).build());
            }
            // check coupon payment between two settlement dates
            IssuerCurveDiscountFactors issuerDf    = DiscountingCapitalIndexedBondProductPricer.issuerCurveDf(bond, discountingProvider);
            PointSensitivityBuilder    pvSensiDiff = PointSensitivityBuilder.none();

            if (standardSettlementDate.isAfter(tradeSettlementDate))
            {
                pvSensiDiff = pvSensiDiff.combinedWith(productPricer.presentValueSensitivityCouponWithZSpread(bond, ratesProvider, issuerDf, tradeSettlementDate, standardSettlementDate, zSpread, compoundedRateType, periodsPerYear).multipliedBy(-1d));
            }
            else
            {
                pvSensiDiff = pvSensiDiff.combinedWith(productPricer.presentValueSensitivityCouponWithZSpread(bond, ratesProvider, issuerDf, standardSettlementDate, tradeSettlementDate, zSpread, compoundedRateType, periodsPerYear));
            }
            return(presentValueSensitivityFromProductPresentValueSensitivity(trade, ratesProvider, discountingProvider, pvSensiStandard.combinedWith(pvSensiDiff)).build());
        }
Exemplo n.º 28
0
 //-------------------------------------------------------------------------
 // calculates present value for all scenarios
 internal CurrencyScenarioArray presentValue(ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
 {
     return(CurrencyScenarioArray.of(marketData.ScenarioCount, i => presentValue(trade, marketData.scenario(i).creditRatesProvider(), PriceType.DIRTY, refData)));
 }
Exemplo n.º 29
0
        /// <summary>
        /// Calculates the currency exposure of the bond trade with z-spread.
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <param name="discountingProvider">  the discount factors provider </param>
        /// <param name="refData">  the reference data used to calculate the settlement date </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <param name="cleanRealPrice">  the clean real price </param>
        /// <returns> the currency exposure of the trade </returns>
        public virtual MultiCurrencyAmount currencyExposureFromCleanPriceWithZSpread(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData, double cleanRealPrice, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            CurrencyAmount pv = presentValueFromCleanPriceWithZSpread(trade, ratesProvider, discountingProvider, refData, cleanRealPrice, zSpread, compoundedRateType, periodsPerYear);

            return(MultiCurrencyAmount.of(pv));
        }
Exemplo n.º 30
0
 // calculates present value for one scenario
 internal CurrencyAmount presentValue(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData)
 {
     return(tradePricer.presentValue(trade, ratesProvider, priceType, refData));
 }