Package com.opengamma.master.security

Examples of com.opengamma.master.security.SecurityDocument


  }

  //-------------------------------------------------------------------------
  @Override
  public SecurityDocument get(final ObjectIdentifiable objectId, final VersionCorrection versionCorrection) {
    final SecurityDocument doc = doGetByOidInstants(objectId, versionCorrection, new SecurityDocumentExtractor(), "Security");
    loadDetail(getDetailProvider(), Collections.singletonList(doc));
    return doc;
  }
View Full Code Here


    final ManageablePortfolio portfolio = new ManageablePortfolio(portfolioName, rootNode);
    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    for (final SwapSecurity swap : swaps) {
      final SecurityDocument swapToAddDoc = new SecurityDocument();
      swapToAddDoc.setSecurity(swap);
      securityMaster.add(swapToAddDoc);
      final ManageablePosition swapPosition = new ManageablePosition(BigDecimal.ONE, swap.getExternalIdBundle());
      final PositionDocument addedDoc = positionMaster.add(new PositionDocument(swapPosition));
      rootNode.addPosition(addedDoc.getUniqueId());
    }
View Full Code Here

        _security.setUniqueId(uniqueId);
        _security.setName(name)
      } else {
        _security = new ManageableSecurity(uniqueId, name, type, ExternalIdBundle.EMPTY);
      }
      SecurityDocument doc = new SecurityDocument(_security);
      doc.setVersionFromInstant(DbDateUtils.fromSqlTimestamp(versionFrom));
      doc.setVersionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(versionTo));
      doc.setCorrectionFromInstant(DbDateUtils.fromSqlTimestamp(correctionFrom));
      doc.setCorrectionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(correctionTo));
      doc.setUniqueId(uniqueId);
      _documents.add(doc);
    }
View Full Code Here

    _secMaster.add(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_add_noSecurity() {
    SecurityDocument doc = new SecurityDocument();
    _secMaster.add(doc);
  }
View Full Code Here

  @Test
  public void test_add_add() {
    Instant now = Instant.now(_secMaster.getClock());

    ManageableSecurity security = new ManageableSecurity(null, "TestSecurity", "EQUITY", ExternalIdBundle.of("A", "B"));
    SecurityDocument doc = new SecurityDocument();
    doc.setSecurity(security);
    SecurityDocument test = _secMaster.add(doc);

    UniqueId uniqueId = test.getUniqueId();
    assertNotNull(uniqueId);
    assertEquals("DbSec", uniqueId.getScheme());
    assertTrue(uniqueId.isVersioned());
    assertTrue(Long.parseLong(uniqueId.getValue()) >= 1000);
    assertEquals("0", uniqueId.getVersion());
    assertEquals(now, test.getVersionFromInstant());
    assertEquals(null, test.getVersionToInstant());
    assertEquals(now, test.getCorrectionFromInstant());
    assertEquals(null, test.getCorrectionToInstant());
    ManageableSecurity testSecurity = test.getSecurity();
    assertNotNull(testSecurity);
    assertEquals(uniqueId, testSecurity.getUniqueId());
    assertEquals("TestSecurity", security.getName());
    assertEquals("EQUITY", security.getSecurityType());
    ExternalIdBundle idKey = security.getExternalIdBundle();
View Full Code Here

  }

  @Test
  public void test_add_addThenGet() {
    ManageableSecurity security = new ManageableSecurity(null, "TestSecurity", "EQUITY", ExternalIdBundle.of("A", "B"));
    SecurityDocument doc = new SecurityDocument();
    doc.setSecurity(security);
    SecurityDocument added = _secMaster.add(doc);

    SecurityDocument test = _secMaster.get(added.getUniqueId());
    assertEquals(added, test);
  }
View Full Code Here

    final InterestRateNotional notional = new InterestRateNotional(CURRENCY, 10000000);
    final FloatingInterestRateLeg payLeg = new FloatingInterestRateLeg(ACT_360, QUARTERLY, REGION, MODIFIED_FOLLOWING, notional, true, LIBOR_3M, FloatingRateType.IBOR);
    final FixedInterestRateLeg receiveLeg = new FixedInterestRateLeg(THIRTYU_360, SEMI_ANNUAL, REGION, MODIFIED_FOLLOWING, notional, true, 0.02);
    final SwapSecurity underlyingSwap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg);
    underlyingSwap.setName("Receive fixed @ 2% v USD 3m Libor");
    final SecurityDocument toAddDoc = new SecurityDocument();
    toAddDoc.setSecurity(underlyingSwap);
    securityMaster.add(toAddDoc);
    final ZonedDateTime[] tradeDates = new ZonedDateTime[] {tradeDate, tradeDate};
    final ExternalId underlyingId = getSecurityPersister().storeSecurity(underlyingSwap).iterator().next();
    final SwaptionSecurity swaption1 = new SwaptionSecurity(true, underlyingId, true, expiry, false, CURRENCY);
    swaption1.setName("Long payer 1Yx10Y @ 2%");
