Esempio n. 1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the deliverable swap futures trade.
        /// <para>
        /// The present value of the product is the value on the valuation date.
        /// The current price is calculated using the discounting model.
        /// </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="ratesProvider">  the rates provider </param>
        /// <param name="lastSettlementPrice">  the last settlement price used for margining, in decimal form </param>
        /// <returns> the present value </returns>
        public virtual CurrencyAmount presentValue(ResolvedDsfTrade trade, RatesProvider ratesProvider, double lastSettlementPrice)
        {
            double price          = this.price(trade, ratesProvider);
            double referencePrice = this.referencePrice(trade, ratesProvider.ValuationDate, lastSettlementPrice);

            return(presentValue(trade, price, referencePrice));
        }
Esempio n. 2
0
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedDsfTrade trade, RatesProvider ratesProvider)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
Esempio n. 3
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity of the deliverable swap futures 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="ratesProvider">  the rates provider </param>
        /// <returns> the present value curve sensitivity of the trade </returns>
        public virtual PointSensitivities presentValueSensitivity(ResolvedDsfTrade trade, RatesProvider ratesProvider)
        {
            ResolvedDsf        product          = trade.Product;
            PointSensitivities priceSensi       = productPricer.priceSensitivity(product, ratesProvider);
            PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi);

            return(marginIndexSensi.multipliedBy(trade.Quantity));
        }
Esempio n. 4
0
        //-------------------------------------------------------------------------
        // gets the settlement price
        private double settlementPrice(ResolvedDsfTrade trade, RatesProvider ratesProvider)
        {
            StandardId standardId = trade.Product.SecurityId.StandardId;
            QuoteId    id         = QuoteId.of(standardId, FieldName.SETTLEMENT_PRICE);
            double     price      = ratesProvider.data(id);

            ArgChecker.isTrue(price < 10, "Price must be in decimal form, such as 1.007 for a 0.7% present value, but was: {}", price);
            return(price);
        }
Esempio n. 5
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the deliverable swap futures trade from the current price.
        /// <para>
        /// The present value of the product is the value on the valuation date.
        /// The current price is specified, not calculated.
        /// </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 current price, in decimal form </param>
        /// <param name="referencePrice">  the reference price to margin against, typically the last settlement price, in decimal form </param>
        /// <returns> the present value </returns>
        private CurrencyAmount presentValue(ResolvedDsfTrade trade, double currentPrice, double referencePrice)
        {
            ResolvedDsf 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));
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedDsfTrade, 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(ResolvedDsfTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.pv01MarketQuoteSum(trade, lookup.marketDataView(marketData)));
 }
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedDsfTrade, 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="ratesProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual MultiCurrencyAmount pv01MarketQuoteSum(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(calc.pv01MarketQuoteSum(trade, ratesProvider));
 }
Esempio n. 8
0
 //-------------------------------------------------------------------------
 // calculates calibrated bucketed PV01 for all scenarios
 internal ScenarioArray <CurrencyParameterSensitivities> pv01CalibratedBucketed(ResolvedDsfTrade trade, RatesScenarioMarketData marketData)
 {
     return(ScenarioArray.of(marketData.ScenarioCount, i => pv01CalibratedBucketed(trade, marketData.scenario(i).ratesProvider())));
 }
Esempio n. 9
0
        // calibrated bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedDsfTrade trade, RatesProvider ratesProvider)
        {
            PointSensitivities pointSensitivity = tradePricer.presentValueSensitivity(trade, ratesProvider);

            return(ratesProvider.parameterSensitivity(pointSensitivity).multipliedBy(ONE_BASIS_POINT));
        }
Esempio n. 10
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the reference price for the trade.
 /// <para>
 /// If the valuation date equals the trade date, then the reference price is the trade price.
 /// Otherwise, the reference price is the last settlement price used for margining.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="valuationDate">  the date for which the reference price should be calculated </param>
 /// <param name="lastSettlementPrice">  the last settlement price used for margining, in decimal form </param>
 /// <returns> the reference price, in decimal form </returns>
 private double referencePrice(ResolvedDsfTrade trade, LocalDate valuationDate, double lastSettlementPrice)
 {
     ArgChecker.notNull(valuationDate, "valuationDate");
     return(trade.TradedPrice.filter(tp => tp.TradeDate.Equals(valuationDate)).map(tp => tp.Price).orElse(lastSettlementPrice));
 }
Esempio n. 11
0
 //-------------------------------------------------------------------------
 // calculates calibrated sum PV01 for all scenarios
 internal MultiCurrencyScenarioArray pv01CalibratedSum(ResolvedDsfTrade trade, RatesScenarioMarketData marketData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => pv01CalibratedSum(trade, marketData.scenario(i).ratesProvider())));
 }
 //-------------------------------------------------------------------------
 /// <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)));
 }
 //-------------------------------------------------------------------------
 /// <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)));
 }
