Package com.opengamma.financial.analytics.ircurve.strips

Examples of com.opengamma.financial.analytics.ircurve.strips.CashNode$Meta


@Test(groups = TestGroup.UNIT)
public class CurveNodeBuildersTest extends AnalyticsTestBase {

  @Test
  public void testCashNodeBuilder() {
    CashNode node = new CashNode(Tenor.ONE_DAY, Tenor.ONE_YEAR, ExternalId.of("convention", "name"), "TEST");
    assertEquals(node, cycleObject(CashNode.class, node));
    node = new CashNode(Tenor.ONE_DAY, Tenor.ONE_YEAR, ExternalId.of("convention", "name"), "TEST", null);
    assertEquals(node, cycleObject(CashNode.class, node));
    node = new CashNode(Tenor.ONE_DAY, Tenor.ONE_YEAR, ExternalId.of("convention", "name"), "TEST", "Name");
    assertEquals(node, cycleObject(CashNode.class, node));
  }
View Full Code Here


    node.accept(visitor);
  }

  @Test
  public void testCash() {
    final CashNode node = new CashNode(Tenor.ONE_DAY, Tenor.ONE_WEEK, DEPOSIT_1M_ID, SCHEME);
    final Set<Currency> currencies = node.accept(VISITOR);
    assertEquals(1, currencies.size());
    assertEquals(Currency.USD, currencies.iterator().next());
  }
View Full Code Here

    BUILDER = new CurveNodeWithIdentifierBuilder(LocalDate.of(2013, 1, 1), MAPPER);
  }

  @Test
  public void testCash() {
    final CashNode cash = new CashNode(Tenor.ONE_DAY, Tenor.TWO_MONTHS, ExternalId.of("Test", "Test"), "Test");
    assertEquals(new CurveNodeWithIdentifier(cash, ExternalId.of("Test", "Cash"), "Cash Data", DataFieldType.OUTRIGHT), cash.accept(BUILDER));
  }
View Full Code Here

    new CurveNodeCurrencyVisitor(null);
  }

  @Test(expectedExceptions = OpenGammaRuntimeException.class)
  public void testNullCashConvention() {
    final CashNode node = new CashNode(Tenor.ONE_DAY, Tenor.ONE_WEEK, DEPOSIT_1M_ID, SCHEME);
    node.accept(EMPTY_CONVENTIONS);
  }
View Full Code Here

      final Tenor maturityTenor = Tenor.of(Period.parse(message.getString(MATURITY_TENOR_FIELD)));
      final ExternalId conventionId = deserializer.fieldValueToObject(ExternalId.class, message.getByName(CONVENTION_ID_FIELD));
      final String curveNodeIdMapperName = message.getString(CURVE_MAPPER_ID_FIELD);
      if (message.hasField(NAME_FIELD)) {
        final String name = message.getString(NAME_FIELD);
        return new CashNode(startTenor, maturityTenor, conventionId, curveNodeIdMapperName, name);
      }
      return new CashNode(startTenor, maturityTenor, conventionId, curveNodeIdMapperName);
    }
View Full Code Here

   */
  @Test
  public void testInterpolatedCurveDefinitions() {
    final Set<CurveNode> nodes = new TreeSet<>();
    final String curveNodeIdMapperName = "Id mapper";
    final CashNode cash1w = new CashNode(Tenor.ONE_DAY, Tenor.ONE_WEEK, ExternalId.of("Test", "1W Cash"), curveNodeIdMapperName);
    final CashNode cash1m = new CashNode(Tenor.ONE_DAY, Tenor.ONE_MONTH, ExternalId.of("Test", "1m Cash"), curveNodeIdMapperName);
    final CashNode cash6m = new CashNode(Tenor.ONE_DAY, Tenor.SIX_MONTHS, ExternalId.of("Test", "6m Cash"), curveNodeIdMapperName);
    final CashNode cash12m = new CashNode(Tenor.ONE_DAY, Tenor.TWELVE_MONTHS, ExternalId.of("Test", "12m Cash"), curveNodeIdMapperName);
    final SwapNode swap2y = new SwapNode(Tenor.ONE_DAY, Tenor.TWO_YEARS, ExternalId.of("Test", "Pay leg 2y"), ExternalId.of("Test", "Receive leg 2y"), curveNodeIdMapperName);
    final SwapNode swap5y = new SwapNode(Tenor.ONE_DAY, Tenor.FIVE_YEARS, ExternalId.of("Test", "Pay leg 5y"), ExternalId.of("Test", "Receive leg 5y"), curveNodeIdMapperName);
    final SwapNode swap10y = new SwapNode(Tenor.ONE_DAY, Tenor.TEN_YEARS, ExternalId.of("Test", "Pay leg 10y"), ExternalId.of("Test", "Receive leg 10y"), curveNodeIdMapperName);
    nodes.add(cash1w);
    nodes.add(cash1m);
View Full Code Here

  public void testNoConventionForCash() {
    final ExternalId marketDataId = ExternalId.of(SCHEME, "Data");
    final SnapshotDataBundle marketValues = new SnapshotDataBundle();
    final double rate = 0.0012345;
    marketValues.setDataPoint(marketDataId, rate);
    final CashNode cashNode = new CashNode(Tenor.ONE_DAY, Tenor.FIVE_MONTHS, ExternalId.of(SCHEME, "Test"), "Mapper");
    final CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE,
        marketValues, marketDataId, NOW);
    cashNode.accept(converter);
  }
View Full Code Here

  public void testWrongConventionTypeForCash() {
    final ExternalId marketDataId = ExternalId.of(SCHEME, "Data");
    final SnapshotDataBundle marketValues = new SnapshotDataBundle();
    final double rate = 0.0012345;
    marketValues.setDataPoint(marketDataId, rate);
    final CashNode cashNode = new CashNode(Tenor.ONE_DAY, Tenor.FIVE_MONTHS, FIXED_LEG_ID, "Mapper");
    final CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE,
        marketValues, marketDataId, NOW);
    cashNode.accept(converter);
  }
View Full Code Here

    final ExternalId marketDataId = ExternalId.of(SCHEME, "US1d");
    final double rate = 0.0012345;
    final SnapshotDataBundle marketValues = new SnapshotDataBundle();
    marketValues.setDataPoint(marketDataId, rate);
    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

    final ExternalId marketDataId = ExternalId.of(SCHEME, "US1d");
    final double rate = 0.0012345;
    final SnapshotDataBundle marketValues = new SnapshotDataBundle();
    marketValues.setDataPoint(marketDataId, rate);
    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

TOP

Related Classes of com.opengamma.financial.analytics.ircurve.strips.CashNode$Meta

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.