View Full Code Here

    final FixedInterestRateLeg receiveLeg2 = new FixedInterestRateLeg(ACT_365, SEMI_ANNUAL, REGION, MODIFIED_FOLLOWING, notional, true, 0.01825);
    final SwapSecurity underlyingSwap1 = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg1);
    underlyingSwap1.setName("Receive fixed @ 1.8% v USD 3m Libor");
    final SwapSecurity underlyingSwap2 = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg2);
    underlyingSwap2.setName("Receive fixed @ 1.825% v USD 3m Libor");
    SecurityDocument toAddDoc = new SecurityDocument();
    toAddDoc.setSecurity(underlyingSwap1);
    securityMaster.add(toAddDoc);
    toAddDoc = new SecurityDocument();
    toAddDoc.setSecurity(underlyingSwap2);
    securityMaster.add(toAddDoc);
    final ExternalId underlyingId1 = getSecurityPersister().storeSecurity(underlyingSwap1).iterator().next();
    final ExternalId underlyingId2 = getSecurityPersister().storeSecurity(underlyingSwap2).iterator().next();
    final ZonedDateTime[] tradeDates = new ZonedDateTime[] {tradeDate, tradeDate};
    final SwaptionSecurity swaption1 = new SwaptionSecurity(false, underlyingId1, true, expiry, false, CURRENCY);
View Full Code Here

    final FixedInterestRateLeg receiveLeg = new FixedInterestRateLeg(THIRTYU_360, SEMI_ANNUAL, REGION, MODIFIED_FOLLOWING, notional, true, 0.02);
    final SwapSecurity underlyingSwap1 = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg);
    underlyingSwap1.setName("Receive fixed @ 2% v USD 3m Libor");
    final SwapSecurity underlyingSwap2 = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, receiveLeg, payLeg);
    underlyingSwap2.setName("Pay fixed @ 2% v USD 3m Libor");
    SecurityDocument toAddDoc = new SecurityDocument();
    toAddDoc.setSecurity(underlyingSwap1);
    securityMaster.add(toAddDoc);
    toAddDoc = new SecurityDocument();
    toAddDoc.setSecurity(underlyingSwap2);
    securityMaster.add(toAddDoc);
    final ExternalId underlyingId1 = getSecurityPersister().storeSecurity(underlyingSwap1).iterator().next();
    final ExternalId underlyingId2 = getSecurityPersister().storeSecurity(underlyingSwap2).iterator().next();
    final ZonedDateTime[] tradeDates = new ZonedDateTime[] {tradeDate, tradeDate, tradeDate};
    final SwaptionSecurity swaption1 = new SwaptionSecurity(true, underlyingId1, true, expiry, false, CURRENCY);
View Full Code Here

    final ManageablePortfolio portfolio = new ManageablePortfolio("Tutorial 1");
    final ManageablePortfolioNode root = portfolio.getRootNode();
    final Random rnd = new Random();
    root.setName("Root");
    for (final Tutorial1Security security : loadSecurities()) {
      securities.add(new SecurityDocument(security.toRawSecurity()));
      final ManageablePosition position = new ManageablePosition(new BigDecimal(100 + rnd.nextInt(900)), security.getExternalIdBundle());
      root.addPosition(positions.add(new PositionDocument(position)));
    }
    portfolios.add(new PortfolioDocument(portfolio));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.security.SecurityDocument

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.