Example #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity of the settlement of the bond trade from the real clean price.
        /// <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="cleanRealPrice">  the clean real price </param>
        /// <returns> the present value sensitivity of the settlement </returns>
        public virtual PointSensitivities presentValueSensitivityFromCleanPrice(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData, double cleanRealPrice)
        {
            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.presentValueSensitivityCoupon(bond, ratesProvider, issuerDf, tradeSettlementDate, standardSettlementDate).multipliedBy(-1d));
            }
            else
            {
                pvSensiDiff = pvSensiDiff.combinedWith(productPricer.presentValueSensitivityCoupon(bond, ratesProvider, issuerDf, standardSettlementDate, tradeSettlementDate));
            }
            return(presentValueSensitivityFromProductPresentValueSensitivity(trade, ratesProvider, discountingProvider, pvSensiStandard.combinedWith(pvSensiDiff)).build());
        }
Example #2
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)));
        }
Example #3
0
        private CurrencyAmount presentValueFromProductPresentValue(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, CurrencyAmount productPresentValue)
        {
            CurrencyAmount pvProduct = productPresentValue.multipliedBy(trade.Quantity);
            CurrencyAmount pvPayment = presentValueSettlement(trade, ratesProvider, discountingProvider);

            return(pvProduct.plus(pvPayment));
        }