Esempio n. 14
0
 //-------------------------------------------------------------------------
 // calculates currency exposure for all scenarios
 internal MultiCurrencyScenarioArray currencyExposure(ResolvedDsfTrade trade, RatesScenarioMarketData marketData)
 {
     return(MultiCurrencyScenarioArray.of(marketData.ScenarioCount, i => currencyExposure(trade, marketData.scenario(i).ratesProvider())));
 }
Esempio n. 15
0
        // currency exposure for one scenario
        internal MultiCurrencyAmount currencyExposure(ResolvedDsfTrade trade, RatesProvider ratesProvider)
        {
            double settlementPrice = this.settlementPrice(trade, ratesProvider);

            return(tradePricer.currencyExposure(trade, ratesProvider, settlementPrice));
        }
Esempio n. 16
0
 // unit price for one scenario
 internal double unitPrice(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     // mark to model
     return(tradePricer.price(trade, ratesProvider));
 }
Esempio n. 17
0
 //-------------------------------------------------------------------------
 // calculates unit price for all scenarios
 internal DoubleScenarioArray unitPrice(ResolvedDsfTrade trade, RatesScenarioMarketData marketData)
 {
     return(DoubleScenarioArray.of(marketData.ScenarioCount, i => unitPrice(trade, marketData.scenario(i).ratesProvider())));
 }
Esempio n. 18
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the price of the underlying deliverable swap futures product.
 /// <para>
 /// The price of the trade is the price on the valuation date.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the rates provider </param>
 /// <returns> the price of the trade, in decimal form </returns>
 public virtual double price(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(productPricer.price(trade.Product, ratesProvider));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates present value sensitivity across one or more scenarios.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedDsfTrade, 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(ResolvedDsfTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.pv01MarketQuoteBucketed(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 CurrencyScenarioArray presentValue(ResolvedDsfTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
 {
     return(calc.presentValue(trade, lookup.marketDataView(marketData)));
 }
 /// <summary>
 /// Calculates present value sensitivity for a single set of market data.
 /// <para>
 /// This is the sensitivity of
 /// <seealso cref="#presentValue(ResolvedDsfTrade, 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="ratesProvider">  the market data </param>
 /// <returns> the present value sensitivity </returns>
 public virtual CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(calc.pv01MarketQuoteBucketed(trade, ratesProvider));
 }
Esempio n. 22
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the currency exposure of the deliverable swap futures trade.
 /// <para>
 /// Since the deliverable swap futures is based on a single currency, the trade is exposed to only this currency.
 /// The current price is calculated using the discounting model.
 /// </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="ratesProvider">  the rates provider </param>
 /// <param name="lastSettlementPrice">  the last settlement price used for margining, in decimal form </param>
 /// <returns> the currency exposure of the trade </returns>
 public virtual MultiCurrencyAmount currencyExposure(ResolvedDsfTrade trade, RatesProvider ratesProvider, double lastSettlementPrice)
 {
     return(MultiCurrencyAmount.of(presentValue(trade, ratesProvider, lastSettlementPrice)));
 }
 /// <summary>
 /// Calculates unit price for a single set of market data.
 /// <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="ratesProvider">  the market data </param>
 /// <returns> the present value </returns>
 public virtual double unitPrice(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(calc.unitPrice(trade, ratesProvider));
 }
Esempio n. 24
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the price sensitivity of the deliverable swap futures product.
 /// <para>
 /// The price sensitivity of the product is the sensitivity of the price to the underlying curves.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the rates provider </param>
 /// <returns> the price curve sensitivity of the trade </returns>
 public virtual PointSensitivities priceSensitivity(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(productPricer.priceSensitivity(trade.Product, ratesProvider));
 }
 /// <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>
 /// <returns> the currency exposure </returns>
 public virtual MultiCurrencyAmount currencyExposure(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(calc.currencyExposure(trade, ratesProvider));
 }
Esempio n. 26
0
 //-------------------------------------------------------------------------
 // calculates present value for all scenarios
 internal CurrencyScenarioArray presentValue(ResolvedDsfTrade trade, RatesScenarioMarketData marketData)
 {
     return(CurrencyScenarioArray.of(marketData.ScenarioCount, i => presentValue(trade, marketData.scenario(i).ratesProvider())));
 }
 /// <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>
 /// <returns> the present value </returns>
 public virtual CurrencyAmount presentValue(ResolvedDsfTrade trade, RatesProvider ratesProvider)
 {
     return(calc.presentValue(trade, ratesProvider));
 }
Esempio n. 28
0
        // present value for one scenario
        internal CurrencyAmount presentValue(ResolvedDsfTrade trade, RatesProvider ratesProvider)
        {
            double settlementPrice = this.settlementPrice(trade, ratesProvider);

            return(tradePricer.presentValue(trade, ratesProvider, settlementPrice));
        }