Package com.opengamma.master.position

Examples of com.opengamma.master.position.ManageableTrade


    manageablePosition.setSecurityLink(new ManageableSecurityLink(position.getSecurityLink()));
    manageablePosition.setAttributes(position.getAttributes());
    final Collection<Trade> trades = position.getTrades();
    final List<ManageableTrade> manageableTrades = new ArrayList<ManageableTrade>(trades.size());
    for (Trade trade : trades) {
      final ManageableTrade mtrade = new ManageableTrade(trade);
      final ExternalIdBundle replacementKey = mapSecurityKey(mtrade.getSecurityLink().getExternalId());
      if (replacementKey != null) {
        mtrade.getSecurityLink().setExternalId(replacementKey);
      }
      mtrade.setAttributes(trade.getAttributes());
      manageableTrades.add(mtrade);
    }
    manageablePosition.setTrades(manageableTrades);
    final String providerIdFieldName = manageablePosition.providerId().name();
    if (position.getAttributes().containsKey(providerIdFieldName)) {
View Full Code Here


  public void newSecurityWithOtcUnderlying() {
    UniqueId tradeId = _builder.addTrade(createTradeData(),
                                         BlotterTestUtils.SWAPTION_DATA_SOURCE,
                                         BlotterTestUtils.SWAP_DATA_SOURCE,
                                         _nodeId);
    ManageableTrade trade = _positionMaster.getTrade(tradeId);
    UniqueId positionId = trade.getParentPositionId();
    ManageablePosition position = _positionMaster.get(positionId).getPosition();
    assertEquals(BigDecimal.ONE, trade.getQuantity());
    assertEquals(BigDecimal.ONE, position.getQuantity());
    SwaptionSecurity security = (SwaptionSecurity) _securityMaster.get(trade.getSecurityLink().getObjectId(),
                                                                       VersionCorrection.LATEST).getSecurity();
    assertNotNull(security);
    // check this later
    ExternalId underlyingId = security.getUnderlyingId();
    security.setUniqueId(null); // so it can be tested for equality against the unsaved version
    security.setUnderlyingId(BlotterTestUtils.SWAPTION.getUnderlyingId()); // will need this later
    assertEquals(BlotterTestUtils.SWAPTION, security);
    assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId());
    assertEquals(PREMIUM, trade.getPremium());
    assertEquals(Currency.GBP, trade.getPremiumCurrency());
    assertEquals(PREMIUM_DATE, trade.getPremiumDate());
    assertEquals(TRADE_DATE, trade.getTradeDate());
    assertEquals(PREMIUM_TIME, trade.getPremiumTime());
    assertEquals(TRADE_TIME, trade.getTradeTime());
    assertEquals(ATTRIBUTES, trade.getAttributes());

    // can't check the node ID as nodes are completely replaced
    ManageablePortfolioNode loadedRoot = _portfolioMaster.get(_savedPortfolio.getUniqueId()).getPortfolio().getRootNode();
    ManageablePortfolioNode loadedNode = loadedRoot.getChildNodes().get(0);
    assertEquals(1, loadedNode.getPositionIds().size());
View Full Code Here

  private void addPosition(final ManageablePortfolioNode node, final BigDecimal amount, final ExternalId optionTicker) {
    final ManageablePosition position = new ManageablePosition(amount, optionTicker);

    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

    BeanDataSource updatedUnderlyingData = BlotterTestUtils.overrideBeanData(BlotterTestUtils.SWAP_DATA_SOURCE,
                                                                             "tradeDate", "2013-01-01",
                                                                             "eom", "false");

    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());
    assertEquals(Currency.CAD, updatedSecurity.getCurrency());
View Full Code Here

                                                                           "payAmount", "200");

    _builder.updatePosition(savedPosition.getUniqueId(), updatedTradeData, updatedSecurityData, null);
    ManageablePosition loadedPosition = _positionMaster.get(savedPosition.getUniqueId()).getPosition();
    assertEquals(1, loadedPosition.getTrades().size());
    ManageableTrade trade = loadedPosition.getTrades().get(0);
    assertEquals("updatedCounterparty", trade.getCounterpartyExternalId().getValue());
    assertEquals(LocalDate.of(2012, 12, 22), trade.getTradeDate());
    assertEquals(4321d, trade.getPremium());
    FXForwardSecurity updatedSecurity = (FXForwardSecurity) _securityMaster.get(trade.getSecurityLink().getObjectId(),
                                                                                VersionCorrection.LATEST).getSecurity();
    assertEquals(Currency.AUD, updatedSecurity.getPayCurrency());
    assertEquals(200d, updatedSecurity.getPayAmount());
  }
View Full Code Here

  protected ManageableTrade createFXBarrierOptionSecurityTrade(final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    final FXBarrierOptionSecurity security = createFXBarrierOptionSecurity(bundle);
    if (security == null) {
      return null;
    }
    ManageableTrade trade = new ManageableTrade(quantity, persister.storeSecurity(security), bundle._tradeDate.toLocalDate(), bundle._tradeDate.toOffsetDateTime().toOffsetTime(),
        ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    trade.setPremium(security.getCallAmount());
    trade.setPremiumCurrency(security.getCallCurrency());
    return trade;
  }
View Full Code Here

  protected ManageableTrade createFXDigitalOptionSecurityTrade(final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    final FXDigitalOptionSecurity security = createFXDigitalOptionSecurity(bundle);
    if (security == null) {
      return null;
    }
    ManageableTrade trade = new ManageableTrade(quantity, persister.storeSecurity(security), bundle._tradeDate.toLocalDate(), bundle._tradeDate.toOffsetDateTime().toOffsetTime(),
        ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    trade.setPremium(security.getCallAmount());
    trade.setPremiumCurrency(security.getCallCurrency());
    return trade;
  }
View Full Code Here

  protected ManageableTrade createFXForwardSecurityTrade(final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    final FXForwardSecurity security = createFXForwardSecurity(bundle);
    if (security == null) {
      return null;
    }
    ManageableTrade trade = new ManageableTrade(quantity, persister.storeSecurity(security), bundle._tradeDate.toLocalDate(), bundle._tradeDate.toOffsetDateTime().toOffsetTime(),
        ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    trade.setPremium(security.getPayAmount());
    trade.setPremiumCurrency(security.getPayCurrency());
    return trade;
   
  }
View Full Code Here

  protected ManageableTrade createNDFXForwardSecurityTrade(final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    final NonDeliverableFXForwardSecurity security = createNDFXForwardSecurity(bundle);
    if (security == null) {
      return null;
    }
    ManageableTrade trade = new ManageableTrade(quantity, persister.storeSecurity(security), bundle._tradeDate.toLocalDate(), bundle._tradeDate.toOffsetDateTime().toOffsetTime(),
        ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    trade.setPremium(security.getPayAmount());
    trade.setPremiumCurrency(security.getPayCurrency());
    return trade;
  }
View Full Code Here

  protected ManageableTrade createFXOptionSecurityTrade(final Bundle bundle, final BigDecimal quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    final FXOptionSecurity security = createFXOptionSecurity(bundle);
    if (security == null) {
      return null;
    }
    ManageableTrade trade = new ManageableTrade(quantity, persister.storeSecurity(security), bundle._tradeDate.toLocalDate(), bundle._tradeDate.toOffsetDateTime().toOffsetTime(),
        ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    trade.setPremium(security.getCallAmount());
    trade.setPremiumCurrency(security.getCallCurrency());
    return trade;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.position.ManageableTrade

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.