Package com.opengamma.core.position.impl

Examples of com.opengamma.core.position.impl.SimplePosition


    ExternalId secId = ExternalId.of("SEC_ID", "12345");
    security.addExternalId(secId);
    document.setSecurity(security);
    _securityMaster.add(document);

    Position posn = new SimplePosition(BigDecimal.ONE, secId);
    assertEquals(_aggregator.classifyPosition(posn), "N/A");
  }
View Full Code Here


    ExternalId secId = ExternalId.of("SEC_ID", "12345");
    cds.addExternalId(secId);
    document.setSecurity(cds);
    _securityMaster.add(document);

    Position posn = new SimplePosition(BigDecimal.ONE, secId);

    assertEquals(_aggregator.classifyPosition(posn), "39FF64");
  }
View Full Code Here

    trade.setSecurityLink(createSecurityLink(securities));
    return trade;
  }

  private SimplePosition createPosition(final SecuritySource securities) {
    final SimplePosition position = new SimplePosition();
    position.setQuantity(BigDecimal.ONE);
    position.setSecurityLink(createSecurityLink(securities));
    return position;
  }
View Full Code Here

    // Portfolio node with position with a trade with an attribute
    SimplePortfolioNode node = new SimplePortfolioNode("TradeAttr");
    SimpleTrade trade = createTrade(securities);
    trade.addAttribute("Present Value.DEFAULT_ForwardCurve", "FooForward");
    trade.addAttribute("*.DEFAULT_FundingCurve", "FooFunding");
    SimplePosition position = createPosition(securities);
    position.addTrade(trade);
    node.addPosition(position);
    root.addChildNode(node);
    // Portfolio node with position with a trade without an attribute
    node = new SimplePortfolioNode("Trade");
    trade = createTrade(securities);
    position = createPosition(securities);
    position.addTrade(trade);
    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");
    position = createPosition(securities);
View Full Code Here

  public static final String TRADE_VALUE = "TRADE_VALUE";
  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));
  }
View Full Code Here

    assertEquals(POS_VALUE, _aggFn.classifyPosition(position));
  }

  @Test
  public void tradeAttribute() {
    SimplePosition position = new SimplePosition();
    SimpleTrade trade = new SimpleTrade();
    trade.addAttribute(ATTR_NAME, TRADE_VALUE);
    position.addTrade(trade);
    assertEquals(TRADE_VALUE, _aggFn.classifyPosition(position));
  }
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

    trade.addAttribute("Foo", Integer.toString(attribSource.getAndIncrement()));
    return trade;
  }

  private static SimplePosition samplePosition(final AtomicInteger attribSource) {
    final SimplePosition position = new SimplePosition();
    position.addTrade(sampleTrade(attribSource));
    return position;
  }
View Full Code Here

   * The interface contains different data to this class due to database design.
   *
   * @return the security from the link, null if not resolve
   */
  public SimplePosition toPosition() {
    SimplePosition sp = new SimplePosition();
    sp.setQuantity(this.getQuantity());
    sp.setSecurityLink(this.getSecurityLink());
    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());
    }

    return sp;
  }
View Full Code Here

  @Test
  public void getResultsTest_1() {
    FunctionCompilationContext fcctx = mock(FunctionCompilationContext.class);
    DV01_test_fun dv01 = new DV01_test_fun();

    assertTrue(dv01.canApplyTo(fcctx, new ComputationTarget(ComputationTargetType.POSITION, new SimplePosition())));

    ComputationTargetSpecification cts = new ComputationTargetSpecification(ComputationTargetType.POSITION, UniqueId.of("a", "b"));
    ComputationTarget ct = mock(ComputationTarget.class);
    when(ct.toSpecification()).thenReturn(cts);
    Set<ValueSpecification> specs = dv01.getResults(null, ct);
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.impl.SimplePosition

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.