Package com.opengamma.master.position

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


   * @return A position from the node in the security or null if there isn't one
   */
  private ManageablePosition findPosition(ManageablePortfolioNode node, Security security) {
    for (ObjectId positionId : node.getPositionIds()) {
      // TODO which version do I want? will LATEST do?
      PositionDocument document = getPositionMaster().get(positionId, VersionCorrection.LATEST);
      ManageablePosition position = document.getPosition();
      Security positionSecurity = position.getSecurityLink().resolve(_securitySource);
      if (positionSecurity.getExternalIdBundle().containsAny(security.getExternalIdBundle())) {
        return position;
      }
    }
View Full Code Here


    trade.setSecurityLink(new ManageableSecurityLink(savedSecurity.getUniqueId()));
    ManageablePosition position = new ManageablePosition();
    position.setQuantity(BigDecimal.ONE);
    position.setSecurityLink(new ManageableSecurityLink(trade.getSecurityLink()));
    position.setTrades(Lists.newArrayList(trade));
    ManageablePosition savedPosition = getPositionMaster().add(new PositionDocument(position)).getPosition();
    ManageableTrade savedTrade = savedPosition.getTrades().get(0);

    PortfolioSearchRequest searchRequest = new PortfolioSearchRequest();
    searchRequest.addNodeObjectId(nodeId.getObjectId());
    PortfolioSearchResult searchResult = getPortfolioMaster().search(searchRequest);
View Full Code Here

    security.setUniqueId(previousSecurity.getUniqueId());
    ManageableSecurity savedSecurity = getSecurityMaster().update(new SecurityDocument(security)).getSecurity();
    trade.setSecurityLink(new ManageableSecurityLink(savedSecurity.getUniqueId()));
    ManageablePosition position = getPositionMaster().get(positionId).getPosition();
    position.setTrades(Lists.newArrayList(trade));
    ManageablePosition savedPosition = getPositionMaster().update(new PositionDocument(position)).getPosition();
    ManageableTrade savedTrade = savedPosition.getTrades().get(0);
    return savedTrade.getUniqueId();
  }
View Full Code Here

  @PUT
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.TEXT_HTML)
  public Response putHTML(
      @FormParam("quantity") String quantityStr) {
    PositionDocument doc = data().getPosition();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    quantityStr = StringUtils.replace(StringUtils.trimToNull(quantityStr), ",", "");
    BigDecimal quantity = quantityStr != null && NumberUtils.isNumber(quantityStr) ? new BigDecimal(quantityStr) : null;
    if (quantity == null) {
View Full Code Here

  @PUT
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.APPLICATION_JSON)
  public Response putJSON(
      @FormParam("quantity") String quantityStr, @FormParam("tradesJson") String tradesJson) {
    PositionDocument doc = data().getPosition();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    quantityStr = StringUtils.replace(StringUtils.trimToNull(quantityStr), ",", "");
    tradesJson = StringUtils.trimToNull(tradesJson);
    Collection<ManageableTrade> trades = null;
View Full Code Here

  //-------------------------------------------------------------------------
  @DELETE
  @Produces(MediaType.TEXT_HTML)
  public Response deleteHTML() {
    PositionDocument doc = data().getPosition();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    URI uri = deletePosition(doc);
    return Response.seeOther(uri).build();
  }
View Full Code Here

  }

  @DELETE
  @Produces(MediaType.APPLICATION_JSON)
  public Response deleteJSON() {
    PositionDocument doc = data().getPosition();
    if (doc.isLatest()) {
      deletePosition(doc);
    }
    return Response.ok().build();
  }
View Full Code Here

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    PositionDocument doc = data().getPosition();
   
    // REVIEW jonathan 2012-01-12 -- we are throwing away any adjuster that may be required, e.g. to apply
    // normalisation to the time-series. This reproduces the previous behaviour but probably indicates that the
    // time-series information is in the wrong place.
   
    ObjectId tsObjectId = null;
    Security security = doc.getPosition().getSecurityLink().resolveQuiet(data().getSecuritySource());
    if (security != null && !security.getExternalIdBundle().isEmpty()) {
      // Get the last price HTS for the security
      HistoricalTimeSeriesSource htsSource = data().getHistoricalTimeSeriesSource();
      HistoricalTimeSeries series = htsSource.getHistoricalTimeSeries(
          MarketDataRequirementNames.MARKET_VALUE, doc.getPosition().getSecurity().getExternalIdBundle(), null, null, false, null, false, 0);
      if (series != null) {
        tsObjectId = series.getUniqueId().getObjectId();
      }
    }
   
    out.put("positionDoc", doc);
    out.put("position", doc.getPosition());
    out.put("security", doc.getPosition().getSecurity());
    out.put("timeSeriesId", tsObjectId);
    out.put("deleted", !doc.isLatest());
    out.put("attributes", doc.getPosition().getAttributes());
    TradeAttributesModel tradeAttributesModel = getTradeAttributesModel();
    out.put("tradeAttrModel", tradeAttributesModel);
    return out;
  }
View Full Code Here

    out.put("tradeAttrModel", tradeAttributesModel);
    return out;
  }

  private TradeAttributesModel getTradeAttributesModel() {
    PositionDocument doc = data().getPosition();
    TradeAttributesModel getTradeAttributesModel = new TradeAttributesModel(doc.getPosition());
    return getTradeAttributesModel;
  }
View Full Code Here

    ManageablePosition position = new ManageablePosition(quantity, secId);
    for (ManageableTrade trade : trades) {
      trade.setSecurityLink(new ManageableSecurityLink(secId));
      position.addTrade(trade);
    }
    PositionDocument doc = new PositionDocument(position);
    doc = data().getPositionMaster().add(doc);
    data().setPosition(doc);
    return WebPositionResource.uri(data());
  }
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.