Package com.opengamma.core.position

Examples of com.opengamma.core.position.Portfolio


    _versionCorrection = versionCorrection;
    _viewId = viewId;
    _targetResolver = targetResolver;
    _portfolioSupplier = portfolioSupplier;
    _portfolioEntityExtractor = portfolioEntityExtractor;
    Portfolio portfolio;
    if (primitivesOnly) {
      portfolio = null;
    } else {
      portfolio = EMPTY_PORTFOLIO;
    }
View Full Code Here


    return getGrid(gridType).getData(graphId, viewportId);
  }

  @Override
  public List<String> portfolioChanged() {
    Portfolio portfolio = _portfolioSupplier.get();
    List<UniqueIdentifiable> entities = PortfolioMapper.flatMap(portfolio.getRootNode(), _portfolioEntityExtractor);
    _cache.put(entities);
    // TODO ignore for now, causes problems when the view take a long time to recompile
    /*_portfolioGrid = _portfolioGrid.withUpdatedRows(portfolio);
    // TODO this is pretty conservative, refreshes all grids because the portfolio structure has changed
    return getGridIds();*/
 
View Full Code Here

  }

  @Override
  public Portfolio get() {
    if (_portfolioId != null) {
      Portfolio unresolvedPortfolio = _positionSource.getPortfolio(_portfolioId, _versionCorrection);
      return PortfolioCompiler.resolvePortfolio(unresolvedPortfolio, _executor, _securitySource);
    } else {
      return null;
    }
  }
View Full Code Here

    // REVIEW jonathan 2011-11-13 -- portfolio aggregation is currently painful. The positions obtained from the
    // position source during the orginal portfolio lookup contain munged identifiers that do not correspond to
    // anything in the position master. We end up rewriting the positions even though there is no need, then we cannot
    // clean them up when the portfolio is no longer required in case other portfolios have now referenced the new
    // positions.
    Portfolio basePortfolio = _positionSource.getPortfolio(basePortfolioId, VersionCorrection.LATEST);
    Portfolio resolvedPortfolio =
        PortfolioCompiler.resolvePortfolio(basePortfolio, Executors.newSingleThreadExecutor(), _securitySource);
    List<AggregationFunction<?>> aggregationFunctions = Lists.newArrayListWithCapacity(aggregatorNames.size());
    for (String aggregatorName : aggregatorNames) {
      AggregationFunction<?> aggregationFunction = _portfolioAggregators.get(aggregatorName);
      if (aggregationFunction == null) {
        throw new OpenGammaRuntimeException("Unknown aggregator '" + aggregatorName + "'");
      }
      aggregationFunctions.add(aggregationFunction);
    }
    PortfolioAggregator aggregator = new PortfolioAggregator(aggregationFunctions);
    Portfolio aggregatedPortfolio = aggregator.aggregate(resolvedPortfolio);
    return _portfolioSaver.savePortfolio(aggregatedPortfolio, false);
  }
View Full Code Here

    return _positionSource.getPortfolio(searchResult.getFirstDocument().getUniqueId(), VersionCorrection.LATEST);
  }

  private AvailableOutputs testPortfolio(final String portfolioName) {
    final long t1 = System.nanoTime();
    Portfolio portfolio = getPortfolio(portfolioName);
    final long t2 = System.nanoTime();
    portfolio = PortfolioCompiler.resolvePortfolio(portfolio, _executorService, _securitySource);
    final long t3 = System.nanoTime();
    final AvailableOutputs outputs = new AvailablePortfolioOutputs(portfolio, _functionRepository, _functionExclusionGroups, _marketDataAvailability, "?");
    final long t4 = System.nanoTime();
    s_logger.info("Fetch={}ms, Resolve={}ms, Outputs={}ms", new Object[] {(t2 - t1) / 1e6, (t3 - t2) / 1e6, (t4 - t3) / 1e6 });
    s_logger.info("Outputs for {}", portfolio.getName());
    for (final AvailableOutput output : outputs.getOutputs()) {
      s_logger.info("{}", output);
    }
    s_logger.info("Portfolio node outputs for {}", portfolio.getName());
    for (final AvailableOutput output : outputs.getPortfolioNodeOutputs()) {
      s_logger.info("{}", output);
    }
    s_logger.info("Position outputs for {}", portfolio.getName());
    for (final AvailableOutput output : outputs.getPositionOutputs()) {
      s_logger.info("{}", output);
    }
    for (final String securityType : outputs.getSecurityTypes()) {
      s_logger.info("{} security outputs for {}", securityType, portfolio.getName());
      for (final AvailableOutput output : outputs.getPositionOutputs(securityType)) {
        s_logger.info("{}", output);
      }
    }
    return outputs;
View Full Code Here

    @Override
    public void viewDefinitionCompiled(CompiledViewDefinition compiledViewDefinition, boolean hasMarketDataPermissions) {
      s_logger.debug("View definition compiled: '{}'", compiledViewDefinition.getViewDefinition().getName());
      // resolve the portfolio, it won't be resolved if the engine is in a different VM from the web components
      // if it's in the same VM then resolution is fairly cheap and doesn't touch the DB
      Portfolio portfolio = compiledViewDefinition.getPortfolio();
      Portfolio resolvedPortfolio;
      if (portfolio != null) {
        resolvedPortfolio = PortfolioCompiler.resolvePortfolio(portfolio, _executor, _securitySource);
      } else {
        resolvedPortfolio = null;
      }
View Full Code Here

      public String getName() {
        return "No filter";
      }

    });
    final Portfolio portfolio = filter.filter(samplePortfolio());
    //print(portfolio.getRootNode(), "TestNoFilter");
    assertShape(
        portfolio.getRootNode(),
        new Object[] {
            2, 0,
            new Object[] {
                2, 2,
                new Object[] {
View Full Code Here

          }
        }
        return true;
      }
    });
    final Portfolio portfolio = filter.filter(samplePortfolio());
    //print(portfolio.getRootNode(), "TestPositionFilter");
    assertShape(
        portfolio.getRootNode(),
        new Object[] {
            2, 0,
            new Object[] {
                2, 2,
                new Object[] {
View Full Code Here

  public void run() {
    int count = Integer.MIN_VALUE; // set to e.g. -10 to just consider the first 10 portfolios found
    for (final UniqueId portfolioId : getPortfolios()) {
      try {
        final long t1 = System.nanoTime();
        final Portfolio rawPortfolio = getPositionSource().getPortfolio(portfolioId, VersionCorrection.LATEST);
        final long t2 = System.nanoTime();
        final Portfolio resolvedPortfolio = PortfolioCompiler.resolvePortfolio(rawPortfolio, getExecutorService(), getSecuritySource());
        final long t3 = System.nanoTime();
        s_logger.debug("Got portfolio {} in {}ms", portfolioId, (double) (t2 - t1) / 1e6);
        s_logger.debug("Resolved portfolio {} in {}ms", portfolioId, (double) (t3 - t2) / 1e6);
        getExecutorService().execute(new Runnable() {
          @Override
View Full Code Here

    }

    @Override
    public boolean canApplyTo(final FunctionCompilationContext context, final ComputationTarget target) {
      // Applies to any portfolio node, except the root if "Don't aggregate root node" is set
      Portfolio portfolio = context.getPortfolio();
      if (portfolio == null || portfolio.getAttributes().get(IGNORE_ROOT_NODE) == null) {
        return true;
      } else {
        return target.getPortfolioNode().getParentNodeId() != null;
      }
    }
View Full Code Here

TOP

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

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.