Package com.opengamma.master.position

Examples of com.opengamma.master.position.PositionDocument$Meta


    for (final FinancialSecurity security : securities) {
      final SecurityDocument securityToAddDoc = new SecurityDocument();
      securityToAddDoc.setSecurity(security);
      securityMaster.add(securityToAddDoc);
      final ManageablePosition position = new ManageablePosition(BigDecimal.ONE, security.getExternalIdBundle());
      final PositionDocument addedDoc = positionMaster.add(new PositionDocument(position));
      rootNode.addPosition(addedDoc.getUniqueId());
    }
    portfolioMaster.add(portfolioDoc);
  }
View Full Code Here


      // build the tree structure
      final ManageablePortfolioNode issuerNode = buildPortfolioTree(rootNode, security);
     
      // create the position and add it to the master
      final ManageablePosition position = createPosition(security);
      final PositionDocument addedPosition = addPosition(position);
     
      // add the position reference (the unique identifier) to portfolio
      issuerNode.addPosition(addedPosition.getUniqueId());
    }
   
    // adds the complete tree structure to the master
    addPortfolio(portfolio);
  }
View Full Code Here

   *
   * @param position  the position to add, not null
   * @return the added document, not null
   */
  protected PositionDocument addPosition(ManageablePosition position) {
    return getToolContext().getPositionMaster().add(new PositionDocument(position));
  }
View Full Code Here

  protected ObjectId mapPositionIdentifier(final Position position) {
    ObjectId id = _positionMap.get(position.getUniqueId());
    if (id == null) {
      s_logger.debug("Adding position {} to master", position);
      id = _positions.add(new PositionDocument(createManageablePosition(position))).getUniqueId().getObjectId();
      _positionMap.put(position.getUniqueId(), id);
      s_cache.put(position.getUniqueId().toExternalId(), id);
    } else {
      s_logger.debug("Position {} already in master at {}", position, id);
    }
View Full Code Here

    final LocalDate tradeDate = getRandomTradeDate(optionTicker);
    final ManageableTrade trade = new ManageableTrade(amount, optionTicker, tradeDate, null, ExternalId.of("CPARTY", "BACS"));

    position.addTrade(trade);
    final PositionDocument doc = new PositionDocument(position);
    final PositionDocument added = getToolContext().getPositionMaster().add(doc);
    node.addPosition(added);
  }
View Full Code Here

    UniqueId updatedTradeId = _builder.updateTrade(updatedTradeData, updatedSecurityData, null);
    ManageableTrade updatedTrade = _positionMaster.getTrade(updatedTradeId);
    assertEquals("updatedCounterparty", updatedTrade.getCounterpartyExternalId().getValue());
    assertEquals(LocalDate.of(2012, 12, 22), updatedTrade.getTradeDate());
    assertEquals(4321d, updatedTrade.getPremium());
    PositionDocument positionDocument = _positionMaster.get(updatedTrade.getParentPositionId());
    ManageablePosition updatedPosition = positionDocument.getPosition();
    assertEquals(updatedTrade, updatedPosition.getTrade(updatedTradeId));
    FXForwardSecurity updatedSecurity = (FXForwardSecurity) _securityMaster.get(updatedTrade.getSecurityLink().getObjectId(),
                                                                                VersionCorrection.LATEST).getSecurity();
    assertEquals(Currency.AUD, updatedSecurity.getPayCurrency());
    assertEquals(200d, updatedSecurity.getPayAmount());
View Full Code Here

    UniqueId updatedTradeId = _builder.updateTrade(updatedTradeData, updatedSecurityData, updatedUnderlyingData);
    ManageableTrade updatedTrade = _positionMaster.getTrade(updatedTradeId);
    assertEquals("updatedCounterparty", updatedTrade.getCounterpartyExternalId().getValue());
    assertEquals(LocalDate.of(2012, 12, 22), updatedTrade.getTradeDate());
    assertEquals(4321d, updatedTrade.getPremium());
    PositionDocument positionDocument = _positionMaster.get(updatedTrade.getParentPositionId());
    ManageablePosition updatedPosition = positionDocument.getPosition();
    assertEquals(updatedTrade, updatedPosition.getTrade(updatedTradeId));
    SwaptionSecurity updatedSecurity = (SwaptionSecurity) _securityMaster.get(updatedTrade.getSecurityLink().getObjectId(),
                                                                              VersionCorrection.LATEST).getSecurity();
    assertFalse(updatedSecurity.isPayer());
    assertEquals(LongShort.LONG, updatedSecurity.getLongShort());
View Full Code Here

  public void updatePositionWithNoTrade() {
    ManageableSecurity security = _securityMaster.add(new SecurityDocument(BlotterTestUtils.FX_FORWARD)).getSecurity();
    ManageablePosition position = new ManageablePosition();
    position.setQuantity(BigDecimal.ONE);
    position.setSecurityLink(new ManageableSecurityLink(security.getUniqueId()));
    ManageablePosition savedPosition = _positionMaster.add(new PositionDocument(position)).getPosition();

    BeanDataSource updatedTradeData = createTradeData("counterparty", "updatedCounterparty",
                                                      "tradeDate", "2012-12-22",
                                                      "premium", "4321");
    BeanDataSource updatedSecurityData = BlotterTestUtils.overrideBeanData(BlotterTestUtils.FX_FORWARD_DATA_SOURCE,
View Full Code Here

          trades = new BigDecimal(1 + (random.nextInt(150) - 75));
        } else {
          trades = BigDecimal.ONE;
        }
        final ManageablePosition securityPosition = new ManageablePosition(trades, security.getExternalIdBundle());
        final PositionDocument addedDoc = positionMaster.add(new PositionDocument(securityPosition));
        subNode.addPosition(addedDoc.getUniqueId());
      }
      portfolioMaster.add(subPortfolioDoc);
      rootNode.addChildNode(subNode);
    }
    portfolioMaster.add(portfolioDoc);
View Full Code Here

    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());
    }
    portfolioMaster.add(portfolioDoc);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.position.PositionDocument$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.