Package com.opengamma.analytics.financial.model.interestrate.definition

Examples of com.opengamma.analytics.financial.model.interestrate.definition.G2ppPiecewiseConstantParameters


   * @param g2Data The G2++ data (curves and G2++ parameters).
   * @return The present value.
   */
  public MultipleCurrencyAmount presentValue(final InstrumentDerivative instrument, final Currency ccy, final G2ppProviderInterface g2Data) {
    MulticurveProviderInterface multicurves = g2Data.getMulticurveProvider();
    G2ppPiecewiseConstantParameters parameters = g2Data.getG2ppParameters();
    final DecisionSchedule decision = instrument.accept(DC, multicurves);
    final double[] decisionTime = decision.getDecisionTime();
    final double[][] impactTime = decision.getImpactTime();
    final int nbJump = decisionTime.length;
    final double numeraireTime = decisionTime[nbJump - 1];
    final double pDN = multicurves.getDiscountFactor(ccy, numeraireTime);
    // Discount factor to numeraire date for rebasing.
    final double[][] pDI = new double[nbJump][];
    // Initial discount factors to each impact date.
    for (int loopjump = 0; loopjump < nbJump; loopjump++) {
      pDI[loopjump] = new double[impactTime[loopjump].length];
      for (int i = 0; i < impactTime[loopjump].length; i++) {
        pDI[loopjump][i] = multicurves.getDiscountFactor(ccy, impactTime[loopjump][i]) / pDN;
      }
    }
    final double rhog2pp = parameters.getCorrelation();
    final double[][][] h = MODEL.volatilityMaturityPart(parameters, numeraireTime, impactTime); // factor/jump/cf
    final double[][][] gamma = new double[nbJump][2][2]; // jump/factor/factor
    final double[][] cov = new double[2 * nbJump][2 * nbJump]; // factor 0 - factor 1
    for (int loopjump = 0; loopjump < nbJump; loopjump++) {
      gamma[loopjump] = MODEL.gamma(parameters, 0.0, decisionTime[loopjump]);
View Full Code Here


    ArgumentChecker.notNull(cmsSpread, "CMS spread");
    ArgumentChecker.notNull(g2Data, "Yield curves and G2++ parameters");
    final Currency ccy = cmsSpread.getCurrency();
    ArgumentChecker.isTrue(g2Data.getG2ppCurrency().equals(ccy), "CMS spread currency incompatible with data");
    final MulticurveProviderInterface multicurves = g2Data.getMulticurveProvider();
    final G2ppPiecewiseConstantParameters parameters = g2Data.getG2ppParameters();
    final double strike = cmsSpread.getStrike();
    final double theta = cmsSpread.getFixingTime();
    final double tp = cmsSpread.getPaymentTime();
    final double dftp = multicurves.getDiscountFactor(ccy, tp);
    final int[] nbCfFixed = new int[] {cmsSpread.getUnderlyingSwap1().getFixedLeg().getNumberOfPayments(), cmsSpread.getUnderlyingSwap2().getFixedLeg().getNumberOfPayments()};
View Full Code Here

   */
  public void calibration() {
    final double[] meanReversion = new double[] {0.01, 0.30 };
    final double ratio = 4.0;
    final double correlation = -0.50;
    final G2ppPiecewiseConstantParameters g2Parameters = new G2ppPiecewiseConstantParameters(meanReversion, new double[][] { {0.01 }, {0.01 / ratio } }, new double[0], correlation);
    final SuccessiveRootFinderG2ppCalibrationObjective objective = new SuccessiveRootFinderG2ppCalibrationObjective(g2Parameters, EUR, ratio);
    final SuccessiveRootFinderG2ppCalibrationEngine<SABRSwaptionProviderInterface> calibrationEngine = new SuccessiveRootFinderG2ppCalibrationEngine<>(objective);

    for (int loopexp = 0; loopexp < EXPIRY_TENOR.length; loopexp++) {
      calibrationEngine.addInstrument(SWAPTION_LONG_PAYER[loopexp], PVSSC);
View Full Code Here

    final int nbTest = 100;
    final MultipleCurrencyAmount[] pv = new MultipleCurrencyAmount[nbTest];

    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      final G2ppPiecewiseConstantParameters g2Parameters = new G2ppPiecewiseConstantParameters(meanReversion, new double[][] { {0.01 }, {0.01 / ratio } }, new double[0], correlation);
      final SuccessiveRootFinderG2ppCalibrationObjective objective = new SuccessiveRootFinderG2ppCalibrationObjective(g2Parameters, EUR, ratio);
      final SuccessiveRootFinderG2ppCalibrationEngine<SABRSwaptionProviderInterface> calibrationEngine = new SuccessiveRootFinderG2ppCalibrationEngine<>(objective);
      for (int loopexp = 0; loopexp < EXPIRY_TENOR.length; loopexp++) {
        calibrationEngine.addInstrument(SWAPTION_LONG_PAYER[loopexp], PVSSC);
      }
View Full Code Here

  /**
   * Test the present value by approximation vs by numerical integration for a grid of expiry/tenor.
   * To check the precision, increase the NB_INTEGRATION to 50 (slower but more precise).
   */
  public void approximationNumericalIntegrationGrid() {
    final G2ppPiecewiseConstantParameters parametersG2pp = TestsDataSetG2pp.createG2ppParameters3();
    final G2ppProviderDiscount bundleG2pp = new G2ppProviderDiscount(MULTICURVES, parametersG2pp, CUR);
    final GeneratorSwapFixedIbor generator = GENERATOR_SWAP_MASTER.getGenerator("EUR1YEURIBOR6M", CALENDAR);
    final Period[] expiry = new Period[] {Period.ofMonths(6), Period.ofYears(1), Period.ofYears(2), Period.ofYears(5), Period.ofYears(10), Period.ofYears(25)};
    final int nbExpiry = expiry.length;
    final Period[] tenor = new Period[] {Period.ofYears(2), Period.ofYears(5), Period.ofYears(10), Period.ofYears(25)};
View Full Code Here

      final double[] times = new double[n];
      for (int i = 0; i < n; i++) {
        times[i] = (Double) timeFields.get(i).getValue();
      }
      final double correlation = message.getDouble(CORRELATION_FIELD);
      return new G2ppPiecewiseConstantParameters(meanReversion, volatilities, times, correlation);
    }
View Full Code Here

    assertEquals(parameters, cycleObject(HullWhiteOneFactorPiecewiseConstantParameters.class, parameters));
  }

  @Test
  public void testG2ppParameters() {
    final G2ppPiecewiseConstantParameters parameters = new G2ppPiecewiseConstantParameters(new double[] {0.02, 0.01},
        new double[][] {new double[] {0.03, 0.04, 0.05}, new double[] {0.06, 0.07, 0.08}}, new double[] {1, 2}, 0.9);
    assertEquals(parameters, cycleObject(G2ppPiecewiseConstantParameters.class, parameters));
  }
View Full Code Here

    final double[][] vol01 = new double[][] { {0.00 }, {0.01 } };
    final double expiryTime = 1.0;
    final double u = 1.02;
    final double v = 1.27;
    final HullWhiteOneFactorPiecewiseConstantParameters hw10 = new HullWhiteOneFactorPiecewiseConstantParameters(MEAN_REVERSION[0], vol10[0], volTime);
    final G2ppPiecewiseConstantParameters g2pp10 = new G2ppPiecewiseConstantParameters(MEAN_REVERSION, vol10, volTime, CORRELATION);
    final double adjHW10 = MODEL_HW.futuresConvexityFactor(hw10, expiryTime, u, v);
    final double adjG210 = MODEL_G2PP.futuresConvexityFactor(g2pp10, expiryTime, u, v);
    assertEquals("G2++: swap rate", adjHW10, adjG210, TOLERANCE_FACTOR);
    final HullWhiteOneFactorPiecewiseConstantParameters hw01 = new HullWhiteOneFactorPiecewiseConstantParameters(MEAN_REVERSION[1], vol01[1], volTime);
    final G2ppPiecewiseConstantParameters g2pp01 = new G2ppPiecewiseConstantParameters(MEAN_REVERSION, vol01, volTime, CORRELATION);
    final double adjHW01 = MODEL_HW.futuresConvexityFactor(hw01, expiryTime, u, v);
    final double adjG201 = MODEL_G2PP.futuresConvexityFactor(g2pp01, expiryTime, u, v);
    assertEquals("G2++: swap rate", adjHW01, adjG201, TOLERANCE_FACTOR);
    // TODO: full two-factor test
  }
View Full Code Here

   */
  public void calibration() {
    final double[] meanReversion = new double[] {0.01, 0.30};
    final double ratio = 4.0;
    final double correlation = -0.50;
    final G2ppPiecewiseConstantParameters g2Parameters = new G2ppPiecewiseConstantParameters(meanReversion, new double[][] { {0.01}, {0.01 / ratio}}, new double[0], correlation);
    final SwaptionPhysicalG2ppCalibrationObjective objective = new SwaptionPhysicalG2ppCalibrationObjective(g2Parameters, ratio);
    final SuccessiveRootFinderCalibrationEngine calibrationEngine = new SwaptionPhysicalG2ppSuccessiveRootFinderCalibrationEngine(objective);
    for (int loopexp = 0; loopexp < EXPIRY_TENOR.length; loopexp++) {
      calibrationEngine.addInstrument(SWAPTION_LONG_PAYER[loopexp], METHOD_SABR);
    }
View Full Code Here

    final int nbTest = 100;
    final CurrencyAmount[] pv = new CurrencyAmount[nbTest];

    startTime = System.currentTimeMillis();
    for (int looptest = 0; looptest < nbTest; looptest++) {
      final G2ppPiecewiseConstantParameters g2Parameters = new G2ppPiecewiseConstantParameters(meanReversion, new double[][] { {0.01}, {0.01 / ratio}}, new double[0], correlation);
      final SwaptionPhysicalG2ppCalibrationObjective objective = new SwaptionPhysicalG2ppCalibrationObjective(g2Parameters, ratio);
      final SuccessiveRootFinderCalibrationEngine calibrationEngine = new SwaptionPhysicalG2ppSuccessiveRootFinderCalibrationEngine(objective);
      for (int loopexp = 0; loopexp < EXPIRY_TENOR.length; loopexp++) {
        calibrationEngine.addInstrument(SWAPTION_LONG_PAYER[loopexp], METHOD_SABR);
      }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.interestrate.definition.G2ppPiecewiseConstantParameters

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.