Examples of YieldAndDiscountCurve


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++;
    }
    loopname = 0;
    for (final String name : bundle.getAllNames()) { // loop over all curves (by name)
      if (!fixedCurves.contains(name)) {
        loopname++;
      }
    }
    final int nbSensitivityCurve = loopname;
    final int[] nbNewParamSensiCurve = new int[nbSensitivityCurve];
    // Implementation note: nbNewParamSensiCurve
    final int[][] indexOtherSensiCurve = new int[nbSensitivityCurve][];
    // Implementation note: indexOtherSensiCurve -
    // int[] startCleanParameter = new int[nbSensitivityCurve];
    // 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[nbSensitivityCurve][];
    // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
    //int nbCleanParameters = 0;
    int currentDirtyStart = 0;
    loopname = 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[loopname];
        startDirtyParameter[loopname] = startDirtyParameterList.toIntArray();
        nbNewParamSensiCurve[loopname] = nbNewParameters[num];
        indexOtherSensiCurve[loopname] = indexOther[num];
        // startCleanParameter[loopname] = nbCleanParameters;
        //nbCleanParameters += nbNewParamSensiCurve[loopname];
        loopname++;
      }
    }
    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 Double[] oneCurveSensitivity = pointToParameterSensitivity(sensitivity.getSensitivities().get(name), curve);
        sensiDirtyList.addAll(Arrays.asList(oneCurveSensitivity));
      }
    }
    final double[] sensiDirty = sensiDirtyList.toDoubleArray();
View Full Code Here

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

   * @return The price.
   */
  public double price(final InterestRateFutureSecurity future, final YieldCurveBundle curves) {
    Validate.notNull(future, "Future");
    Validate.notNull(curves, "Curves");
    final YieldAndDiscountCurve forwardCurve = curves.getCurve(future.getForwardCurveName());
    final double forward = (forwardCurve.getDiscountFactor(future.getFixingPeriodStartTime()) / forwardCurve.getDiscountFactor(future.getFixingPeriodEndTime()) - 1)
        / future.getFixingPeriodAccrualFactor();
    final double price = 1.0 - forward;
    return price;
  }
View Full Code Here

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

   */
  @Override
  public InterestRateCurveSensitivity priceCurveSensitivity(final InterestRateFutureSecurity future, final YieldCurveBundle curves) {
    Validate.notNull(future, "Future");
    Validate.notNull(curves, "Curves");
    final YieldAndDiscountCurve forwardCurve = curves.getCurve(future.getForwardCurveName());
    final double dfForwardStart = forwardCurve.getDiscountFactor(future.getFixingPeriodStartTime());
    final double dfForwardEnd = forwardCurve.getDiscountFactor(future.getFixingPeriodEndTime());
    // Partials - XBar => d(price)/dX
    final double priceBar = 1.0;
    final double forwardBar = -priceBar;
    final double dfForwardEndBar = -dfForwardStart / (dfForwardEnd * dfForwardEnd) / future.getFixingPeriodAccrualFactor() * forwardBar;
    final double dfForwardStartBar = 1.0 / (future.getFixingPeriodAccrualFactor() * dfForwardEnd) * forwardBar;
 
View Full Code Here

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

   * @return The rate.
   */
  public double parRate(final InterestRateFutureSecurity future, final YieldCurveBundle curves) {
    Validate.notNull(future, "Future");
    Validate.notNull(curves, "Curves");
    final YieldAndDiscountCurve forwardCurve = curves.getCurve(future.getForwardCurveName());
    final double forward = (forwardCurve.getDiscountFactor(future.getFixingPeriodStartTime()) / forwardCurve.getDiscountFactor(future.getFixingPeriodEndTime()) - 1)
        / future.getFixingPeriodAccrualFactor();
    return forward;
  }
View Full Code Here

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

   */
  public InterestRateCurveSensitivity parRateCurveSensitivity(final InterestRateFutureSecurity future, final YieldCurveBundle curves) {
    Validate.notNull(future, "Future");
    Validate.notNull(curves, "Curves");
    final String curveName = future.getForwardCurveName();
    final YieldAndDiscountCurve curve = curves.getCurve(curveName);
    final double ta = future.getFixingPeriodStartTime();
    final double tb = future.getFixingPeriodEndTime();
    final double ratio = curve.getDiscountFactor(ta) / curve.getDiscountFactor(tb) / future.getFixingPeriodAccrualFactor();
    final DoublesPair s1 = new DoublesPair(ta, -ta * ratio);
    final DoublesPair s2 = new DoublesPair(tb, tb * ratio);
    final List<DoublesPair> temp = new ArrayList<>();
    temp.add(s1);
    temp.add(s2);
View Full Code Here

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

    int index = 0;
    for (final String name : names) {
      final GeneratorYDCurve gen = _curveGenerators.get(name);
      final double[] paramCurve = Arrays.copyOfRange(x.getData(), index, index + gen.getNumberOfParameter());
      index += gen.getNumberOfParameter();
      final YieldAndDiscountCurve newCurve = gen.generateCurve(name, bundle, paramCurve);
      bundle.setCurve(name, newCurve);
    }
    return bundle;
  }
View Full Code Here

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

  }

  public InterestRateCurveSensitivity visitCoupon(final Coupon coupon, final YieldCurveBundle curves) {
    Validate.notNull(curves);
    Validate.notNull(coupon);
    final YieldAndDiscountCurve fundingCurve = curves.getCurve(coupon.getFundingCurveName());
    final double df = fundingCurve.getDiscountFactor(coupon.getPaymentTime());
    // Backward sweep
    final double pvbpBar = 1.0;
    final double dfBar = coupon.getPaymentYearFraction() * coupon.getNotional() * pvbpBar;
    final Map<String, List<DoublesPair>> resultMapDsc = new HashMap<>();
    final List<DoublesPair> listDiscounting = new ArrayList<>();
View Full Code Here

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

   * @deprecated Curve builders that use and populate {@link YieldCurveBundle}s are deprecated.
   */
  @Deprecated
  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final YieldCurveBundle bundle, final double[] parameters) {
    final YieldAndDiscountCurve existingCurve = bundle.getCurve(_existingCurveName);
    final YieldAndDiscountCurve newCurve = _generator.generateCurve(name + "-0", bundle, parameters);
    return new YieldAndDiscountAddZeroSpreadCurve(name, _substract, existingCurve, newCurve);
  }
View Full Code Here

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

  }

  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final MulticurveProviderInterface multicurve, final double[] parameters) {
    if (multicurve instanceof MulticurveProviderDiscount) { // TODO: improve the way the curves are generated
      final YieldAndDiscountCurve existingCurve = ((MulticurveProviderDiscount) multicurve).getCurve(_existingCurveName);
      final YieldAndDiscountCurve newCurve = _generator.generateCurve(name + "-0", multicurve, parameters);
      return new YieldAndDiscountAddZeroSpreadCurve(name, _substract, existingCurve, newCurve);

    }
    throw new UnsupportedOperationException("Cannot generate curves for a GeneratorCurveAddYieldExisiting");
  }
View Full Code Here

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

    return _generator.getNumberOfParameter();
  }

  @Override
  public YieldAndDiscountCurve generateCurve(final String name, final double[] parameters) {
    final YieldAndDiscountCurve newCurve = _generator.generateCurve(name + "-0", parameters);
    return new YieldAndDiscountAddZeroFixedCurve(name, _substract, newCurve, _fixedCurve);
  }
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.