Пример #1
0
        // present value for one scenario
        internal CurrencyAmount presentValue(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
        {
            // mark to model
            double settlementPrice = this.settlementPrice(trade, discountingProvider);

            return(tradePricer.presentValue(trade, discountingProvider, settlementPrice));
        }
Пример #2
0
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider ratesProvider)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
Пример #3
0
        //-------------------------------------------------------------------------
        // gets the settlement price
        private double settlementPrice(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
        {
            StandardId standardId = trade.Product.SecurityId.StandardId;
            QuoteId    id         = QuoteId.of(standardId, FieldName.SETTLEMENT_PRICE);

            return(discountingProvider.data(id) / 100);    // convert market quote to value needed
        }
        /// <summary>
        /// Calculates the currency exposure of the bond future trade with z-spread.
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates
        /// of the issuer discounting curve.
        /// </para>
        /// <para>
        /// This method calculates based on the difference between the model price and the
        /// last settlement price, or the trade price if traded on the valuation date.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <param name="lastSettlementPrice">  the last settlement price used for margining, in decimal form </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodPerYear">  the number of periods per year </param>
        /// <returns> the currency exposure of the bond future trade </returns>
        public MultiCurrencyAmount currencyExposureWithZSpread(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear)
        {
            double price          = priceWithZSpread(trade, discountingProvider, zSpread, compoundedRateType, periodPerYear);
            double referencePrice = this.referencePrice(trade, discountingProvider.ValuationDate, lastSettlementPrice);

            return(MultiCurrencyAmount.of(presentValue(trade, price, referencePrice)));
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the currency exposure of the bond future trade.
        /// <para>
        /// This method calculates based on the difference between the model price and the
        /// last settlement price, or the trade price if traded on the valuation date.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <param name="lastSettlementPrice">  the last settlement price used for margining, in decimal form </param>
        /// <returns> the currency exposure of the bond future trade </returns>
        public MultiCurrencyAmount currencyExposure(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice)
        {
            double price          = this.price(trade, discountingProvider);
            double referencePrice = this.referencePrice(trade, discountingProvider.ValuationDate, lastSettlementPrice);

            return(MultiCurrencyAmount.of(presentValue(trade, price, referencePrice)));
        }
        /// <summary>
        /// Calculates the present value sensitivity of the bond future 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>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates
        /// of the issuer discounting curve.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodPerYear">  the number of periods per year </param>
        /// <returns> the present value curve sensitivity of the trade </returns>
        public PointSensitivities presentValueSensitivityWithZSpread(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear)
        {
            ResolvedBondFuture product          = trade.Product;
            PointSensitivities priceSensi       = productPricer.priceSensitivityWithZSpread(product, discountingProvider, zSpread, compoundedRateType, periodPerYear);
            PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi);

            return(marginIndexSensi.multipliedBy(trade.Quantity));
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity of the bond future trade.
        /// <para>
        /// The present value sensitivity of the trade is the sensitivity of the present value to
        /// the underlying curves.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <returns> the present value curve sensitivity of the trade </returns>
        public PointSensitivities presentValueSensitivity(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
        {
            ResolvedBondFuture product          = trade.Product;
            PointSensitivities priceSensi       = productPricer.priceSensitivity(product, discountingProvider);
            PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi);

            return(marginIndexSensi.multipliedBy(trade.Quantity));
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the bond future trade from the current price.
        /// <para>
        /// The present value of the product is the value on the valuation date.
        /// </para>
        /// <para>
        /// The calculation is performed against a reference price. The reference price
        /// must be the last settlement price used for margining, except on the trade date,
        /// when it must be the trade price.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="currentPrice">  the price on the valuation date </param>
        /// <param name="referencePrice">  the price with respect to which the margining should be done </param>
        /// <returns> the present value </returns>
        internal CurrencyAmount presentValue(ResolvedBondFutureTrade trade, double currentPrice, double referencePrice)
        {
            ResolvedBondFuture future         = trade.Product;
            double             priceIndex     = productPricer.marginIndex(future, currentPrice);
            double             referenceIndex = productPricer.marginIndex(future, referencePrice);
            double             pv             = (priceIndex - referenceIndex) * trade.Quantity;

            return(CurrencyAmount.of(future.Currency, pv));
        }
Пример #9
0
 //-------------------------------------------------------------------------
 // calculates calibrated bucketed PV01 for all scenarios
 internal ScenarioArray <CurrencyParameterSensitivities> pv01CalibratedBucketed(ResolvedBondFutureTrade trade, LegalEntityDiscountingScenarioMarketData marketData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => pv01CalibratedBucketed(trade, marketData.scenario(i).discountingProvider())));
 }
Пример #10
0
 //-------------------------------------------------------------------------
 // calculates currency exposure for all scenarios
 internal MultiCurrencyScenarioArray currencyExposure(ResolvedBondFutureTrade trade, LegalEntityDiscountingScenarioMarketData marketData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => currencyExposure(trade, marketData.scenario(i).discountingProvider())));
 }
Пример #11
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())));
 }
Пример #12
0
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedBondFutureTrade, LegalEntityDiscountingMarketDataLookup, 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="ratesProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual MultiCurrencyAmount pv01MarketQuoteSum(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider ratesProvider)
 {
     return(calc.pv01MarketQuoteSum(trade, ratesProvider));
 }
Пример #13
0
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedBondFutureTrade, 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="discountingProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual MultiCurrencyAmount pv01CalibratedSum(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(calc.pv01CalibratedSum(trade, discountingProvider));
 }
