Package org.springframework.nanotrader.data.domain

Examples of org.springframework.nanotrader.data.domain.PortfolioSummary


    return holdings;
  }
 
 
  public PortfolioSummary portfolioSummary() {
    PortfolioSummary portfolioSummary = new PortfolioSummary();
    portfolioSummary.setNumberOfHoldings(HOLDING_COUNT);
    portfolioSummary.setTotalBasis(BASIS);
    portfolioSummary.setTotalMarketValue(MARKET_VALUE);
    return portfolioSummary;
  }
View Full Code Here


    this.em = em;
  }

  @Override
  public PortfolioSummary findPortfolioSummary(Integer accountId) {
    PortfolioSummary portfolioSummary = new PortfolioSummary();
    Query query = em.createQuery("SELECT SUM(h.purchaseprice * h.quantity) as purchaseBasis, sum(q.price * h.quantity) as marketValue, count(h) FROM Holding h, Quote q Where h.accountAccountid =:accountId and h.quoteSymbol=q.symbol  ORDER BY marketValue desc");
    query.setParameter("accountId", accountId);
    @SuppressWarnings("unchecked")
    List<Object[]> result = query.getResultList();
    for (Object[] o: result) {
      BigDecimal price = (BigDecimal)o[0];
      BigDecimal marketValue = (BigDecimal)o[1];
      Long countOfHoldings = (Long)o[2];
      portfolioSummary.setTotalBasis(price);
      portfolioSummary.setTotalMarketValue(marketValue);
      portfolioSummary.setNumberOfHoldings(countOfHoldings.intValue());
    }


    return portfolioSummary;
  }
View Full Code Here

        quote.setVolume( BigDecimal.valueOf(50000));
        quoteService.saveQuote(quote);
        entityManager.flush();
    entityManager.clear(); // force reload
        Assert.assertNotNull("Expected 'Quote' identifier to no longer be null", quote.getQuoteid());
    PortfolioSummary portfolioSummary = tradingService.findPortfolioSummary(100);
    Assert.assertTrue("Expected 'PortfolioSummary' holding count to be equal to 1", portfolioSummary.getNumberOfHoldings() == 1);


  }
View Full Code Here

TOP

Related Classes of org.springframework.nanotrader.data.domain.PortfolioSummary

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.