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

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


  public DepositCounterpartDefinition 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 DepositCounterpartDefinition(_currency, startDate, endDate, notional, rate, accrualFactor, _nameCounterpart);
  }
View Full Code Here


   */
  public void parSpreadBeforeStart() {
    final ZonedDateTime referenceDate = TRADE_DATE;
    final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate);
    final double parSpread = METHOD_DEPOSIT.parSpread(deposit, PROVIDER_ISSUER);
    final DepositCounterpartDefinition deposit0Definition = DepositCounterpartDefinition.fromStart(SPOT_DATE, DEPOSIT_PERIOD, NOTIONAL, RATE + parSpread, GENERATOR, ISSUER_NAME);
    final DepositCounterpart deposit0 = deposit0Definition.toDerivative(referenceDate);
    final MultipleCurrencyAmount pv0 = METHOD_DEPOSIT.presentValue(deposit0, PROVIDER_ISSUER);
    assertEquals("DepositDefinition: present value", 0, pv0.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

   */
  public void parSpreadOnStart() {
    final ZonedDateTime referenceDate = DEPOSIT_CPTY_DEFINITION.getStartDate();
    final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate);
    final double parSpread = METHOD_DEPOSIT.parSpread(deposit, PROVIDER_ISSUER);
    final DepositCounterpartDefinition deposit0Definition = DepositCounterpartDefinition.fromStart(SPOT_DATE, DEPOSIT_PERIOD, NOTIONAL, RATE + parSpread, GENERATOR, ISSUER_NAME);
    final DepositCounterpart deposit0 = deposit0Definition.toDerivative(referenceDate);
    final MultipleCurrencyAmount pv0 = METHOD_DEPOSIT.presentValue(deposit0, PROVIDER_ISSUER);
    assertEquals("DepositDefinition: present value", 0, pv0.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

   */
  public void parSpreadAfterStart() {
    final ZonedDateTime referenceDate = ScheduleCalculator.getAdjustedDate(DEPOSIT_CPTY_DEFINITION.getStartDate(), 1, TARGET);
    final DepositCounterpart deposit = DEPOSIT_CPTY_DEFINITION.toDerivative(referenceDate);
    final double parSpread = METHOD_DEPOSIT.parSpread(deposit, PROVIDER_ISSUER); // Spread will be -(1/delta+rate), as there is no initial amount
    final DepositCounterpartDefinition deposit0Definition = DepositCounterpartDefinition.fromStart(SPOT_DATE, DEPOSIT_PERIOD, NOTIONAL, RATE + parSpread, GENERATOR, ISSUER_NAME);
    final DepositCounterpart deposit0 = deposit0Definition.toDerivative(referenceDate);
    final MultipleCurrencyAmount pv0 = METHOD_DEPOSIT.presentValue(deposit0, PROVIDER_ISSUER);
    assertEquals("DepositDefinition: present value", 0, pv0.getAmount(EUR), TOLERANCE_PV);
  }
View Full Code Here

  private static final String CURVE_NAME = "Curve";

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void nullCurrency() {
    new DepositCounterpartDefinition(null, SPOT_DATE, END_DATE, NOTIONAL, RATE, DEPOSIT_AF, COUNTERPART);
  }
View Full Code Here

    new DepositCounterpartDefinition(null, SPOT_DATE, END_DATE, NOTIONAL, RATE, DEPOSIT_AF, COUNTERPART);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void nullCpty() {
    new DepositCounterpartDefinition(EUR, SPOT_DATE, END_DATE, NOTIONAL, RATE, DEPOSIT_AF, null);
  }
View Full Code Here

  @Test
  /**
   * Tests the builders.
   */
  public void from() {
    final DepositCounterpartDefinition fromTradeTenor = DepositCounterpartDefinition.fromTrade(TRADE_DATE, DEPOSIT_PERIOD, NOTIONAL, RATE, GENERATOR, COUNTERPART);
    assertEquals("DepositDefinition: from", DEPOSIT_CTP_DEFINITION, fromTradeTenor);
    final DepositCounterpartDefinition fromStartTenor = DepositCounterpartDefinition.fromStart(SPOT_DATE, DEPOSIT_PERIOD, NOTIONAL, RATE, GENERATOR, COUNTERPART);
    assertEquals("DepositDefinition: from", DEPOSIT_CTP_DEFINITION, fromStartTenor);
    final int start = 1;
    final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(TRADE_DATE, start, TARGET);
    final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, 1, TARGET);
    final double af = GENERATOR.getDayCount().getDayCountFraction(startDate, endDate);
    final DepositCounterpartDefinition on = new DepositCounterpartDefinition(EUR, startDate, endDate, NOTIONAL, RATE, af, COUNTERPART);
    final DepositCounterpartDefinition fromTradeON = DepositCounterpartDefinition.fromTrade(TRADE_DATE, start, NOTIONAL, RATE, GENERATOR, COUNTERPART);
    assertEquals("DepositDefinition: from", on, fromTradeON);
    final DepositCounterpartDefinition fromStartON = DepositCounterpartDefinition.fromStart(startDate, NOTIONAL, RATE, GENERATOR, COUNTERPART);
    assertEquals("DepositDefinition: from", on, fromStartON);
  }
View Full Code Here

    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 7, 17);
    final Period tenor = Period.ofDays(2);
    final double rate = 0.01;
    final double notional = 12345;
    final GeneratorAttributeIR attribute = new GeneratorAttributeIR(tenor, tenor);
    final DepositCounterpartDefinition insGenerated = GENERATOR_DEPOSIT_ON_USD.generateInstrument(referenceDate, rate, notional, attribute);
    final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(referenceDate, tenor, CALENDAR);
    final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, 1, CALENDAR);
    final double accrualFactor = DAY_COUNT.getDayCountFraction(startDate, endDate);
    final DepositCounterpartDefinition insExpected = new DepositCounterpartDefinition(CUR, startDate, endDate, notional, rate, accrualFactor, NAME_COUNTERPART);
    assertEquals("Generator Deposit Counterpart: generate instrument", insExpected, insGenerated);
  }
View Full Code Here

TOP

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

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.