Package com.opengamma.master.security

Examples of com.opengamma.master.security.SecurityMaster


    addPortfolioNode(rootNode, getCMCapFloor(), "CM cap/floor", BigDecimal.ONE);
    portfolioMaster.add(portfolioDoc);
  }

  private void storeFinancialSecurity(final FinancialSecurity security) {
    SecurityMaster securityMaster = getToolContext().getSecurityMaster();
    SecurityDocument toAddDoc = new SecurityDocument();
    toAddDoc.setSecurity(security);
    securityMaster.add(toAddDoc);
  }
View Full Code Here


  public static LocalDate getDateWithException(Map<String, String> fieldValueMap, String fieldName) {
    return LocalDate.parse(getWithException(fieldValueMap, fieldName), CSV_DATE_FORMATTER);
  }

  public static void persistLiborRawSecurities(Set<Currency> currencies, ToolContext toolContext) {
    SecurityMaster securityMaster = toolContext.getSecurityMaster();
    byte[] rawData = new byte[] {0};
    StringBuilder sb = new StringBuilder();
    sb.append("Created ").append(currencies.size()).append(" libor securities:\n");
    for (Currency ccy : currencies) {
      ConventionBundle swapConvention = getSwapConventionBundle(ccy, toolContext.getConventionBundleSource());
      ConventionBundle liborConvention = getLiborConventionBundle(swapConvention, toolContext.getConventionBundleSource());
      sb.append("\t").append(liborConvention.getIdentifiers()).append("\n");
      RawSecurity rawSecurity = new RawSecurity(LIBOR_RATE_SECURITY_TYPE, rawData);
      rawSecurity.setExternalIdBundle(liborConvention.getIdentifiers());
      SecurityDocument secDoc = new SecurityDocument();
      secDoc.setSecurity(rawSecurity);
      securityMaster.add(secDoc);
    }
    s_logger.info(sb.toString());
  }
View Full Code Here

  private int _counter;

  @Override
  protected void doRun() throws Exception {
   
    final SecurityMaster secMaster = getToolContext().getSecurityMaster();
   
    final ManageableSecurity cds = makeOneCDS();
    final SecurityDocument cdsDoc = new SecurityDocument(cds);
   
    secMaster.add(cdsDoc);
   
    portfolioWithSecurity(cds, "Test CDS Port 1");
  }
View Full Code Here

  private boolean _publishRest = true;


  @Override
  public void init(final ComponentRepository repo, final LinkedHashMap<String, String> configuration) {
    final SecurityMaster master = new InMemorySecurityMaster();
    final ComponentInfo info = new ComponentInfo(SecurityMaster.class, getClassifier());
    info.addAttribute(ComponentInfoAttributes.LEVEL, 1);
    info.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteSecurityMaster.class);
    info.addAttribute(ComponentInfoAttributes.UNIQUE_ID_SCHEME, InMemorySecurityMaster.DEFAULT_OID_SCHEME);
    repo.registerComponent(info, master);
View Full Code Here

    search(results, callback);
  }

  @Override
  public SecurityHistoryResult history(final SecurityHistoryRequest request) {
    final SecurityMaster master = getMasterByScheme(request.getObjectId().getScheme());
    if (master != null) {
      return master.history(request);
    }
    return (new Try<SecurityHistoryResult>() {
      @Override
      public SecurityHistoryResult tryMaster(final SecurityMaster master) {
        return master.history(request);
      }
    }).each(request.getObjectId().getScheme());
  }
View Full Code Here

  }

  private void persistToPortfolio(final Collection<FXOptionSecurity> fxOptions, final String portfolioName) {
    final PortfolioMaster portfolioMaster = getToolContext().getPortfolioMaster();
    final PositionMaster positionMaster = getToolContext().getPositionMaster();
    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

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

    for (final FXOptionSecurity fxOption : fxOptions) {
      final SecurityDocument fxOptionToAddDoc = new SecurityDocument();
      fxOptionToAddDoc.setSecurity(fxOption);
      securityMaster.add(fxOptionToAddDoc);
      final ManageablePosition fxOptionPosition = new ManageablePosition(BigDecimal.ONE, fxOption.getExternalIdBundle());
      final PositionDocument addedDoc = positionMaster.add(new PositionDocument(fxOptionPosition));
      rootNode.addPosition(addedDoc.getUniqueId());
    }
    portfolioMaster.add(portfolioDoc);
View Full Code Here

    new MasterSecuritySource(null, null);
  }

  //-------------------------------------------------------------------------
  public void test_getSecurity_UniqueId_noOverride_found() throws Exception {
    SecurityMaster mock = mock(SecurityMaster.class);
   
    SecurityDocument doc = new SecurityDocument(example());
    when(mock.get(UID)).thenReturn(doc);
    MasterSecuritySource test = new MasterSecuritySource(mock);
    Security testResult = test.get(UID);
    verify(mock, times(1)).get(UID);
   
    assertEquals(example(), testResult);
View Full Code Here

   
    assertEquals(example(), testResult);
  }

  public void test_getSecurity_UniqueId_found() throws Exception {
    SecurityMaster mock = mock(SecurityMaster.class);
   
    SecurityDocument doc = new SecurityDocument(example());
    when(mock.get(OID, VC)).thenReturn(doc);
    MasterSecuritySource test = new MasterSecuritySource(mock, VC);
    Security testResult = test.get(UID);
    verify(mock, times(1)).get(OID, VC);
   
    assertEquals(example(), testResult);
View Full Code Here

    assertEquals(example(), testResult);
  }

  @Test(expectedExceptions = DataNotFoundException.class)
  public void test_getSecurity_UniqueId_notFound() throws Exception {
    SecurityMaster mock = mock(SecurityMaster.class);
   
    when(mock.get(OID, VC)).thenThrow(new DataNotFoundException(""));
    MasterSecuritySource test = new MasterSecuritySource(mock, VC);
    try {
      test.get(UID);
    } finally {
      verify(mock, times(1)).get(OID, VC);
View Full Code Here

    }
  }

  //-------------------------------------------------------------------------
  public void test_getSecurity_ObjectId_found() throws Exception {
    SecurityMaster mock = mock(SecurityMaster.class);
   
    SecurityDocument doc = new SecurityDocument(example());
    when(mock.get(OID, VC)).thenReturn(doc);
    MasterSecuritySource test = new MasterSecuritySource(mock, VC);
    Security testResult = test.get(OID, VC);
    verify(mock, times(1)).get(OID, VC);
   
    assertEquals(example(), testResult);
View Full Code Here

TOP

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

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.