Package com.opengamma.analytics.financial.provider.description.interestrate

Examples of com.opengamma.analytics.financial.provider.description.interestrate.MulticurveProviderDiscount


    return (MulticurveProviderDiscount) super.getMulticurveProvider();
  }

  @Override
  public BlackForexSmileProviderDiscount copy() {
    MulticurveProviderDiscount multicurveProvider = getMulticurveProvider().copy();
    return new BlackForexSmileProviderDiscount(multicurveProvider, getVolatility(), getCurrencyPair());
  }
View Full Code Here


      final double[] sensitivity = new double[nbNodePoint];
      for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
        final double[] yieldBumpedPlus = curveInt.getYDataAsPrimitive().clone();
        yieldBumpedPlus[loopnode] += _shift;
        final YieldAndDiscountCurve dscBumpedPlus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedPlus, curveInt.getInterpolator(), true));
        final MulticurveProviderDiscount marketDscBumpedPlus = multicurve.withDiscountFactor(ccy, dscBumpedPlus);
        final Double valueBumpedPlus = instrument.accept(_valueCalculator, marketDscBumpedPlus);
        final double[] yieldBumpedMinus = curveInt.getYDataAsPrimitive().clone();
        yieldBumpedMinus[loopnode] -= _shift;
        final YieldAndDiscountCurve dscBumpedMinus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedMinus,
            curveInt.getInterpolator(), true));
        final MulticurveProviderDiscount marketDscBumpedMinus = multicurve.withDiscountFactor(ccy, dscBumpedMinus);
        final Double valueBumpedMinus = instrument.accept(_valueCalculator, marketDscBumpedMinus);
        final Double valueDiff = valueBumpedPlus - valueBumpedMinus;
        sensitivity[loopnode] = valueDiff / (2 * _shift);
      }
      final String name = multicurve.getName(ccy);
      result = result.plus(name, new DoubleMatrix1D(sensitivity));
    }
    // Forward ON
    final Set<IndexON> indexON = multicurve.getIndexesON();
    for (final IndexON index : indexON) {
      final YieldAndDiscountCurve curve = multicurve.getCurve(index);
      ArgumentChecker.isTrue(curve instanceof YieldCurve, "Curve should be a YieldCurve");
      final YieldCurve curveYield = (YieldCurve) curve;
      ArgumentChecker.isTrue(curveYield.getCurve() instanceof InterpolatedDoublesCurve, "Yield curve should be based on InterpolatedDoublesCurve");
      final InterpolatedDoublesCurve curveInt = (InterpolatedDoublesCurve) curveYield.getCurve();
      final int nbNodePoint = curveInt.getXDataAsPrimitive().length;
      final double[] sensitivity = new double[nbNodePoint];
      for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
        final double[] yieldBumpedPlus = curveInt.getYDataAsPrimitive().clone();
        yieldBumpedPlus[loopnode] += _shift;
        final YieldAndDiscountCurve fwdBumpedPlus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedPlus, curveInt.getInterpolator(), true));
        final MulticurveProviderDiscount marketFwdBumpedPlus = multicurve.withForward(index, fwdBumpedPlus);
        final Double valueBumpedPlus = instrument.accept(_valueCalculator, marketFwdBumpedPlus);
        final double[] yieldBumpedMinus = curveInt.getYDataAsPrimitive().clone();
        yieldBumpedMinus[loopnode] -= _shift;
        final YieldAndDiscountCurve fwdBumpedMinus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedMinus,
            curveInt.getInterpolator(), true));
        final MulticurveProviderDiscount marketFwdBumpedMinus = multicurve.withForward(index, fwdBumpedMinus);
        final Double valueBumpedMinus = instrument.accept(_valueCalculator, marketFwdBumpedMinus);
        final Double valueDiff = valueBumpedPlus - valueBumpedMinus;
        sensitivity[loopnode] = valueDiff / (2 * _shift);
      }
      final String name = multicurve.getName(index);
      result = result.plus(name, new DoubleMatrix1D(sensitivity));
    }
    // Forward Ibor - symmetrical
    final Set<IborIndex> indexForward = multicurve.getIndexesIbor();
    for (final IborIndex index : indexForward) {
      final YieldAndDiscountCurve curve = multicurve.getCurve(index);
      ArgumentChecker.isTrue(curve instanceof YieldCurve, "Curve should be a YieldCurve");
      final YieldCurve curveYield = (YieldCurve) curve;
      ArgumentChecker.isTrue(curveYield.getCurve() instanceof InterpolatedDoublesCurve, "Yield curve should be based on InterpolatedDoublesCurve");
      final InterpolatedDoublesCurve curveInt = (InterpolatedDoublesCurve) curveYield.getCurve();
      final int nbNodePoint = curveInt.getXDataAsPrimitive().length;
      final double[] sensitivity = new double[nbNodePoint];
      for (int loopnode = 0; loopnode < nbNodePoint; loopnode++) {
        final double[] yieldBumpedPlus = curveInt.getYDataAsPrimitive().clone();
        yieldBumpedPlus[loopnode] += _shift;
        final YieldAndDiscountCurve fwdBumpedPlus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedPlus, curveInt.getInterpolator(), true));
        final MulticurveProviderDiscount marketFwdBumpedPlus = multicurve.withForward(index, fwdBumpedPlus);
        final Double valueBumpedPlus = instrument.accept(_valueCalculator, marketFwdBumpedPlus);
        final double[] yieldBumpedMinus = curveInt.getYDataAsPrimitive().clone();
        yieldBumpedMinus[loopnode] -= _shift;
        final YieldAndDiscountCurve fwdBumpedMinus = new YieldCurve(curveInt.getName(), new InterpolatedDoublesCurve(curveInt.getXDataAsPrimitive(), yieldBumpedMinus,
            curveInt.getInterpolator(), true));
        final MulticurveProviderDiscount marketFwdBumpedMinus = multicurve.withForward(index, fwdBumpedMinus);
        final Double valueBumpedMinus = instrument.accept(_valueCalculator, marketFwdBumpedMinus);
        final Double valueDiff = valueBumpedPlus - valueBumpedMinus;
        sensitivity[loopnode] = valueDiff / (2 * _shift);
      }
      final String name = multicurve.getName(index);
