/// <summary> /// Returns a collector that can be used to create a multi-currency amount /// from a stream of amounts where each amount has a different currency. /// <para> /// Each amount in the stream must have a different currency. /// /// </para> /// </summary> /// <returns> the collector </returns> //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: private static java.util.stream.Collector<CurrencyAmount, ?, MultiCurrencyAmount> collectorInternal() private static Collector <CurrencyAmount, ?, MultiCurrencyAmount> collectorInternal() { // this method must not be exposed publicly as misuse creates an instance with invalid state // it exists because when used internally it offers better performance than collector() //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(Collectors.collectingAndThen(Guavate.toImmutableSortedSet(), MultiCurrencyAmount::new)); }
/// <summary> /// The par spread quotes are converted to points upfronts or quoted spreads. /// <para> /// The relevant discount curve and recovery rate curve must be stored in {@code ratesProvider}. /// The credit curve is internally calibrated to par spread values. /// </para> /// <para> /// {@code trades} must be sorted in ascending order in maturity and coherent to {@code quotes}. /// </para> /// <para> /// The resultant quote is specified by {@code targetConvention}. /// /// </para> /// </summary> /// <param name="trades"> the trades </param> /// <param name="quotes"> the quotes </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="targetConvention"> the target convention </param> /// <param name="refData"> the reference data </param> /// <returns> the quotes </returns> public virtual IList <CdsQuote> quotesFromParSpread(IList <ResolvedCdsTrade> trades, IList <CdsQuote> quotes, CreditRatesProvider ratesProvider, CdsQuoteConvention targetConvention, ReferenceData refData) { ArgChecker.noNulls(trades, "trades"); ArgChecker.noNulls(quotes, "quotes"); ArgChecker.notNull(ratesProvider, "ratesProvider"); ArgChecker.notNull(targetConvention, "targetConvention"); ArgChecker.notNull(refData, "refData"); int nNodes = trades.Count; ArgChecker.isTrue(quotes.Count == nNodes, "trades and quotes must be the same size"); quotes.ForEach(q => ArgChecker.isTrue(q.QuoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD), "quote must be par spread")); //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: IEnumerator <StandardId> legalEntities = trades.Select(t => t.Product.LegalEntityId).collect(Collectors.toSet()).GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: StandardId legalEntityId = legalEntities.next(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: ArgChecker.isFalse(legalEntities.hasNext(), "legal entity must be common to trades"); //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: IEnumerator <Currency> currencies = trades.Select(t => t.Product.Currency).collect(Collectors.toSet()).GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Currency currency = currencies.next(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: ArgChecker.isFalse(currencies.hasNext(), "currency must be common to trades"); LocalDate valuationDate = ratesProvider.ValuationDate; CreditDiscountFactors discountFactors = ratesProvider.discountFactors(currency); RecoveryRates recoveryRates = ratesProvider.recoveryRates(legalEntityId); NodalCurve creditCurve = calibrator.calibrate(trades, DoubleArray.of(nNodes, q => quotes[q].QuotedValue), DoubleArray.filled(nNodes), CurveName.of("temp"), valuationDate, discountFactors, recoveryRates, refData); CreditRatesProvider ratesProviderNew = ratesProvider.toImmutableCreditRatesProvider().toBuilder().creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurve)))).build(); System.Func <ResolvedCdsTrade, CdsQuote> quoteValueFunction = createQuoteValueFunction(ratesProviderNew, targetConvention, refData); //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: ImmutableList <CdsQuote> result = trades.Select(c => quoteValueFunction(c)).collect(Collectors.collectingAndThen(Collectors.toList(), ImmutableList.copyOf)); return(result); }
/// <summary> /// Applies an operation to the sensitivities in this instance. /// <para> /// The result will consist of the same entries, but with the operator applied to each sensitivity value. /// This instance is immutable and unaffected by this method. /// </para> /// <para> /// This is used to apply a mathematical operation to the sensitivity values. /// For example, the operator could multiply the sensitivities by a constant, or take the inverse. /// <pre> /// inverse = base.mapSensitivities(value -> 1 / value); /// </pre> /// /// </para> /// </summary> /// <param name="operator"> the operator to be applied to the sensitivities </param> /// <returns> a {@code PointSensitivities} based on this one, with the operator applied to the sensitivity values </returns> public PointSensitivities mapSensitivities(System.Func <double, double> @operator) { //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: return(sensitivities.Select(s => s.withSensitivity(@operator(s.Sensitivity))).collect(Collectors.collectingAndThen(Guavate.toImmutableList(), PointSensitivities::new))); }