Examples of YieldAndDiscountCurve


Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

    ArgumentChecker.notNull(hwData, "Hull-White data");
    final int nbExpiry = swaption.getExpiryTime().length;
    ArgumentChecker.isTrue(nbExpiry > 1, "At least two expiry dates required for this method");

    double tmpdb;
    final YieldAndDiscountCurve discountingCurve = hwData.getCurve(swaption.getUnderlyingSwap()[0].getFirstLeg().getDiscountCurve());

    final double[] theta = new double[nbExpiry + 1]; // Extended expiry time (with 0).
    theta[0] = 0.0;
    System.arraycopy(swaption.getExpiryTime(), 0, theta, 1, nbExpiry);
    final AnnuityPaymentFixed[] cashflow = new AnnuityPaymentFixed[nbExpiry];
    for (int loopexp = 0; loopexp < nbExpiry; loopexp++) {
      cashflow[loopexp] = swaption.getUnderlyingSwap()[loopexp].accept(CFEC, hwData);
    }
    final int[] n = new int[nbExpiry];
    final double[][][] alpha = new double[nbExpiry][][];
    final double[][][] alpha2 = new double[nbExpiry][][]; // alpha^2

    for (int loopexp = 0; loopexp < nbExpiry; loopexp++) {
      n[loopexp] = cashflow[loopexp].getNumberOfPayments();
      alpha[loopexp] = new double[loopexp + 1][];
      alpha2[loopexp] = new double[loopexp + 1][];
      for (int k = 0; k <= loopexp; k++) {
        alpha[loopexp][k] = new double[n[loopexp]];
        alpha2[loopexp][k] = new double[n[loopexp]];
        for (int l = 0; l < alpha[loopexp][k].length; l++) {
          alpha[loopexp][k][l] = MODEL.alpha(hwData.getHullWhiteParameter(), theta[k], theta[k + 1], theta[k + 1], cashflow[loopexp].getNthPayment(l).getPaymentTime());
          alpha2[loopexp][k][l] = alpha[loopexp][k][l] * alpha[loopexp][k][l];
        }
      }
    }

    final int nbPoint2 = 2 * NB_POINT + 1;
    final int[] startInt = new int[nbExpiry - 1];
    final int[] endInt = new int[nbExpiry - 1];
    for (int i = 1; i < nbExpiry - 1; i++) {
      startInt[i] = 0;
      endInt[i] = nbPoint2 - 1;
    }
    startInt[0] = NB_POINT;
    endInt[0] = NB_POINT;

    final double[][] t = new double[nbExpiry][]; // payment time
    final double[][] dfS = new double[nbExpiry][]; // discount factor
    final double[] beta = new double[nbExpiry];
    final double[][] h = new double[nbExpiry][];
    final double[][] sa2 = new double[nbExpiry][];

    for (int loopexp = 0; loopexp < nbExpiry; loopexp++) {
      beta[loopexp] = MODEL.beta(hwData.getHullWhiteParameter(), theta[loopexp], theta[loopexp + 1]);
      t[loopexp] = new double[n[loopexp]];
      dfS[loopexp] = new double[n[loopexp]];
      h[loopexp] = new double[n[loopexp]];
      sa2[loopexp] = new double[n[loopexp]];
      for (int loopcf = 0; loopcf < n[loopexp]; loopcf++) {
        t[loopexp][loopcf] = cashflow[loopexp].getNthPayment(loopcf).getPaymentTime();
        dfS[loopexp][loopcf] = discountingCurve.getDiscountFactor(t[loopexp][loopcf]);
        h[loopexp][loopcf] = (1 - Math.exp(-hwData.getHullWhiteParameter().getMeanReversion() * t[loopexp][loopcf])) / hwData.getHullWhiteParameter().getMeanReversion();
        tmpdb = 0.0;
        for (int k = 0; k <= loopexp; k++) {
          tmpdb += alpha2[loopexp][k][loopcf];
        }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

  public CurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final LiborMarketModelDisplacedDiffusionDataBundle lmmBundle) {
    ArgumentChecker.notNull(swaption, "swaption");
    ArgumentChecker.notNull(lmmBundle, "LMM bundle");
    // 1. Swaption CFE preparation
    final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, lmmBundle);
    final YieldAndDiscountCurve dsc = lmmBundle.getCurve(cfe.getDiscountCurve());
    final int nbCFInit = cfe.getNumberOfPayments();
    final double multFact = Math.signum(cfe.getNthPayment(0).getAmount());
    final boolean isCall = (cfe.getNthPayment(0).getAmount() < 0);
    final double[] cftInit = new double[nbCFInit];
    final double[] cfaInit = new double[nbCFInit];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cftInit[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime();
      cfaInit[loopcf] = cfe.getNthPayment(loopcf).getAmount() * -multFact;
    }
    final double timeToExpiry = swaption.getTimeToExpiry();
    // 2. Model data
    final int nbFactor = lmmBundle.getLmmParameter().getNbFactor();
    final double[][] volLMM = lmmBundle.getLmmParameter().getVolatility();
    final double[] timeLMM = lmmBundle.getLmmParameter().getIborTime();
    // 3. Link cfe dates to lmm
    final int[] indCFDate = new int[nbCFInit];
    int indStart = nbCFInit - 1;
    int indEnd = 0;
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      indCFDate[loopcf] = Arrays.binarySearch(timeLMM, cftInit[loopcf]);
      if (indCFDate[loopcf] < 0) {
        if (timeLMM[-indCFDate[loopcf] - 1] - cftInit[loopcf] < TIME_TOLERANCE) {
          indCFDate[loopcf] = -indCFDate[loopcf] - 1;
        } else {
          if (cftInit[loopcf] - timeLMM[-indCFDate[loopcf] - 2] < TIME_TOLERANCE) {
            indCFDate[loopcf] = -indCFDate[loopcf] - 2;
          } else {
            ArgumentChecker.isTrue(true, "Instrument time incompatible with LMM parametrisation"); //TODO really?
          }
        }
      }
      if (indCFDate[loopcf] < indStart) {
        indStart = indCFDate[loopcf];
      }
      if (indCFDate[loopcf] > indEnd) {
        indEnd = indCFDate[loopcf];
      }
    }
    final int nbCF = indEnd - indStart + 1;
    final double[] cfa = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cfa[indCFDate[loopcf] - indStart] = cfaInit[loopcf];
    }
    final double[] cft = new double[nbCF];
    System.arraycopy(timeLMM, indStart, cft, 0, nbCF);

    final double[] dfLMM = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCF; loopcf++) {
      dfLMM[loopcf] = dsc.getDiscountFactor(cft[loopcf]);
    }
    final double[][] gammaLMM = new double[nbCF - 1][nbFactor];
    final double[] deltaLMM = new double[nbCF - 1];
    System.arraycopy(lmmBundle.getLmmParameter().getAccrualFactor(), indStart, deltaLMM, 0, nbCF - 1);
    final double[] aLMM = new double[nbCF - 1];
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

   * @return The sensitivity.
   */
  public double[][] presentValueLMMSensitivity(final SwaptionPhysicalFixedIbor swaption, final LiborMarketModelDisplacedDiffusionDataBundle lmmBundle) {
    // 1. Swaption CFE preparation
    final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, lmmBundle);
    final YieldAndDiscountCurve dsc = lmmBundle.getCurve(cfe.getDiscountCurve());
    final int nbCFInit = cfe.getNumberOfPayments();
    final double multFact = Math.signum(cfe.getNthPayment(0).getAmount());
    final boolean isCall = (cfe.getNthPayment(0).getAmount() < 0);
    final double[] cftInit = new double[nbCFInit];
    final double[] cfaInit = new double[nbCFInit];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cftInit[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime();
      cfaInit[loopcf] = cfe.getNthPayment(loopcf).getAmount() * -multFact;
    }
    final double timeToExpiry = swaption.getTimeToExpiry();
    // 2. Model data
    final int nbFactor = lmmBundle.getLmmParameter().getNbFactor();
    final double[][] volLMM = lmmBundle.getLmmParameter().getVolatility();
    final double[] timeLMM = lmmBundle.getLmmParameter().getIborTime();
    // 3. Link cfe dates to lmm
    final int[] indCFDate = new int[nbCFInit];
    int indStart = nbCFInit - 1;
    int indEnd = 0;
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      indCFDate[loopcf] = Arrays.binarySearch(timeLMM, cftInit[loopcf]);
      if (indCFDate[loopcf] < 0) {
        if (timeLMM[-indCFDate[loopcf] - 1] - cftInit[loopcf] < TIME_TOLERANCE) {
          indCFDate[loopcf] = -indCFDate[loopcf] - 1;
        } else {
          if (cftInit[loopcf] - timeLMM[-indCFDate[loopcf] - 2] < TIME_TOLERANCE) {
            indCFDate[loopcf] = -indCFDate[loopcf] - 2;
          } else {
            ArgumentChecker.isTrue(true, "Instrument time incompatible with LMM");
          }
        }
      }
      if (indCFDate[loopcf] < indStart) {
        indStart = indCFDate[loopcf];
      }
      if (indCFDate[loopcf] > indEnd) {
        indEnd = indCFDate[loopcf];
      }
    }
    final int nbCF = indEnd - indStart + 1;
    final double[] cfa = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cfa[indCFDate[loopcf] - indStart] = cfaInit[loopcf];
    }
    final double[] cft = new double[nbCF];
    System.arraycopy(timeLMM, indStart, cft, 0, nbCF);

    final double[] dfLMM = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCF; loopcf++) {
      dfLMM[loopcf] = dsc.getDiscountFactor(cft[loopcf]);
    }
    final double[][] gammaLMM = new double[nbCF - 1][nbFactor];
    final double[] deltaLMM = new double[nbCF - 1];
    System.arraycopy(lmmBundle.getLmmParameter().getAccrualFactor(), indStart, deltaLMM, 0, nbCF - 1);
    final double[] aLMM = new double[nbCF - 1];
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

   * @return The sensitivity.
   */
  public double[] presentValueDDSensitivity(final SwaptionPhysicalFixedIbor swaption, final LiborMarketModelDisplacedDiffusionDataBundle lmmBundle) {
    // 1. Swaption CFE preparation
    final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, lmmBundle);
    final YieldAndDiscountCurve dsc = lmmBundle.getCurve(cfe.getDiscountCurve());
    final int nbCFInit = cfe.getNumberOfPayments();
    final double multFact = Math.signum(cfe.getNthPayment(0).getAmount());
    final boolean isCall = (cfe.getNthPayment(0).getAmount() < 0);
    final double[] cftInit = new double[nbCFInit];
    final double[] cfaInit = new double[nbCFInit];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cftInit[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime();
      cfaInit[loopcf] = cfe.getNthPayment(loopcf).getAmount() * -multFact;
    }
    final double timeToExpiry = swaption.getTimeToExpiry();
    // 2. Model data
    final int nbFactor = lmmBundle.getLmmParameter().getNbFactor();
    final double[][] volLMM = lmmBundle.getLmmParameter().getVolatility();
    final double[] timeLMM = lmmBundle.getLmmParameter().getIborTime();
    // 3. Link cfe dates to lmm
    final int[] indCFDate = new int[nbCFInit];
    int indStart = nbCFInit - 1;
    int indEnd = 0;
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      indCFDate[loopcf] = Arrays.binarySearch(timeLMM, cftInit[loopcf]);
      if (indCFDate[loopcf] < 0) {
        if (timeLMM[-indCFDate[loopcf] - 1] - cftInit[loopcf] < TIME_TOLERANCE) {
          indCFDate[loopcf] = -indCFDate[loopcf] - 1;
        } else {
          if (cftInit[loopcf] - timeLMM[-indCFDate[loopcf] - 2] < TIME_TOLERANCE) {
            indCFDate[loopcf] = -indCFDate[loopcf] - 2;
          } else {
            ArgumentChecker.isTrue(true, "Instrument time incompatible with LMM");
          }
        }
      }
      if (indCFDate[loopcf] < indStart) {
        indStart = indCFDate[loopcf];
      }
      if (indCFDate[loopcf] > indEnd) {
        indEnd = indCFDate[loopcf];
      }
    }
    final int nbCF = indEnd - indStart + 1;
    final double[] cfa = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cfa[indCFDate[loopcf] - indStart] = cfaInit[loopcf];
    }
    final double[] cft = new double[nbCF];
    System.arraycopy(timeLMM, indStart, cft, 0, nbCF);

    final double[] dfLMM = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCF; loopcf++) {
      dfLMM[loopcf] = dsc.getDiscountFactor(cft[loopcf]);
    }
    final double[][] gammaLMM = new double[nbCF - 1][nbFactor];
    final double[] deltaLMM = new double[nbCF - 1];
    System.arraycopy(lmmBundle.getLmmParameter().getAccrualFactor(), indStart, deltaLMM, 0, nbCF - 1);
    final double[] aLMM = new double[nbCF - 1];
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

   * @return The present value.
   */
  public InterestRateCurveSensitivity presentValueCurveSensitivity(final SwaptionPhysicalFixedIbor swaption, final LiborMarketModelDisplacedDiffusionDataBundle lmmBundle) {
    // 1. Swaption CFE preparation
    final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, lmmBundle);
    final YieldAndDiscountCurve dsc = lmmBundle.getCurve(cfe.getDiscountCurve());
    final int nbCFInit = cfe.getNumberOfPayments();
    final double multFact = Math.signum(cfe.getNthPayment(0).getAmount());
    final boolean isCall = (cfe.getNthPayment(0).getAmount() < 0);
    final double[] cftInit = new double[nbCFInit];
    final double[] cfaInit = new double[nbCFInit];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cftInit[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime();
      cfaInit[loopcf] = cfe.getNthPayment(loopcf).getAmount() * -multFact;
    }
    final double timeToExpiry = swaption.getTimeToExpiry();
    // 2. Model data
    final int nbFactor = lmmBundle.getLmmParameter().getNbFactor();
    final double[][] volLMM = lmmBundle.getLmmParameter().getVolatility();
    final double[] timeLMM = lmmBundle.getLmmParameter().getIborTime();
    // 3. Link cfe dates to lmm
    final int[] indCFDate = new int[nbCFInit];
    int indStart = nbCFInit - 1;
    int indEnd = 0;
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      indCFDate[loopcf] = Arrays.binarySearch(timeLMM, cftInit[loopcf]);
      if (indCFDate[loopcf] < 0) {
        if (timeLMM[-indCFDate[loopcf] - 1] - cftInit[loopcf] < TIME_TOLERANCE) {
          indCFDate[loopcf] = -indCFDate[loopcf] - 1;
        } else {
          if (cftInit[loopcf] - timeLMM[-indCFDate[loopcf] - 2] < TIME_TOLERANCE) {
            indCFDate[loopcf] = -indCFDate[loopcf] - 2;
          } else {
            ArgumentChecker.isTrue(true, "Instrument time incompatible with LMM");
          }
        }
      }
      if (indCFDate[loopcf] < indStart) {
        indStart = indCFDate[loopcf];
      }
      if (indCFDate[loopcf] > indEnd) {
        indEnd = indCFDate[loopcf];
      }
    }
    final int nbCF = indEnd - indStart + 1;
    final double[] cfa = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCFInit; loopcf++) {
      cfa[indCFDate[loopcf] - indStart] = cfaInit[loopcf];
    }
    final double[] cft = new double[nbCF];
    System.arraycopy(timeLMM, indStart, cft, 0, nbCF);
    final double[] dfLMM = new double[nbCF];
    for (int loopcf = 0; loopcf < nbCF; loopcf++) {
      dfLMM[loopcf] = dsc.getDiscountFactor(cft[loopcf]);
    }
    final double[][] gammaLMM = new double[nbCF - 1][nbFactor];
    final double[] deltaLMM = new double[nbCF - 1];
    System.arraycopy(lmmBundle.getLmmParameter().getAccrualFactor(), indStart, deltaLMM, 0, nbCF - 1);
    final double[] aLMM = new double[nbCF - 1];
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

   * @return The present value.
   */
  public CurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final G2ppPiecewiseConstantDataBundle g2Data) {
    ArgumentChecker.notNull(swaption, "Swaption");
    ArgumentChecker.notNull(g2Data, "G2++ data");
    final YieldAndDiscountCurve dsc = g2Data.getCurve(swaption.getUnderlyingSwap().getFixedLeg().getDiscountCurve());
    final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, g2Data);
    final double theta = swaption.getTimeToExpiry();
    final int nbCf = cfe.getNumberOfPayments();
    final double[] t = new double[nbCf];
    final double[] df = new double[nbCf];
    final double[] discountedCashFlow = new double[nbCf];
    for (int loopcf = 0; loopcf < nbCf; loopcf++) {
      t[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime();
      df[loopcf] = dsc.getDiscountFactor(cfe.getNthPayment(loopcf).getPaymentTime());
      discountedCashFlow[loopcf] = df[loopcf] * cfe.getNthPayment(loopcf).getAmount();
    }

    final double rhog2pp = g2Data.getG2ppParameter().getCorrelation();
    final double[][] htheta = MODEL_G2PP.volatilityMaturityPart(g2Data.getG2ppParameter(), theta, t);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

  @Override
  public DoubleMatrix1D pointToParameterSensitivity(final InterestRateCurveSensitivity sensitivity, final Set<String> fixedCurves, final YieldCurveBundle bundle) {
    final List<Double> result = new ArrayList<>();
    for (final String curveName : bundle.getAllNames()) {
      if (!fixedCurves.contains(curveName)) {
        final YieldAndDiscountCurve curve = bundle.getCurve(curveName);
        final List<Double> oneCurveSensitivity = pointToParameterSensitivity(sensitivity.getSensitivities().get(curveName), curve);
        result.addAll(oneCurveSensitivity);
      }
    }
    return new DoubleMatrix1D(result.toArray(new Double[result.size()]));
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

   * @return The present value.
   */
  public CurrencyAmount presentValue(final SwaptionPhysicalFixedIbor swaption, final HullWhiteOneFactorPiecewiseConstantDataBundle hwData) {
    ArgumentChecker.notNull(swaption, "Swaption");
    ArgumentChecker.notNull(hwData, "Hull-White data");
    final YieldAndDiscountCurve dsc = hwData.getCurve(swaption.getUnderlyingSwap().getFixedLeg().getDiscountCurve());
    final double expiry = swaption.getTimeToExpiry();
    final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, hwData);
    final int nbCf = cfe.getNumberOfPayments();
    final double a = hwData.getHullWhiteParameter().getMeanReversion();
    final double[] sigma = hwData.getHullWhiteParameter().getVolatility();
    final double[] s = hwData.getHullWhiteParameter().getVolatilityTime();
    final double[] cfa = new double[nbCf];
    final double[] t = new double[nbCf + 1];
    final double[] expt = new double[nbCf + 1];
    final double[] dfswap = new double[nbCf];
    final double[] p0 = new double[nbCf];
    final double[] cP = new double[nbCf];
    t[0] = expiry;
    expt[0] = Math.exp(-a * t[0]);
    for (int loopcf = 0; loopcf < nbCf; loopcf++) {
      t[loopcf + 1] = cfe.getNthPayment(loopcf).getPaymentTime();
      cfa[loopcf] = -Math.signum(cfe.getNthPayment(0).getAmount()) * cfe.getNthPayment(loopcf).getAmount();
      expt[loopcf + 1] = Math.exp(-a * t[loopcf + 1]);
      dfswap[loopcf] = dsc.getDiscountFactor(t[loopcf + 1]);
      p0[loopcf] = dfswap[loopcf] / dfswap[0];
      cP[loopcf] = cfa[loopcf] * p0[loopcf];
    }
    final double k = -cfa[0];
    double b0 = 0.0;
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

    ArgumentChecker.notNull(bundle, "Curve bundle");
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<>();
    for (final Currency ccy : sensitivity.getCurrencies()) {
      for (final String curveName : sensitivity.getSensitivity(ccy).getSensitivities().keySet()) {
        if (!fixedCurves.contains(curveName)) {
          final YieldAndDiscountCurve curve = bundle.getCurve(curveName);
          final Double[] oneCurveSensitivity = pointToParameterSensitivity(sensitivity.getSensitivity(ccy).getSensitivities().get(curveName), curve);
          result.put(new ObjectsPair<>(curveName, ccy), new DoubleMatrix1D(oneCurveSensitivity));
        }
      }
    }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.interestrate.curve.YieldAndDiscountCurve

    // Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle.
    final int[][] indexOther = new int[nbCurve][];
    // Implementation note: indexOther - the index of the underlying curves, if any.
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
      final YieldAndDiscountCurve curve = bundle.getCurve(name);
      final List<String> underlyingCurveNames = curve.getUnderlyingCurvesNames();
      nbNewParameters[loopname] = curve.getNumberOfParameters();
      final IntArrayList indexOtherList = new IntArrayList();
      for (final String u : underlyingCurveNames) {
        final Integer i = curveNum.get(u);
        if (i != null) {
          indexOtherList.add(i);
          nbNewParameters[loopname] -= nbNewParameters[i];
        }
      }
      indexOther[loopname] = indexOtherList.toIntArray();
      loopname++;
    }
    int nbSensiCurve = 0;
    for (final String name : bundle.getAllNames()) { // loop over all curves (by name)
      if (!fixedCurves.contains(name)) {
        nbSensiCurve++;
      }
    }
    final int[] nbNewParamSensiCurve = new int[nbSensiCurve];
    // Implementation note: nbNewParamSensiCurve
    final int[][] indexOtherSensiCurve = new int[nbSensiCurve][];
    // Implementation note: indexOtherSensiCurve -
    final int[] startCleanParameter = new int[nbSensiCurve];
    // Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start.
    final int[][] startDirtyParameter = new int[nbSensiCurve][];
    // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
    int nbSensitivityCurve = 0;
    int nbCleanParameters = 0;
    int currentDirtyStart = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
      if (!fixedCurves.contains(name)) {
        final int num = curveNum.get(name);
        final YieldAndDiscountCurve curve = bundle.getCurve(name);
        final IntArrayList startDirtyParameterList = new IntArrayList();
        final List<String> underlyingCurveNames = curve.getUnderlyingCurvesNames();
        for (final String u : underlyingCurveNames) {
          final Integer i = curveNum.get(u);
          if (i != null) {
            startDirtyParameterList.add(currentDirtyStart);
            currentDirtyStart += nbNewParameters[i];
          }
        }
        startDirtyParameterList.add(currentDirtyStart);
        currentDirtyStart += nbNewParameters[nbSensitivityCurve];
        startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray();
        nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num];
        indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num];
        startCleanParameter[nbSensitivityCurve] = nbCleanParameters;
        nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve];
        nbSensitivityCurve++;
      }
    }
    final DoubleArrayList sensiDirtyList = new DoubleArrayList();
    for (final String name : curveNamesSet) { // loop over all curves (by name)
      if (!fixedCurves.contains(name)) {
        final YieldAndDiscountCurve curve = bundle.getCurve(name);
        final List<Double> oneCurveSensitivity = pointToParameterSensitivity(sensitivity.getSensitivities().get(name), curve);
        sensiDirtyList.addAll(oneCurveSensitivity);
      }
    }
    final double[] sensiDirty = sensiDirtyList.toDoubleArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.