Пример #14
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedBondFutureTrade, 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="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 pv01CalibratedSum(ResolvedBondFutureTrade trade, LegalEntityDiscountingMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.pv01CalibratedSum(trade, lookup.marketDataView(marketData)));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the price of the bond future trade.
 /// <para>
 /// The price of the trade is the price on the valuation date.
 /// </para>
 /// <para>
 /// Strata uses <i>decimal prices</i> for bond futures. This is coherent with the pricing of <seealso cref="FixedCouponBond"/>.
 /// For example, a price of 99.32% is represented in Strata by 0.9932.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="discountingProvider">  the discounting provider </param>
 /// <returns> the price of the trade, in decimal form </returns>
 public double price(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(productPricer.price(trade.Product, discountingProvider));
 }
Пример #16
0
 //-------------------------------------------------------------------------
 /// <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 CurrencyScenarioArray presentValue(ResolvedBondFutureTrade trade, LegalEntityDiscountingMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.presentValue(trade, lookup.marketDataView(marketData)));
 }
Пример #17
0
 /// <summary>
 /// Calculates present value for a single set of market data.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="discountingProvider">  the market data </param>
 /// <returns> the present value </returns>
 public virtual CurrencyAmount presentValue(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(calc.presentValue(trade, discountingProvider));
 }
Пример #18
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedBondFutureTrade, LegalEntityDiscountingMarketDataLookup, 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(ResolvedBondFutureTrade trade, LegalEntityDiscountingMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.pv01MarketQuoteBucketed(trade, lookup.marketDataView(marketData)));
 }
Пример #19
0
        // par spread for one scenario
        internal double parSpread(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
        {
            double settlementPrice = this.settlementPrice(trade, discountingProvider);

            return(tradePricer.parSpread(trade, discountingProvider, settlementPrice));
        }
Пример #20
0
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedBondFutureTrade, LegalEntityDiscountingMarketDataLookup, 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="ratesProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider ratesProvider)
 {
     return(calc.pv01MarketQuoteBucketed(trade, ratesProvider));
 }
Пример #21
0
 // unit price for one scenario
 internal double unitPrice(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     // mark to model
     return(tradePricer.price(trade, discountingProvider));
 }
Пример #22
0
 /// <summary>
 /// Calculates par spread for a single set of market data.
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="discountingProvider">  the market data </param>
 /// <returns> the par spread </returns>
 public virtual double parSpread(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(calc.parSpread(trade, discountingProvider));
 }
Пример #23
0
        // currency exposure for one scenario
        internal MultiCurrencyAmount currencyExposure(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
        {
            double settlementPrice = this.settlementPrice(trade, discountingProvider);

            return(tradePricer.currencyExposure(trade, discountingProvider, settlementPrice));
        }
Пример #24
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates unit price across one or more scenarios.
 /// <para>
 /// This is the price of a single unit of the security.
 ///
 /// <h4>Price</h4>
 /// Strata uses <i>decimal prices</i> for bond futures in the trade model, pricers and market data.
 /// This is coherent with the pricing of <seealso cref="FixedCouponBond"/>. The bond futures delivery is a bond
 /// for an amount computed from the bond future price, a conversion factor and the accrued interest.
 ///
 /// </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(ResolvedBondFutureTrade trade, LegalEntityDiscountingMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.unitPrice(trade, lookup.marketDataView(marketData)));
 }
Пример #25
0
 //-------------------------------------------------------------------------
 // calculates present value for all scenarios
 internal CurrencyScenarioArray presentValue(ResolvedBondFutureTrade trade, LegalEntityDiscountingScenarioMarketData marketData)
 {
     return(CurrencyScenarioArray.of(marketData.ScenarioCount, i => presentValue(trade, marketData.scenario(i).discountingProvider())));
 }
Пример #26
0
 /// <summary>
 /// Calculates unit price for a single set of market data.
 /// <para>
 /// This is the price of a single unit of the security.
 ///
 /// <h4>Price</h4>
 /// Strata uses <i>decimal prices</i> for bond futures in the trade model, pricers and market data.
 /// This is coherent with the pricing of <seealso cref="FixedCouponBond"/>. The bond futures delivery is a bond
 /// for an amount computed from the bond future price, a conversion factor and the accrued interest.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="discountingProvider">  the market data </param>
 /// <returns> the present value </returns>
 public virtual double unitPrice(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(calc.unitPrice(trade, discountingProvider));
 }
Пример #27
0
 //-------------------------------------------------------------------------
 // calculates calibrated sum PV01 for all scenarios
 internal MultiCurrencyScenarioArray pv01CalibratedSum(ResolvedBondFutureTrade trade, LegalEntityDiscountingScenarioMarketData marketData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => pv01CalibratedSum(trade, marketData.scenario(i).discountingProvider())));
 }
Пример #28
0
 //-------------------------------------------------------------------------
 /// <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(ResolvedBondFutureTrade trade, LegalEntityDiscountingMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.currencyExposure(trade, lookup.marketDataView(marketData)));
 }
Пример #29
0
        // calibrated bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
        {
            PointSensitivities pointSensitivity = tradePricer.presentValueSensitivity(trade, discountingProvider);

            return(discountingProvider.parameterSensitivity(pointSensitivity).multipliedBy(ONE_BASIS_POINT));
        }
Пример #30
0
 /// <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="discountingProvider">  the market data </param>
 /// <returns> the currency exposure </returns>
 public virtual MultiCurrencyAmount currencyExposure(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(calc.currencyExposure(trade, discountingProvider));
 }