Package com.opengamma.core.position

Examples of com.opengamma.core.position.Position


        final double premium = _prices[i];
        final ManageableTrade trade = new ManageableTrade(n, getSecurityPersister().storeSecurity(_securities[i]), _tradeDate.toLocalDate(),
            _tradeDate.toOffsetDateTime().toOffsetTime(), ExternalId.of(Counterparty.DEFAULT_SCHEME, COUNTERPARTY));
        trade.setPremium(premium);
        trade.setPremiumCurrency(CURRENCY);
        final Position position = SimplePositionGenerator.createPositionFromTrade(trade);
        node.addPosition(position);
      }
      return node;
    }
View Full Code Here


    final PortfolioNode node = getPortfolioNode(positions, name);
    return node.getPositions().get(0);
  }

  private Trade getTrade(final PositionSource positions, final String name) {
    final Position position = getPosition(positions, name);
    return position.getTrades().iterator().next();
  }
View Full Code Here

  public void testPositionSpecific() {
    final DependencyGraphBuilder builder = createBuilder();
    final ViewCalculationConfiguration config = builder.getCompilationContext().getViewCalculationConfiguration();
    final PositionSource positions = builder.getCompilationContext().getPortfolioStructure().getPositionSource();
    final Position position1 = getPosition(positions, "PositionAttr");
    config.setDefaultProperties(ValueProperties.with("POSITION.Present Value.DEFAULT_ForwardCurve." + position1.getUniqueId(), "BarForward")
        .with("POSITION.*.DEFAULT_FundingCurve." + position1.getUniqueId(), "BarFunding").get());
    final ValueRequirement req1 = createValueRequirement(ComputationTargetSpecification.of(position1), ValueProperties.none());
    final ValueRequirement req2 = createValueRequirement(ComputationTargetSpecification.of(getPosition(positions, "Position")), ValueProperties.none());
    builder.addTarget(req1);
    builder.addTarget(req2);
    builder.getDependencyGraph();
View Full Code Here

  public void testPositionSpecificOverride() {
    final DependencyGraphBuilder builder = createBuilder();
    final ViewCalculationConfiguration config = builder.getCompilationContext().getViewCalculationConfiguration();
    final PositionSource positions = builder.getCompilationContext().getPortfolioStructure().getPositionSource();
    final Position position1 = getPosition(positions, "PositionAttr");
    config.setDefaultProperties(ValueProperties.with("POSITION.Present Value.DEFAULT_ForwardCurve." + position1.getUniqueId(), "BarForward")
        .with("POSITION.*.DEFAULT_FundingCurve." + position1.getUniqueId(), "BarFunding").with("POSITION.*.DEFAULT_ForwardCurve", "GenericForward")
        .with("POSITION.Present Value.DEFAULT_FundingCurve", "GenericFunding").get());
    final ValueRequirement req1 = createValueRequirement(ComputationTargetSpecification.of(position1), ValueProperties.none());
    final ValueRequirement req2 = createValueRequirement(ComputationTargetSpecification.of(getPosition(positions, "Position")), ValueProperties.none());
    builder.addTarget(req1);
    builder.addTarget(req2);
View Full Code Here

  }

  @Test
  public void testPositionWithUnlocatableSecurityIsIgnored() {

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

    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

  }

  @Test
  public void testPositionWithUnlocatableSecurityIsIgnored() {

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

    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

    }
    ComputationTargetType targetType = row.getTarget().getType();
    details.put("type", targetType.toString());

    if (targetType == ComputationTargetType.POSITION) {
      Position position = row.getPosition();
      details.put("posId", position.getUniqueId());
      details.put("position", position.getSecurity().getName());
      DoubleValueFormatter formatter = new DoubleValueOptionalDecimalPlaceFormatter();
      details.put("quantity", position.getQuantity().signum() == 0 ? "0" : formatter.format(position.getQuantity()));
    } else {
      details.put("position", row.getAggregateName());
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.core.position.Position

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.