Package com.opengamma.master.position

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


    return manageablePosition;
  }

  private ManageableTrade convertTrade(Trade trade, Security security) {

    ManageableTrade manageableTrade = new ManageableTrade(trade.getQuantity(),
                                                          security.getExternalIdBundle(),
                                                          trade.getTradeDate(),
                                                          null,
                                                          trade.getCounterparty().toExternalId());

    ExternalId externalId = trade.getExternalSystemId().toExternalId();

    _xmlExternalIdValidator.validateExternalId(externalId, trade.getId());

    manageableTrade.setProviderId(externalId);

    for (AdditionalCashflow cashflow : nullCheckIterable(trade.getAdditionalCashflows())) {

      if (cashflow.getCashflowType() == AdditionalCashflow.CashflowType.PREMIUM) {
        MonetaryAmount monetaryAmount = cashflow.getMonetaryAmount();
        manageableTrade.setPremium(monetaryAmount.getAmount().doubleValue());
        manageableTrade.setPremiumCurrency(monetaryAmount.getCurrency());
        manageableTrade.setPremiumDate(cashflow.getCashflowDate());
      }
    }

    manageableTrade.setAttributes(trade.getAdditionalAttributes());

    return manageableTrade;
  }
View Full Code Here


      // Check for trade equality
      if (chosenPosition != null && (chosenPosition.getTrades().size() == position.getTrades().size())) {

        for (ManageableTrade trade : chosenPosition.getTrades()) {

          ManageableTrade comparableTrade = JodaBeanUtils.clone(trade);
          comparableTrade.setUniqueId(null);
          if (!(position.getTrades().contains(comparableTrade))) {
            chosenPosition = null;
            break;
          }
        }
View Full Code Here

  }

  private ManageablePosition createPosition(ManageableSecurity security, boolean includeTrade) {
    ManageablePosition position = new ManageablePosition(BigDecimal.ONE, security.getExternalIdBundle());
    if (includeTrade) {
      ManageableTrade trade = new ManageableTrade(BigDecimal.ONE, security.getExternalIdBundle(), LocalDate.now().minusDays(3), OffsetTime.now(), ExternalId.of("Cpty", "GOLDMAN"));
      position.addTrade(trade);
    }
    return position;
  }
View Full Code Here

    if (securities != null && securities.length > 0 && securities[0] != null) {
     
      // Build the position and trade(s) using security[0] (underlying)
      ManageablePosition position = _rowParser.constructPosition(row, securities[0]);     
      if (position != null) {
        ManageableTrade trade = _rowParser.constructTrade(row, securities[0], position);
        if (trade != null) {
          position.addTrade(trade);
        }
      }
      return new ObjectsPair<ManageablePosition, ManageableSecurity[]>(position, securities);
View Full Code Here

    return swap;
  }

  @Override
  public ManageableTrade createSecurityTrade(final QuantityGenerator quantity, final SecurityPersister persister, final NameGenerator counterPartyGenerator) {
    ManageableTrade trade = null;
    final SwapSecurity swap = createSecurity();
    if (swap != null) {
      trade = new ManageableTrade(quantity.createQuantity(), persister.storeSecurity(swap), swap.getTradeDate().toLocalDate(), swap.getTradeDate().toOffsetDateTime().toOffsetTime(),
          ExternalId.of(Counterparty.DEFAULT_SCHEME, counterPartyGenerator.createName()));
    }
    return trade;
  }
View Full Code Here

   
    // Create trade using trade date, premium and counterparty if available in current row
    if (row.containsKey(TRADE_DATE) && row.containsKey(PREMIUM) && row.containsKey(COUNTERPARTY)) {
      LocalDate tradeDate = getDateWithException(row, TRADE_DATE);
      ExternalId counterpartyId = ExternalId.of(Counterparty.DEFAULT_SCHEME, getWithException(row, COUNTERPARTY));
      ManageableTrade result =
          new ManageableTrade(
              position.getQuantity(),
              security.getExternalIdBundle(),
              tradeDate,
              LocalTime.of(11, 11).atOffset(ZoneOffset.UTC),
              counterpartyId);
View Full Code Here

    ArgumentChecker.notNull(row, "row");
    ArgumentChecker.notNull(security, "security");
    ArgumentChecker.notNull(position, "position");
   
    ManageableTrade result = (ManageableTrade) recursiveConstructBean(row, ManageableTrade.class, "trade:");
    if (result != null) {
      if (result.getTradeDate() == null) {
        return null;
      }
      result.setSecurityLink(new ManageableSecurityLink(security.getExternalIdBundle()));
    }
    return result;
  }
View Full Code Here

      ManageablePosition position = new ManageablePosition();
      position.getSecurityLink().setExternalId(_trade.getSecurityLink().getExternalId());
      position.setQuantity(_trade.getQuantity());
      String providerIdStr = _trade.getAttributes().get(getProviderIdName());
      ManageableTrade manageableTrade = new ManageableTrade(_trade);
      if (providerIdStr != null) {
        ExternalId providerId = ExternalId.parse(providerIdStr);
        position.setProviderId(providerId);
        manageableTrade.setProviderId(providerId);
      }
      position.addTrade(manageableTrade);
      PositionDocument addedPosition = getPositionMaster().add(new PositionDocument(position));
      root.addPosition(addedPosition.getUniqueId());
View Full Code Here

    @SuppressWarnings("synthetic-access")
    @Override
    public PortfolioNode createPortfolioNode() {
      final SimplePortfolioNode node = new SimplePortfolioNode(_name);
      for (int i = 0; i < _securities.length; i++) {
        final ManageableTrade trade = new ManageableTrade(BigDecimal.ONE, getSecurityPersister().storeSecurity(_securities[i]), _tradeDates[i].toLocalDate(),
            _tradeDates[i].toOffsetDateTime().toOffsetTime(), ExternalId.of(Counterparty.DEFAULT_SCHEME, COUNTERPARTY));
        trade.setPremium(0.);
        trade.setPremiumCurrency(CURRENCY);
        final Position position = SimplePositionGenerator.createPositionFromTrade(trade);
        node.addPosition(position);
      }
      return node;
    }
View Full Code Here

    public PortfolioNode createPortfolioNode() {
      final SimplePortfolioNode node = new SimplePortfolioNode("CM Cap/Floor");
      for (final Tenor tenor : _tenors) {
        for (final double strike : _strikes) {
          final CapFloorSecurity cap = createCapFloor(tenor, strike);
          final ManageableTrade trade = new ManageableTrade(BigDecimal.ONE, getSecurityPersister().storeSecurity(cap), _tradeDate.toLocalDate(),
              _tradeDate.toOffsetDateTime().toOffsetTime(), ExternalId.of(Counterparty.DEFAULT_SCHEME, COUNTERPARTY));
          trade.setPremium(0.);
          trade.setPremiumCurrency(CURRENCY);
          final Position position = SimplePositionGenerator.createPositionFromTrade(trade);
          node.addPosition(position);
        }
      }
      return node;
View Full Code Here

TOP

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