Package com.opengamma.analytics.financial.instrument.cash

Examples of com.opengamma.analytics.financial.instrument.cash.CashDefinition


    ArgumentChecker.notNull(attribute, "Attributes");
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, _spotLag, _calendar);
    final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spot, attribute.getStartPeriod(), this);
    final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, attribute.getEndPeriod(), this);
    final double accrualFactor = _dayCount.getDayCountFraction(startDate, endDate, _calendar);
    return new CashDefinition(_currency, startDate, endDate, notional, rate, accrualFactor);
  }
View Full Code Here


  public CashDefinition generateInstrument(final ZonedDateTime date, final double rate, final double notional, final GeneratorAttributeIR attribute) {
    ArgumentChecker.notNull(date, "Reference date");
    final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(date, attribute.getStartPeriod(), _calendar);
    final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, 1, _calendar);
    final double accrualFactor = _dayCount.getDayCountFraction(startDate, endDate, _calendar);
    return new CashDefinition(_currency, startDate, endDate, notional, rate, accrualFactor);
  }
View Full Code Here

    final ZonedDateTime startDate = security.getStart();
    final ZonedDateTime endDate = security.getMaturity();
    final ExternalId regionId = security.getRegionId();
    final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, regionId);
    final double accrualFactor = security.getDayCount().getDayCountFraction(startDate, endDate, calendar);
    return new CashDefinition(currency, startDate, endDate, security.getAmount(), security.getRate(), accrualFactor);
  }
View Full Code Here

      final int settlementDays = depositConvention.getSettlementDays();
      final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(_valuationTime, settlementDays, calendar);
      final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spotDate, startPeriod, businessDayConvention, calendar, isEOM);
      final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, maturityPeriod, businessDayConvention, calendar, isEOM);
      final double accrualFactor = dayCount.getDayCountFraction(startDate, endDate);
      return new CashDefinition(currency, startDate, endDate, 1, rate, accrualFactor);
    } else if (convention instanceof IborIndexConvention) {
      final IborIndexConvention iborConvention = (IborIndexConvention) convention;
      final Currency currency = iborConvention.getCurrency();
      final Calendar calendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, iborConvention.getRegionCalendar());
      final BusinessDayConvention businessDayConvention = iborConvention.getBusinessDayConvention();
View Full Code Here

    final ZonedDateTime now = DateUtils.getUTCDate(2013, 5, 1);
    final CurveNode cashNode = new CashNode(Tenor.of(Period.ZERO), Tenor.ONE_DAY, DEPOSIT_1D_ID, "Mapper");
    final CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
    final InstrumentDefinition<?> definition = cashNode.accept(converter);
    assertTrue(definition instanceof CashDefinition);
    final CashDefinition cash = (CashDefinition) definition;
    final CashDefinition expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 5, 1), DateUtils.getUTCDate(2013, 5, 2), 1, rate, 1. / 360);
    assertEquals(expectedCash, cash);
  }
View Full Code Here

    ZonedDateTime now = DateUtils.getUTCDate(2013, 2, 4);
    CurveNode cashNode = new CashNode(Tenor.of(Period.ZERO), Tenor.ONE_MONTH, DEPOSIT_1M_ID, "Mapper");
    CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
    InstrumentDefinition<?> definition = cashNode.accept(converter);
    assertTrue(definition instanceof CashDefinition);
    CashDefinition cash = (CashDefinition) definition;
    CashDefinition expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 2, 6), DateUtils.getUTCDate(2013, 3, 6), 1, rate, 28. / 360);
    assertEquals(expectedCash, cash);
    now = DateUtils.getUTCDate(2013, 5, 2);
    converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
    cashNode = new CashNode(Tenor.of(Period.ZERO), Tenor.ONE_MONTH, DEPOSIT_1M_ID, "Mapper");
    definition = cashNode.accept(converter);
    assertTrue(definition instanceof CashDefinition);
    cash = (CashDefinition) definition;
    expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 5, 6), DateUtils.getUTCDate(2013, 6, 6), 1, rate, 31. / 360);
    assertEquals(expectedCash, cash);
    now = DateUtils.getUTCDate(2013, 5, 7);
    converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
    cashNode = new CashNode(Tenor.ONE_MONTH, Tenor.THREE_MONTHS, DEPOSIT_1M_ID, "Mapper");
    definition = cashNode.accept(converter);
    assertTrue(definition instanceof CashDefinition);
    cash = (CashDefinition) definition;
    expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 6, 10), DateUtils.getUTCDate(2013, 9, 10), 1, rate, 92. / 360);
    assertEquals(expectedCash, cash);
  }
View Full Code Here

  private static final String CURVE_NAME = "Curve";

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void nullStartDate() {
    new CashDefinition(EUR, null, SPOT_DATE, NOTIONAL, RATE, 1.0);
  }
View Full Code Here

    new CashDefinition(EUR, null, SPOT_DATE, NOTIONAL, RATE, 1.0);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void nullEndDate() {
    new CashDefinition(EUR, TRADE_DATE, null, NOTIONAL, RATE, 1.0);
  }
View Full Code Here

    new CashDefinition(EUR, TRADE_DATE, null, NOTIONAL, RATE, 1.0);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void nullCurrency() {
    new CashDefinition(null, TRADE_DATE, SPOT_DATE, NOTIONAL, RATE, 1.0);
  }
View Full Code Here

  /**
   * Tests the equal and hash code methods.
   */
  public void equalHash() {
    assertEquals("CashDefinition: equal-hash code", DEPOSIT_DEFINITION, DEPOSIT_DEFINITION);
    final CashDefinition other = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE, DEPOSIT_AF);
    assertEquals("CashDefinition: equal-hash code", other, DEPOSIT_DEFINITION);
    assertEquals("CashDefinition: equal-hash code", other.hashCode(), DEPOSIT_DEFINITION.hashCode());
    CashDefinition modified;
    modified = new CashDefinition(Currency.USD, SPOT_DATE, END_DATE, NOTIONAL, RATE, DEPOSIT_AF);
    assertFalse("CashDefinition: equal-hash code", DEPOSIT_DEFINITION.equals(modified));
    modified = new CashDefinition(EUR, SPOT_DATE.plusDays(1), END_DATE, NOTIONAL, RATE, DEPOSIT_AF);
    assertFalse("CashDefinition: equal-hash code", DEPOSIT_DEFINITION.equals(modified));
    modified = new CashDefinition(EUR, SPOT_DATE, END_DATE.plusDays(1), NOTIONAL, RATE, DEPOSIT_AF);
    assertFalse("CashDefinition: equal-hash code", DEPOSIT_DEFINITION.equals(modified));
    modified = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL + 1000.0, RATE, DEPOSIT_AF);
    assertFalse("CashDefinition: equal-hash code", DEPOSIT_DEFINITION.equals(modified));
    modified = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE + 0.0010, DEPOSIT_AF);
    assertFalse("CashDefinition: equal-hash code", DEPOSIT_DEFINITION.equals(modified));
    modified = new CashDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE, DEPOSIT_AF - 0.001);
    assertFalse("CashDefinition: equal-hash code", DEPOSIT_DEFINITION.equals(modified));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.instrument.cash.CashDefinition

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.