//-----------------------------------------------------------------------
        /// <summary>
        /// Gets a sensitivity instance by type, throwing an exception if not found.
        /// </summary>
        /// <param name="type">  the type to get </param>
        /// <returns> the sensitivity </returns>
        /// <exception cref="IllegalArgumentException"> if the type is not found </exception>
        public CurrencyParameterSensitivities getTypedSensitivity(CurveSensitivitiesType type)
        {
            CurrencyParameterSensitivities sens = typedSensitivities.get(type);

            if (sens == null)
            {
                throw new System.ArgumentException("Unable to find sensitivities: " + type);
            }
            return(sens);
        }
Example #2
0
 /// <summary>
 /// Adds a single sensitivity to the builder.
 /// <para>
 /// Values with the same market data name and currency will be merged.
 ///
 /// </para>
 /// </summary>
 /// <param name="type">  the sensitivity type </param>
 /// <param name="curveName">  the curve name </param>
 /// <param name="currency">  the currency of the sensitivity </param>
 /// <param name="metadata">  the sensitivity metadata, not empty </param>
 /// <param name="sensitivityValue">  the sensitivity value </param>
 /// <returns> this, for chaining </returns>
 public CurveSensitivitiesBuilder add(CurveSensitivitiesType type, CurveName curveName, Currency currency, ParameterMetadata metadata, double sensitivityValue)
 {
     data.computeIfAbsent(type, t => CurrencyParameterSensitivities.builder()).add(curveName, currency, metadata, sensitivityValue);
     return(this);
 }
Example #3
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Adds a sensitivity to the builder.
 /// <para>
 /// Values with the same market data name and currency will be merged.
 ///
 /// </para>
 /// </summary>
 /// <param name="type">  the sensitivity type </param>
 /// <param name="sensitivity">  the sensitivity to ad </param>
 /// <returns> this, for chaining </returns>
 public CurveSensitivitiesBuilder add(CurveSensitivitiesType type, CurrencyParameterSensitivity sensitivity)
 {
     data.computeIfAbsent(type, t => CurrencyParameterSensitivities.builder()).add(sensitivity);
     return(this);
 }
 /// <summary>
 /// Finds a sensitivity instance by type, returning empty if not found.
 /// </summary>
 /// <param name="type">  the type to find </param>
 /// <returns> the sensitivity, empty if not found </returns>
 public Optional <CurrencyParameterSensitivities> findTypedSensitivity(CurveSensitivitiesType type)
 {
     return(Optional.ofNullable(typedSensitivities.get(type)));
 }
 /// <summary>
 /// Obtains an instance from a single set of sensitivities.
 /// </summary>
 /// <param name="info">  the additional information </param>
 /// <param name="type">  the type of the sensitivities </param>
 /// <param name="sensitivities">  the sensitivities </param>
 /// <returns> the sensitivities instance </returns>
 public static CurveSensitivities of(PortfolioItemInfo info, CurveSensitivitiesType type, CurrencyParameterSensitivities sensitivities)
 {
     return(new CurveSensitivities(info, ImmutableMap.of(type, sensitivities)));
 }