// calculate one measure
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: private com.opengamma.strata.collect.result.Result<?> calculate(com.opengamma.strata.calc.Measure measure, com.opengamma.strata.product.credit.ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
        private Result <object> calculate(Measure measure, ResolvedCdsIndexTrade trade, CreditRatesScenarioMarketData marketData, ReferenceData refData)
        {
            SingleMeasureCalculation calculator = CALCULATORS.get(measure);

            if (calculator == null)
            {
                return(Result.failure(FailureReason.UNSUPPORTED, "Unsupported measure for CdsIndexTrade: {}", measure));
            }
            return(Result.of(() => calculator(trade, marketData, refData)));
        }
Beispiel #2
0
        /// <summary>
        /// Computes parallel CS01 for CDS index using a single credit curve.
        /// <para>
        /// This is coherent to the pricer <seealso cref="IsdaHomogenousCdsIndexTradePricer"/>.
        /// The relevant credit curve must be stored in {@code RatesProvider}.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="bucketCdsIndex">  the CDS index bucket </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="refData">  the reference data </param>
        /// <returns> the parallel CS01 </returns>
        public virtual CurrencyAmount parallelCs01(ResolvedCdsIndexTrade trade, IList <ResolvedCdsIndexTrade> bucketCdsIndex, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            ResolvedCdsTrade cdsTrade = trade.toSingleNameCds();
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IList <ResolvedCdsTrade> bucketCds = bucketCdsIndex.Select(ResolvedCdsIndexTrade::toSingleNameCds).ToList();
            CurrencyAmount           cs01Cds   = parallelCs01(cdsTrade, bucketCds, ratesProvider, refData);
            double indexFactor = getIndexFactor(cdsTrade.Product, ratesProvider);

            return(cs01Cds.multipliedBy(indexFactor));
        }
Beispiel #3
0
        /// <summary>
        /// Computes bucketed CS01 for CDS index using a single credit curve.
        /// <para>
        /// This is coherent to the pricer <seealso cref="IsdaHomogenousCdsIndexTradePricer"/>.
        /// The relevant credit curve must be stored in {@code RatesProvider}.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="bucketCdsIndex">  the CDS index bucket </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="refData">  the reference data </param>
        /// <returns> the bucketed CS01 </returns>
        public virtual CurrencyParameterSensitivity bucketedCs01(ResolvedCdsIndexTrade trade, IList <ResolvedCdsIndexTrade> bucketCdsIndex, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            ResolvedCdsTrade cdsTrade = trade.toSingleNameCds();
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IList <ResolvedCdsTrade> bucketCds = bucketCdsIndex.Select(ResolvedCdsIndexTrade::toSingleNameCds).ToList();
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IList <ResolvedTradeParameterMetadata> metadata     = bucketCdsIndex.Select(t => ResolvedTradeParameterMetadata.of(t, t.Product.ProtectionEndDate.ToString())).collect(Guavate.toImmutableList());
            CurrencyParameterSensitivity           bucketedCs01 = this.bucketedCs01(cdsTrade, bucketCds, metadata, ratesProvider, refData);
            double indexFactor = getIndexFactor(cdsTrade.Product, ratesProvider);

            return(bucketedCs01.multipliedBy(indexFactor));
        }
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(com.opengamma.strata.product.credit.CdsIndexTrade trade, java.util.Set<com.opengamma.strata.calc.Measure> measures, com.opengamma.strata.calc.runner.CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData scenarioMarketData, com.opengamma.strata.basics.ReferenceData refData)
        public virtual IDictionary <Measure, Result <object> > calculate(CdsIndexTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
        {
            // resolve the trade once for all measures and all scenarios
            ResolvedCdsIndexTrade resolved = trade.resolve(refData);

            // use lookup to query market data
            CreditRatesMarketDataLookup   ledLookup  = parameters.getParameter(typeof(CreditRatesMarketDataLookup));
            CreditRatesScenarioMarketData marketData = ledLookup.marketDataView(scenarioMarketData);

            // loop around measures, calculating all scenarios for one measure
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = new java.util.HashMap<>();
            IDictionary <Measure, Result <object> > results = new Dictionary <Measure, Result <object> >();

            foreach (Measure measure in measures)
            {
                results[measure] = calculate(measure, resolved, marketData, refData);
            }
            return(results);
        }
Beispiel #5
0
        /// <summary>
        /// Computes bucketed CS01 for CDS index using a single credit curve.
        /// <para>
        /// This is coherent to the pricer <seealso cref="IsdaHomogenousCdsIndexTradePricer"/>.
        /// The relevant credit curve must be stored in {@code RatesProvider}.
        /// </para>
        /// <para>
        /// The CDS index trades used in the curve calibration are reused as bucket CDS index by this method.
        /// Thus the credit curve must store <seealso cref="ResolvedTradeParameterMetadata"/>.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="refData">  the reference data </param>
        /// <returns> the bucketed CS01 </returns>
        public virtual CurrencyParameterSensitivity bucketedCs01(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            IList <ResolvedCdsIndexTrade> bucketCdsIndex = getBucketCdsIndex(trade.Product, ratesProvider);

            return(bucketedCs01(trade, bucketCdsIndex, ratesProvider, refData));
        }
Beispiel #6
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Computes parallel CS01 for CDS index using a single credit curve.
        /// <para>
        /// This is coherent to the pricer <seealso cref="IsdaHomogenousCdsIndexTradePricer"/>.
        /// The relevant credit curve must be stored in {@code RatesProvider}.
        /// </para>
        /// <para>
        /// The CDS index trades used in the curve calibration are reused as bucket CDS index by this method.
        /// Thus the credit curve must store <seealso cref="ResolvedTradeParameterMetadata"/>.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="refData">  the reference data </param>
        /// <returns> the parallel CS01 </returns>
        public virtual CurrencyAmount parallelCs01(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            IList <ResolvedCdsIndexTrade> bucketCdsIndex = getBucketCdsIndex(trade.Product, ratesProvider);

            return(parallelCs01(trade, bucketCdsIndex, ratesProvider, refData));
        }