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

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


  public void testCash() {
    final double t = 7 / 365.0;
    final YieldAndDiscountCurve curve = CURVES.getCurve(FIVE_PC_CURVE_NAME);
    final double df = curve.getDiscountFactor(t);
    double r = 1 / t * (1 / df - 1);
    Cash cash = new Cash(CUR, 0, t, 1, r, t, FIVE_PC_CURVE_NAME);
    Map<String, List<DoublesPair>> sense = cash.accept(PVSC, CURVES);

    assertTrue(sense.containsKey(FIVE_PC_CURVE_NAME));
    assertFalse(sense.containsKey(ZERO_PC_CURVE_NAME));

    List<DoublesPair> temp = sense.get(FIVE_PC_CURVE_NAME);
    for (final DoublesPair pair : temp) {
      if (pair.getFirst() == 0.0) {
        assertEquals(0.0, pair.getSecond(), 1e-12);
      } else if (Double.compare(pair.getFirst(), t) == 0) {
        assertEquals(-t * df * (1 + r * t), pair.getSecond(), 1e-12);
      } else {
        assertFalse(true);
      }
    }

    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


    assertEquals(b2, VISITOR.visitBondFixedSecurity(b1, R2));
  }

  @Test
  public void testCash() {
    final Cash c1 = new Cash(CUR, 0, 1, 1, R1, 1);
    final Cash c2 = new Cash(CUR, 0, 1, 1, R2, 1);
    assertEquals(c1.accept(VISITOR, R2), c2);
  }
View Full Code Here

  private static final Currency DUMMY_CUR = Currency.EUR;
  private static final IborIndex DUMMY_INDEX = new IborIndex(DUMMY_CUR, Period.ofMonths(1), 2, DayCountFactory.INSTANCE.getDayCount("Actual/365"),
      BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), true, "Ibor");

  public static InstrumentDerivative makeCash(final double time, final double rate, final double notional) {
    return new Cash(DUMMY_CUR, 0, time, notional, rate, time);
  }
View Full Code Here

  public static InstrumentDerivative makeCash(final double time, final double rate, final double notional) {
    return new Cash(DUMMY_CUR, 0, time, notional, rate, time);
  }

  public static InstrumentDerivative makeLibor(final double time, final double rate, final double notional) {
    return new Cash(DUMMY_CUR, 0, time, notional, rate, time);
  }
View Full Code Here

  public void testCash() {
    final double t = 7 / 365.0;
    final double r = 0.0456;
    final double tradeTime = 2.0 / 365.0;
    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

  private static final Currency CUR = Currency.EUR;

  @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);
  }
View Full Code Here

  @Test
  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);
    cash = new Cash(CUR, tradeTime, t, 1, r, yearFrac, FIVE_PC_CURVE_NAME);
    pv = cash.accept(PVC, CURVES);
    assertEquals(0.0, pv, 1e-12);
  }
View Full Code Here

  public void testCash() {
    final double t = 7 / 365.0;
    final YieldAndDiscountCurve curve = CURVES.getCurve(FUNDING_CURVE_NAME);
    final double df = curve.getDiscountFactor(t);
    final double r = 1 / t * (1 / df - 1);
    final Cash cash = new Cash(CUR, 0, t, 1, r, t, FUNDING_CURVE_NAME);
    doTest(cash, CURVES);
  }
View Full Code Here

  public void testEqualsAndHashCode() {
    MultipleYieldCurveFinderDataBundle other = new MultipleYieldCurveFinderDataBundle(DERIVATIVES, PAR_RATES, null, NODES, INTERPOLATORS, false, FX_MATRIX);
    assertEquals(DATA, other);
    assertEquals(DATA.hashCode(), other.hashCode());
    final List<InstrumentDerivative> derivatives = new ArrayList<>(DERIVATIVES);
    derivatives.set(0, new Cash(CUR, 0, 1000, 1, 0.05, 1000, CURVE_NAME1));
    other = new MultipleYieldCurveFinderDataBundle(derivatives, PAR_RATES, null, NODES, INTERPOLATORS, false, FX_MATRIX);
    assertFalse(other.equals(DATA));
    other = new MultipleYieldCurveFinderDataBundle(derivatives, new double[PAR_RATES.length], null, NODES, INTERPOLATORS, false, FX_MATRIX);
    assertFalse(other.equals(DATA));
    final YieldCurveBundle knownCurves = new YieldCurveBundle();
View Full Code Here

  /**
   * Tests present value when the valuation date is on trade date.
   */
  public void presentValueTrade() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 12);
    final Cash deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate);
    final MultipleCurrencyAmount pvComputed = METHOD_DEPOSIT.presentValue(deposit, PROVIDER);
    final double dfEnd = PROVIDER.getDiscountFactor(EUR, deposit.getEndTime());
    final double dfStart = PROVIDER.getDiscountFactor(EUR, deposit.getStartTime());
    final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart;
    assertEquals("DepositDefinition: present value", pvExpected, pvComputed.getAmount(EUR), TOLERANCE_PV);
  }
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.