Пример #1
0
 // determine the curve parameter sensitivities, removing the curency
 private UnitParameterSensitivities extractSensitivities(
     ResolvedTrade trade, RatesProvider provider) {
   CalibrationMeasure<ResolvedTrade> measure = getMeasure(trade);
   CurrencyParameterSensitivities paramSens = measure.sensitivities(trade, provider);
   UnitParameterSensitivities unitSens = UnitParameterSensitivities.empty();
   for (CurrencyParameterSensitivity ccySens : paramSens.getSensitivities()) {
     unitSens = unitSens.combinedWith(ccySens.toUnitParameterSensitivity());
   }
   return unitSens;
 }
Пример #2
0
  /**
   * Calculates the sensitivity with respect to the rates provider.
   *
   * <p>The result array is composed of the concatenated curve sensitivities from all curves
   * currently being processed.
   *
   * @param trade the trade
   * @param provider the rates provider
   * @param curveOrder the order of the curves
   * @return the sensitivity derivative
   */
  public DoubleArray derivative(
      ResolvedTrade trade, RatesProvider provider, List<CurveParameterSize> curveOrder) {
    UnitParameterSensitivities unitSens = extractSensitivities(trade, provider);

    // expand to a concatenated array
    DoubleArray result = DoubleArray.EMPTY;
    for (CurveParameterSize curveParams : curveOrder) {
      DoubleArray sens =
          unitSens
              .findSensitivity(curveParams.getName())
              .map(s -> s.getSensitivity())
              .orElseGet(() -> DoubleArray.filled(curveParams.getParameterCount()));
      result = result.concat(sens);
    }
    return result;
  }