Package com.opengamma.analytics.financial.interestrate.cash.derivative

Examples of com.opengamma.analytics.financial.interestrate.cash.derivative.Cash


        final Tenor tenor = strip.getCurveNodePointTime();
        final ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate(spotDate, tenor.getPeriod(), MOD_FOL, calendar, true);
        final double startTime = TimeCalculator.getTimeBetween(now, spotDate);
        final double endTime = TimeCalculator.getTimeBetween(now, paymentDate);
        final double accrualFactor = dayCount.getDayCountFraction(now, now.plus(tenor.getPeriod()), calendar);
        final Cash cashFXCurve = new Cash(_currency, startTime, endTime, 1, 0, accrualFactor, fullYieldCurveName);
        final double parRate = METHOD_CASH.parRate(cashFXCurve, curves);
        final Cash cashDepositCurve = new Cash(_currency, startTime, endTime, 1, 0, accrualFactor, impliedDepositCurveName);
        derivatives.add(cashDepositCurve);
        t[i] = endTime;
        r[i++] = parRate;
      }
      final CombinedInterpolatorExtrapolator interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(_interpolatorName, _leftExtrapolatorName,
View Full Code Here


  /**
   * Tests parSpread when the present is before the deposit start date.
   */
  public void parSpreadBeforeStart() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final double parSpread = METHOD_DEPOSIT.parSpread(deposit, CURVES);
    final CashDefinition deposit0Definition = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE + parSpread, DEPOSIT_AF);
    final Cash deposit0 = deposit0Definition.toDerivative(referenceDate, CURVES_NAME[0]);
    final CurrencyAmount pv0 = METHOD_DEPOSIT.presentValue(deposit0, CURVES);
    assertEquals("DepositDefinition: par spread", 0, pv0.getAmount(), TOLERANCE_PRICE);
  }
View Full Code Here

  /**
   * Tests parSpread when the present date is on the start date.
   */
  public void parSpreadOnStart() {
    final ZonedDateTime referenceDate = DEPOSIT_DEFINITION.getStartDate();
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final double parSpread = METHOD_DEPOSIT.parSpread(deposit, CURVES);
    final CashDefinition deposit0Definition = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE + parSpread, DEPOSIT_AF);
    final Cash deposit0 = deposit0Definition.toDerivative(referenceDate, CURVES_NAME[0]);
    final CurrencyAmount pv0 = METHOD_DEPOSIT.presentValue(deposit0, CURVES);
    assertEquals("DepositDefinition: present value", 0, pv0.getAmount(), TOLERANCE_PRICE);
  }
View Full Code Here

  /**
   * Tests parSpread when the present date is after the start: .
   */
  public void parSpreadAfterStart() {
    final ZonedDateTime referenceDate = ScheduleCalculator.getAdjustedDate(DEPOSIT_DEFINITION.getStartDate(), 1, TARGET);
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final double parSpread = METHOD_DEPOSIT.parSpread(deposit, CURVES); // Spread will be -(1/delta+rate), as there is no initial amount
    final CashDefinition deposit0Definition = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE + parSpread, DEPOSIT_AF);
    final Cash deposit0 = deposit0Definition.toDerivative(referenceDate, CURVES_NAME[0]);
    final CurrencyAmount pv0 = METHOD_DEPOSIT.presentValue(deposit0, CURVES);
    assertEquals("DepositDefinition: present value", 0, pv0.getAmount(), TOLERANCE_PRICE);
  }
View Full Code Here

  /**
   * Tests parSpread.
   */
  public void parSpreadMethodVsCalculator() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final double parSpreadMethod = METHOD_DEPOSIT.parSpread(deposit, CURVES);
    final double parSpreadCalculator = deposit.accept(PSC, CURVES);
    assertEquals("DepositDefinition: present value", parSpreadMethod, parSpreadCalculator, TOLERANCE_SPREAD);
  }