View Full Code Here

    return _generatorsMap.keySet();
  }

  @Override
  public MulticurveProviderDiscount evaluate(DoubleMatrix1D x) {
    MulticurveProviderDiscount provider = _knownData.copy();
    Set<String> nameSet = _generatorsMap.keySet();
    int indexParam = 0;
    for (String name : nameSet) {
      GeneratorYDCurve gen = _generatorsMap.get(name);
      double[] paramCurve = Arrays.copyOfRange(x.getData(), indexParam, indexParam + gen.getNumberOfParameter());
      indexParam += gen.getNumberOfParameter();
      YieldAndDiscountCurve curve = gen.generateCurve(name, provider, paramCurve);
      if (_discountingMap.containsKey(name)) {
        provider.setCurve(_discountingMap.get(name), curve);
      }
      if (_forwardIborMap.containsKey(name)) {
        IborIndex[] indexes = _forwardIborMap.get(name);
        for (int loopindex = 0; loopindex < indexes.length; loopindex++) {
          provider.setCurve(indexes[loopindex], curve);
        }
      }
      if (_forwardONMap.containsKey(name)) {
        IndexON[] indexes = _forwardONMap.get(name);
        for (int loopindex = 0; loopindex < indexes.length; loopindex++) {
          provider.setCurve(indexes[loopindex], curve);
        }
      }
      // TODO: Do we need to check that the curve is used at least once?
    }
    return provider;
View Full Code Here

    _data = data;
  }

  @Override
  public DoubleMatrix2D evaluate(final DoubleMatrix1D x) {
    final MulticurveProviderDiscount bundle = _data.getKnownData().copy();
    final MulticurveProviderDiscount newCurves = _data.getGeneratorMarket().evaluate(x);
    bundle.setAll(newCurves);
    final Set<String> curvesSet = _data.getGeneratorMarket().getCurvesList();
    final int nbParameters = _data.getNumberOfInstruments();
    final double[][] res = new double[nbParameters][nbParameters];
    for (int loopinstrument = 0; loopinstrument < _data.getNumberOfInstruments(); loopinstrument++) {
View Full Code Here

  /**
   * Constructs an empty multi-curve provider and price index curve map.
   */
  public InflationProviderDiscount() {
    _multicurveProvider = new MulticurveProviderDiscount();
    _priceIndexCurves = new LinkedHashMap<>();
    setInflationCurves();
  }
View Full Code Here

  /**
   * Constructor with empty maps for discounting, forward and price index curves.
   * @param fxMatrix The FXMatrix, not null
   */
  public InflationProviderDiscount(final FXMatrix fxMatrix) {
    _multicurveProvider = new MulticurveProviderDiscount(fxMatrix);
    _priceIndexCurves = new LinkedHashMap<>();
    setInflationCurves();
  }
View Full Code Here

   */
  //TODO there is no guarantee that the maps are LinkedHashMaps, which could lead to unexpected behaviour
  public InflationProviderDiscount(final Map<Currency, YieldAndDiscountCurve> discountingCurves, final Map<IborIndex, YieldAndDiscountCurve> forwardIborCurves,
      final Map<IndexON, YieldAndDiscountCurve> forwardONCurves, final Map<IndexPrice, PriceIndexCurve> priceIndexCurves, final FXMatrix fxMatrix) {
    ArgumentChecker.notNull(priceIndexCurves, "price index curve");
    _multicurveProvider = new MulticurveProviderDiscount(discountingCurves, forwardIborCurves, forwardONCurves, fxMatrix);
    _priceIndexCurves = priceIndexCurves;
    setInflationCurves();
  }
View Full Code Here

   * @param forwardONCurves A map with one (forward) curve by ON index, not null
   * @param fxMatrix The FXMatrix.
   */
  public InflationProviderDiscount(final Map<Currency, YieldAndDiscountCurve> discountingCurves, final Map<IborIndex, YieldAndDiscountCurve> forwardIborCurves,
      final Map<IndexON, YieldAndDiscountCurve> forwardONCurves, final FXMatrix fxMatrix) {
    _multicurveProvider = new MulticurveProviderDiscount(discountingCurves, forwardIborCurves, forwardONCurves, fxMatrix);
    _priceIndexCurves = new LinkedHashMap<>();
    setInflationCurves();
  }
View Full Code Here

    }
  }

  @Override
  public InflationProviderDiscount copy() {
    final MulticurveProviderDiscount multicurveProvider = _multicurveProvider.copy();
    final LinkedHashMap<IndexPrice, PriceIndexCurve> priceIndexCurves = new LinkedHashMap<>(_priceIndexCurves);
    return new InflationProviderDiscount(multicurveProvider, priceIndexCurves);
  }
View Full Code Here

    return _multicurveProvider.getFxRates();
  }

  @Override
  public InflationProviderDiscount withDiscountFactor(final Currency ccy, final YieldAndDiscountCurve replacement) {
    final MulticurveProviderDiscount decoratedMulticurve = _multicurveProvider.withDiscountFactor(ccy, replacement);
    return new InflationProviderDiscount(decoratedMulticurve, _priceIndexCurves);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.provider.description.interestrate.MulticurveProviderDiscount

Copyright © 2018 www.massapicom. 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.