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

Examples of com.opengamma.analytics.financial.interestrate.cash.derivative.Cash.accept()


    final double tradeTime = 2.0 / 365.0;
    final double yearFrac = 5.0 / 360.0;
    final double dfa = curve.getDiscountFactor(tradeTime);
    r = 1 / yearFrac * (dfa / df - 1);
    cash = new Cash(CUR, tradeTime, t, 1, r, yearFrac, FIVE_PC_CURVE_NAME);
    sense = cash.accept(PVSC, CURVES);
    temp = sense.get(FIVE_PC_CURVE_NAME);
    for (final DoublesPair pair : temp) {
      if (Double.compare(pair.getFirst(), tradeTime) == 0) {
        assertEquals(dfa * tradeTime, pair.getSecond(), 1e-12);
      } else if (Double.compare(pair.getFirst(), t) == 0) {
View Full Code Here


    final double yearFrac = 5.0 / 360.0;
    final Cash cash = new Cash(CUR, tradeTime, t, 1, r, yearFrac, FIVE_PC_CURVE_NAME);
    final Cash cashUp = new Cash(CUR, tradeTime, t, 1, r + DELTA, yearFrac, FIVE_PC_CURVE_NAME);
    final Cash cashDown = new Cash(CUR, tradeTime, t, 1, r - DELTA, yearFrac, FIVE_PC_CURVE_NAME);
    final double pvUp = cashUp.accept(PVC, CURVES);
    final double pvDown = cashDown.accept(PVC, CURVES);
    final double temp = (pvUp - pvDown) / 2 / DELTA;
    cash.accept(PVCSC, CURVES);

    assertEquals(temp, cash.accept(PVCSC, CURVES), 1e-10);
  }
View Full Code Here

  @Test
  public void testCash() {
    final double t = 7 / 365.0;
    final Cash cash = new Cash(CUR, 1 / 365.0, t, 100, 0.0445, 5.0 / 365);
    assertEquals(t, cash.accept(LDC), 1e-12);
  }

  @Test
  public void testFRA() {
    final double paymentTime = 0.5;
View Full Code Here

  public void testCash() {
    final double t = 7 / 365.0;
    final YieldAndDiscountCurve curve = CURVES.getCurve(FIVE_PC_CURVE_NAME);
    double r = 1 / t * (1 / curve.getDiscountFactor(t) - 1);
    Cash cash = new Cash(CUR, 0, t, 1, r, t, FIVE_PC_CURVE_NAME);
    double pv = cash.accept(PVC, CURVES);
    assertEquals(0.0, pv, 1e-12);

    final double tradeTime = 2.0 / 365.0;
    final double yearFrac = 5.0 / 360.0;
    r = 1 / yearFrac * (curve.getDiscountFactor(tradeTime) / curve.getDiscountFactor(t) - 1);
View Full Code Here

    final double tradeTime = 2.0 / 365.0;
    final double yearFrac = 5.0 / 360.0;
    r = 1 / yearFrac * (curve.getDiscountFactor(tradeTime) / curve.getDiscountFactor(t) - 1);
    cash = new Cash(CUR, tradeTime, t, 1, r, yearFrac, FIVE_PC_CURVE_NAME);
    pv = cash.accept(PVC, CURVES);
    assertEquals(0.0, pv, 1e-12);
  }

  @Test
  public void testFRA() {
View Full Code Here

   */
  public void parRateMethodVsCalculator() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate);
    final double parRateMethod = METHOD_DEPOSIT.parRate(deposit, PROVIDER);
    final double parRateCalculator = deposit.accept(PRDC, PROVIDER);
    assertEquals("DepositDefinition: par rate", parRateMethod, parRateCalculator, TOLERANCE_RATE);
  }

  @Test
  /**
 
View Full Code Here

   */
  public void parSpreadMethodVsCalculator() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate);
    final double parSpreadMethod = METHOD_DEPOSIT.parSpread(deposit, PROVIDER);
    final double parSpreadCalculator = deposit.accept(PSMQDC, PROVIDER);
    assertEquals("DepositDefinition: present value", parSpreadMethod, parSpreadCalculator, TOLERANCE_RATE);
  }

  @Test
  /**
 
View Full Code Here

   */
  public void parSpreadCurveSensitivityMethodVsCalculator() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate);
    final MulticurveSensitivity pscsMethod = METHOD_DEPOSIT.parSpreadCurveSensitivity(deposit, PROVIDER);
    final MulticurveSensitivity pscsCalculator = deposit.accept(PSMQCSDC, PROVIDER);
    AssertSensivityObjects.assertEquals("CashDiscountingProviderMethod: parSpreadCurveSensitivity", pscsMethod, pscsCalculator, TOLERANCE_RATE);
  }

  @Test
  /**
 
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);
    final MultipleCurrencyAmount cash = deposit.accept(TPC);
    assertEquals("DepositDefinition: today payment", 0.0, cash.getAmount(deposit.getCurrency()), TOLERANCE_PV);
    assertEquals("DepositDefinition: today payment", 1, cash.getCurrencyAmounts().length);
  }

  @Test
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);
    final MultipleCurrencyAmount cash = deposit.accept(TPC);
    assertEquals("DepositDefinition: today payment", -NOTIONAL, cash.getAmount(deposit.getCurrency()), TOLERANCE_PV);
    assertEquals("DepositDefinition: today payment", 1, cash.getCurrencyAmounts().length);
  }

  @Test
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.