Package com.opengamma.core.position.impl

Examples of com.opengamma.core.position.impl.SimplePosition.addAttribute()


      FudgeMsg attributesMsg = message.getMessage(ATTRIBUTES_FIELD_NAME);
      for (FudgeField fudgeField : attributesMsg) {
        String key = fudgeField.getName();
        Object value = fudgeField.getValue();
        if (key != null && value != null) {
          position.addAttribute(key, (String) value);
        }
      }
    }
    readTrades(deserializer, message.getFieldValue(FudgeMsg.class, message.getByName(TRADES_FIELD_NAME)), position);
    return position;
View Full Code Here


  protected Position createPosition(final String uid, final int quantity, final Security security, final String attr1Value, final String attr2Value, final Trade trade1, final Trade trade2) {
    final SimplePosition position = new SimplePosition(new BigDecimal(quantity), security.getExternalIdBundle());
    position.setSecurityLink(SimpleSecurityLink.of(security));
    if (attr1Value != null) {
      position.addAttribute("Attr1", attr1Value);
    }
    if (attr2Value != null) {
      position.addAttribute("Attr2", attr2Value);
    }
    if (trade1 != null) {
View Full Code Here

    position.setSecurityLink(SimpleSecurityLink.of(security));
    if (attr1Value != null) {
      position.addAttribute("Attr1", attr1Value);
    }
    if (attr2Value != null) {
      position.addAttribute("Attr2", attr2Value);
    }
    if (trade1 != null) {
      position.addTrade(trade1);
    }
    if (trade2 != null) {
View Full Code Here

    node.addPosition(position);
    root.addChildNode(node);
    // Portfolio node with position with an attribute
    node = new SimplePortfolioNode("PositionAttr");
    position = createPosition(securities);
    position.addAttribute("Present Value.DEFAULT_ForwardCurve", "FooForward");
    position.addAttribute("*.DEFAULT_FundingCurve", "FooFunding");
    node.addPosition(position);
    root.addChildNode(node);
    // Portfolio node with position without an attribute
    node = new SimplePortfolioNode("Position");
View Full Code Here

    root.addChildNode(node);
    // Portfolio node with position with an attribute
    node = new SimplePortfolioNode("PositionAttr");
    position = createPosition(securities);
    position.addAttribute("Present Value.DEFAULT_ForwardCurve", "FooForward");
    position.addAttribute("*.DEFAULT_FundingCurve", "FooFunding");
    node.addPosition(position);
    root.addChildNode(node);
    // Portfolio node with position without an attribute
    node = new SimplePortfolioNode("Position");
    position = createPosition(securities);
View Full Code Here

  private final PositionAttributeAggregationFunction _aggFn = new PositionAttributeAggregationFunction(ATTR_NAME);

  @Test
  public void positionAttribute() {
    SimplePosition position = new SimplePosition();
    position.addAttribute(ATTR_NAME, POS_VALUE);
    assertEquals(POS_VALUE, _aggFn.classifyPosition(position));
  }

  @Test
  public void tradeAttribute() {
View Full Code Here

   * Tests the position's value is used when both the position and one of its trades have values for the same attribute.
   */
  @Test
  public void positionAndTradeAttributes() {
    SimplePosition position = new SimplePosition();
    position.addAttribute(ATTR_NAME, POS_VALUE);
    SimpleTrade trade = new SimpleTrade();
    trade.addAttribute(ATTR_NAME, TRADE_VALUE);
    position.addTrade(trade);
    assertEquals(POS_VALUE, _aggFn.classifyPosition(position));
  }
View Full Code Here

    sp.getTrades().addAll(getTrades());
    sp.setAttributes(this.getAttributes());
   
    // Workaround for PLAT-2371 until PLAT-2286
    if (this.getProviderId() != null) {
      sp.addAttribute(this.providerId().name(), this.getProviderId().toString());
    }

    if (this.getUniqueId() != null) { // may not have an id yet
      sp.setUniqueId(this.getUniqueId());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.