View Full Code Here

  /**
   * Tests parSpread curve sensitivity.
   */
  public void parSpreadCurveSensitivity() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final InterestRateCurveSensitivity pscsMethod = METHOD_DEPOSIT.parSpreadCurveSensitivity(deposit, CURVES);
    final List<DoublesPair> sensiPvDisc = pscsMethod.getSensitivities().get(CURVES_NAME[0]);
    final double ps = METHOD_DEPOSIT.parSpread(deposit, CURVES);
    final YieldAndDiscountCurve curveToBump = CURVES.getCurve(CURVES_NAME[0]);
    final double deltaShift = 0.0001;
    final int nbNode = 2;
    final double[] result = new double[nbNode];
    final double[] nodeTimesExtended = new double[nbNode + 1];
    nodeTimesExtended[1] = deposit.getStartTime();
    nodeTimesExtended[2] = deposit.getEndTime();
    final double[] yields = new double[nbNode + 1];
    yields[0] = curveToBump.getInterestRate(0.0);
    yields[1] = curveToBump.getInterestRate(nodeTimesExtended[1]);
    yields[2] = curveToBump.getInterestRate(nodeTimesExtended[2]);
    final YieldAndDiscountCurve curveNode = YieldCurve.from(InterpolatedDoublesCurve.fromSorted(nodeTimesExtended, yields, new LinearInterpolator1D()));
    for (int loopnode = 0; loopnode < nbNode; loopnode++) {
      final YieldAndDiscountCurve curveBumped = curveNode.withSingleShift(nodeTimesExtended[loopnode + 1], deltaShift);
      CURVES.replaceCurve(CURVES_NAME[0], curveBumped);
      final double psBumped = METHOD_DEPOSIT.parSpread(deposit, CURVES);
      result[loopnode] = (psBumped - ps) / deltaShift;
      final DoublesPair pairPv = sensiPvDisc.get(loopnode);
      assertEquals("Sensitivity par spread to curve: Node " + loopnode, nodeTimesExtended[loopnode + 1], pairPv.getFirst(), TOLERANCE_TIME);
      assertEquals("Sensitivity par spread to curve: Node", pairPv.second, result[loopnode], TOLERANCE_PRICE);
    }
    CURVES.replaceCurve(CURVES_NAME[0], curveToBump);
    InterestRateCurveSensitivity prcsCalculator = deposit.accept(PSCSC, CURVES);
    prcsCalculator = prcsCalculator.cleaned(0.0, 1.0E-4);
    AssertSensivityObjects.assertEquals("DepositZero: par rate curve sensitivity", pscsMethod, prcsCalculator, TOLERANCE_SPREAD_DELTA);
  }
View Full Code Here

  /**
   * Tests today payment amount when the present is before the deposit start date.
   */
  public void todayPaymentBeforeStart() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final MultipleCurrencyAmount cash = deposit.accept(TPC);
    assertEquals("DepositDefinition: today payment", 0.0, cash.getAmount(deposit.getCurrency()), TOLERANCE_PRICE);
    assertEquals("DepositDefinition: today payment", 1, cash.getCurrencyAmounts().length);
  }
View Full Code Here

  /**
   * Tests today payment amount when the present is on the deposit start date.
   */
  public void todayPaymentOnStart() {
    final ZonedDateTime referenceDate = SPOT_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final MultipleCurrencyAmount cash = deposit.accept(TPC);
    assertEquals("DepositDefinition: today payment", -NOTIONAL, cash.getAmount(deposit.getCurrency()), TOLERANCE_PRICE);
    assertEquals("DepositDefinition: today payment", 1, cash.getCurrencyAmounts().length);
  }
View Full Code Here

  /**
   * Tests today payment amount when the present is on the deposit start date.
   */
  public void todayPaymentBetweenStartAndEnd() {
    final ZonedDateTime referenceDate = SPOT_DATE.plusDays(2);
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final MultipleCurrencyAmount cash = deposit.accept(TPC);
    assertEquals("DepositDefinition: today payment", 0.0, cash.getAmount(deposit.getCurrency()), TOLERANCE_PRICE);
    assertEquals("DepositDefinition: today payment", 1, cash.getCurrencyAmounts().length);
  }
View Full Code Here

  /**
   * Tests today payment amount when the present is on the deposit end date.
   */
  public void todayPaymentOnEnd() {
    final ZonedDateTime referenceDate = END_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final MultipleCurrencyAmount cash = deposit.accept(TPC);
    assertEquals("DepositDefinition: today payment", NOTIONAL + deposit.getInterestAmount(), cash.getAmount(deposit.getCurrency()), TOLERANCE_PRICE);
    assertEquals("DepositDefinition: today payment", 1, cash.getCurrencyAmounts().length);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.interestrate.cash.derivative.Cash

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.