Example #4
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity of the bond trade.
        /// <para>
        /// The present value sensitivity of the trade is the sensitivity of the present value to
        /// the underlying curves.
        /// </para>
        /// <para>
        /// Coupon payments of the underlying product are considered based on the settlement date of the trade.
        ///
        /// </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>
        /// <returns> the present value sensitivity of the bond trade </returns>
        public virtual PointSensitivities presentValueSensitivity(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
        {
            validate(ratesProvider, discountingProvider);
            LocalDate settlementDate             = this.settlementDate(trade, ratesProvider.ValuationDate);
            PointSensitivityBuilder productSensi = productPricer.presentValueSensitivity(trade.Product, ratesProvider, discountingProvider, settlementDate);

            return(presentValueSensitivityFromProductPresentValueSensitivity(trade, ratesProvider, discountingProvider, productSensi).build());
        }
Example #5
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the bond trade.
        /// <para>
        /// The present value of the trade is the value on the valuation date.
        /// The result is expressed using the payment currency of the bond.
        /// </para>
        /// <para>
        /// Coupon payments of the underlying product are considered based on the settlement date of the trade.
        ///
        /// </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>
        /// <returns> the present value of the bond trade </returns>
        public virtual CurrencyAmount presentValue(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
        {
            validate(ratesProvider, discountingProvider);
            LocalDate      settlementDate = this.settlementDate(trade, ratesProvider.ValuationDate);
            CurrencyAmount pvProduct      = productPricer.presentValue(trade.Product, ratesProvider, discountingProvider, settlementDate);

            return(presentValueFromProductPresentValue(trade, ratesProvider, discountingProvider, pvProduct));
        }
Example #6
0
        /// <summary>
        /// Calculates the present value of the bond trade with z-spread.
        /// <para>
        /// The present value of the trade is the value on the valuation date.
        /// The result is expressed using the payment currency of the bond.
        /// </para>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic
        /// compounded rates of the discounting curve.
        /// </para>
        /// <para>
        /// Coupon payments of the underlying product are considered based on the settlement date of the trade.
        ///
        /// </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="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the present value of the bond trade </returns>
        public virtual CurrencyAmount presentValueWithZSpread(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            validate(ratesProvider, discountingProvider);
            LocalDate      settlementDate = this.settlementDate(trade, ratesProvider.ValuationDate);
            CurrencyAmount pvProduct      = productPricer.presentValueWithZSpread(trade.Product, ratesProvider, discountingProvider, settlementDate, zSpread, compoundedRateType, periodsPerYear);

            return(presentValueFromProductPresentValue(trade, ratesProvider, discountingProvider, pvProduct));
        }
Example #7
0
        /// <summary>
        /// Calculates the present value sensitivity of the bond trade with z-spread.
        /// <para>
        /// The present value sensitivity of the trade is the sensitivity of the present value to
        /// the underlying curves.
        /// </para>
        /// <para>
        /// Coupon payments of the underlying product are considered based on the settlement date of the trade.
        ///
        /// </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="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the present value sensitivity of the bond trade </returns>
        public virtual PointSensitivities presentValueSensitivityWithZSpread(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            validate(ratesProvider, discountingProvider);
            LocalDate settlementDate             = this.settlementDate(trade, ratesProvider.ValuationDate);
            PointSensitivityBuilder productSensi = productPricer.presentValueSensitivityWithZSpread(trade.Product, ratesProvider, discountingProvider, settlementDate, zSpread, compoundedRateType, periodsPerYear);

            return(presentValueSensitivityFromProductPresentValueSensitivity(trade, ratesProvider, discountingProvider, productSensi).build());
        }
Example #8
0
        //-------------------------------------------------------------------------
        private CurrencyAmount presentValueSettlement(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
        {
            if (!trade.Settlement.Present)
            {
                // position has no settlement, thus it has no value
                return(CurrencyAmount.zero(trade.Product.Currency));
            }
            BondPaymentPeriod          settlePeriod = trade.Settlement.get().Payment;
            ResolvedCapitalIndexedBond product      = trade.Product;
            CurrencyAmount             netAmount    = this.netAmount(trade, ratesProvider);
            RepoCurveDiscountFactors   repoDf       = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(product, discountingProvider);

            return(netAmount.multipliedBy(repoDf.discountFactor(settlePeriod.PaymentDate)));
        }
Example #9
0
        /// <summary>
        /// Calculates the current cash of the bond trade.
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <returns> the current cash </returns>
        public virtual CurrencyAmount currentCash(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider)
        {
            LocalDate      valuationDate  = ratesProvider.ValuationDate;
            LocalDate      settlementDate = this.settlementDate(trade, valuationDate);
            CurrencyAmount cashProduct    = productPricer.currentCash(trade.Product, ratesProvider, settlementDate);

            if (!trade.Settlement.Present)
            {
                return(cashProduct);
            }
            BondPaymentPeriod settlePeriod = trade.Settlement.get().Payment;
            double            cashSettle   = settlePeriod.PaymentDate.isEqual(valuationDate) ? netAmount(trade, ratesProvider).Amount : 0d;

            return(cashProduct.plus(cashSettle));
        }
Example #10
0
        // the sensitivity of the present value of the settlement
        private PointSensitivityBuilder presentValueSensitivitySettlement(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
        {
            if (!trade.Settlement.Present)
            {
                // position has no settlement, thus it has no sensitivity
                return(PointSensitivityBuilder.none());
            }
            ResolvedCapitalIndexedBondSettlement settlement = trade.Settlement.get();
            BondPaymentPeriod          settlePeriod         = settlement.Payment;
            ResolvedCapitalIndexedBond product = trade.Product;
            RepoCurveDiscountFactors   repoDf  = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(product, discountingProvider);
            double df        = repoDf.discountFactor(settlePeriod.PaymentDate);
            double netAmount = this.netAmount(trade, ratesProvider).Amount;
            PointSensitivityBuilder dfSensi = repoDf.zeroRatePointSensitivity(settlePeriod.PaymentDate).multipliedBy(netAmount);
            PointSensitivityBuilder naSensi = netAmountSensitivity(settlement, ratesProvider).multipliedBy(df);

            return(dfSensi.combinedWith(naSensi));
        }
Example #11
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the net amount of the settlement of the bond trade.
        /// <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>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider, used to determine price index values </param>
        /// <returns> the net amount </returns>
        public virtual CurrencyAmount netAmount(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider)
        {
            if (!trade.Settlement.Present)
            {
                // position has no settlement, thus it has no value
                return(CurrencyAmount.zero(trade.Product.Currency));
            }
            BondPaymentPeriod settlePeriod = trade.Settlement.get().Payment;

            if (settlePeriod is KnownAmountBondPaymentPeriod)
            {
                Payment payment = ((KnownAmountBondPaymentPeriod)settlePeriod).Payment;
                return(payment.Value);
            }
            else if (settlePeriod is CapitalIndexedBondPaymentPeriod)
            {
                CapitalIndexedBondPaymentPeriod casted = (CapitalIndexedBondPaymentPeriod)settlePeriod;
                double netAmount = productPricer.PeriodPricer.forecastValue(casted, ratesProvider);
                return(CurrencyAmount.of(casted.Currency, netAmount));
            }
            throw new System.NotSupportedException("unsupported settlement type");
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedCapitalIndexedBondTrade, RatesMarketDataLookup, LegalEntityDiscountingMarketDataLookup, ScenarioMarketData) present value"/>
 /// to a one basis point shift in the calibrated 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="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="legalEntityLookup">  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> pv01CalibratedBucketed(ResolvedCapitalIndexedBondTrade trade, RatesMarketDataLookup ratesLookup, LegalEntityDiscountingMarketDataLookup legalEntityLookup, ScenarioMarketData marketData)
 {
     return(calc.pv01CalibratedBucketed(trade, ratesLookup.marketDataView(marketData), legalEntityLookup.marketDataView(marketData)));
 }
 // currency exposure for one scenario
 internal MultiCurrencyAmount currencyExposure(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
 {
     return(tradePricer.currencyExposure(trade, ratesProvider, discountingProvider));
 }
 // current cash for one scenario
 internal CurrencyAmount currentCash(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider)
 {
     return(tradePricer.currentCash(trade, ratesProvider));
 }
Example #15
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>
        /// <returns> the currency exposure of the trade </returns>
        public virtual MultiCurrencyAmount currencyExposure(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
        {
            CurrencyAmount pv = presentValue(trade, ratesProvider, discountingProvider);

            return(MultiCurrencyAmount.of(pv));
        }
Example #16
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="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodsPerYear">  the number of periods per year </param>
        /// <returns> the currency exposure of the trade </returns>
        public virtual MultiCurrencyAmount currencyExposureWithZSpread(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
        {
            CurrencyAmount pv = presentValueWithZSpread(trade, ratesProvider, discountingProvider, zSpread, compoundedRateType, periodsPerYear);

            return(MultiCurrencyAmount.of(pv));
        }
 /// <summary>
 /// Calculates present value for a single set of market data.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the market data </param>
 /// <param name="legalEntityProvider">  the market data </param>
 /// <returns> the present value </returns>
 public virtual CurrencyAmount presentValue(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider legalEntityProvider)
 {
     return(calc.presentValue(trade, ratesProvider, legalEntityProvider));
 }
Example #18
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));
        }
Example #19
0
        //-------------------------------------------------------------------------
        // the sensitivity of the product plus settlement
        private PointSensitivityBuilder presentValueSensitivityFromProductPresentValueSensitivity(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, PointSensitivityBuilder productPresnetValueSensitivity)
        {
            PointSensitivityBuilder sensiProduct = productPresnetValueSensitivity.multipliedBy(trade.Quantity);
            PointSensitivityBuilder sensiPayment = presentValueSensitivitySettlement(trade, ratesProvider, discountingProvider);

            return(sensiProduct.combinedWith(sensiPayment));
        }
Example #20
0
 //-------------------------------------------------------------------------
 // calculate the settlement date
 private LocalDate settlementDate(ResolvedCapitalIndexedBondTrade trade, LocalDate valuationDate)
 {
     return(trade.Settlement.map(settle => settle.SettlementDate).orElse(valuationDate));
 }
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedCapitalIndexedBondTrade, RatesMarketDataLookup, LegalEntityDiscountingMarketDataLookup, ScenarioMarketData) present value"/>
 /// to a one basis point shift in the calibrated curves.
 /// The result is the sum of the sensitivities of all affected curves.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the market data </param>
 /// <param name="legalEntityProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual MultiCurrencyAmount pv01CalibratedSum(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider legalEntityProvider)
 {
     return(calc.pv01CalibratedSum(trade, ratesProvider, legalEntityProvider));
 }
 // present value for one scenario
 internal CurrencyAmount presentValue(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
 {
     return(tradePricer.presentValue(trade, ratesProvider, discountingProvider));
 }
 //-------------------------------------------------------------------------
 // calculates currency exposure for all scenarios
 internal MultiCurrencyScenarioArray currencyExposure(ResolvedCapitalIndexedBondTrade trade, RatesScenarioMarketData ratesMarketData, LegalEntityDiscountingScenarioMarketData legalEntityMarketData)
 {
     return(MultiCurrencyScenarioArray.of(legalEntityMarketData.ScenarioCount, i => currencyExposure(trade, ratesMarketData.scenario(i).ratesProvider(), legalEntityMarketData.scenario(i).discountingProvider())));
 }
        // calibrated bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider)
        {
            PointSensitivities pointSensitivity = tradePricer.presentValueSensitivity(trade, ratesProvider, discountingProvider);

            return(discountingProvider.parameterSensitivity(pointSensitivity).multipliedBy(ONE_BASIS_POINT));
        }
 //-------------------------------------------------------------------------
 // calculates calibrated bucketed PV01 for all scenarios
 internal ScenarioArray <CurrencyParameterSensitivities> pv01CalibratedBucketed(ResolvedCapitalIndexedBondTrade trade, RatesScenarioMarketData ratesMarketData, LegalEntityDiscountingScenarioMarketData legalEntityMarketData)
 {
     return(ScenarioArray.of(legalEntityMarketData.ScenarioCount, i => pv01CalibratedBucketed(trade, ratesMarketData.scenario(i).ratesProvider(), legalEntityMarketData.scenario(i).discountingProvider())));
 }
 /// <summary>
 /// Calculates currency exposure for a single set of market data.
 /// <para>
 /// The currency risk, expressed as the equivalent amount in each currency.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the market data </param>
 /// <param name="legalEntityProvider">  the market data </param>
 /// <returns> the currency exposure </returns>
 public virtual MultiCurrencyAmount currencyExposure(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider legalEntityProvider)
 {
     return(calc.currencyExposure(trade, ratesProvider, legalEntityProvider));
 }
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedCapitalIndexedBondTrade, RatesMarketDataLookup, LegalEntityDiscountingMarketDataLookup, ScenarioMarketData) present value"/>
 /// to a one basis point shift in the calibrated 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="ratesProvider">  the market data </param>
 /// <param name="legalEntityProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider legalEntityProvider)
 {
     return(calc.pv01CalibratedBucketed(trade, ratesProvider, legalEntityProvider));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedCapitalIndexedBondTrade, RatesMarketDataLookup, LegalEntityDiscountingMarketDataLookup, ScenarioMarketData) present value"/>
 /// to a one basis point shift in the calibrated curves.
 /// The result is the sum of the sensitivities of all affected curves.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="legalEntityLookup">  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 pv01CalibratedSum(ResolvedCapitalIndexedBondTrade trade, RatesMarketDataLookup ratesLookup, LegalEntityDiscountingMarketDataLookup legalEntityLookup, ScenarioMarketData marketData)
 {
     return(calc.pv01CalibratedSum(trade, ratesLookup.marketDataView(marketData), legalEntityLookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value across one or more scenarios.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesLookup">  the lookup used to query the market data </param>
 /// <param name="legalEntityLookup">  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 CurrencyScenarioArray presentValue(ResolvedCapitalIndexedBondTrade trade, RatesMarketDataLookup ratesLookup, LegalEntityDiscountingMarketDataLookup legalEntityLookup, ScenarioMarketData marketData)
 {
     return(calc.presentValue(trade, ratesLookup.marketDataView(marketData), legalEntityLookup.marketDataView(marketData)));
 }