Examples of MarketSummary


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

    portfolioSummary.setTotalMarketValue(MARKET_VALUE);
    return portfolioSummary;
  }

  public MarketSummary marketSummary() {
    MarketSummary marketSummary = new MarketSummary();
    marketSummary.setSummaryDate(new Date(1329759342904l));
    marketSummary.setTradeStockIndexAverage(MARKET_INDEX);
    marketSummary.setTradeStockIndexOpenAverage(MARKET_OPENING);
    marketSummary.setTradeStockIndexVolume(MARKET_VOLUME);
    List<Quote> loserQuotes = new ArrayList<Quote>();
    loserQuotes.add(quote());
    marketSummary.setTopLosers(loserQuotes);
    List<Quote> gainingQuotes = new ArrayList<Quote>();
    gainingQuotes.add(quote());
    marketSummary.setTopGainers(gainingQuotes);
    return marketSummary;
  }
View Full Code Here

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

  public void setEntityManager(EntityManager em) {
    this.em = em;
  }

  public MarketSummary findMarketSummary() {
    MarketSummary marketSummary = new MarketSummary();
    Query query = em
        .createQuery("SELECT SUM(q.price)/count(q) as tradeStockIndexAverage, "
            + "SUM(q.open1)/count(q) as tradeStockIndexOpenAverage, "
            + "SUM(q.volume) as tradeStockIndexVolume, "
            + "SUM(q) as cnt , "
            + "SUM(q.change1)"
            + "FROM Quote q");
    marketSummary.setTradeStockIndexAverage(BigDecimal.ZERO.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
    marketSummary.setTradeStockIndexOpenAverage(BigDecimal.ZERO.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
    marketSummary.setTradeStockIndexVolume(BigDecimal.ZERO.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
    marketSummary.setChange(BigDecimal.ZERO.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
    @SuppressWarnings("unchecked")
    List<Object[]> result = query.getResultList();
    for (Object[] o : result) {
      if (o[0] != null && o[1] != null && o[2] != null && o[3] != null && o[4] != null) {
        marketSummary.setTradeStockIndexAverage(((BigDecimal) o[0])
            .setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));

        marketSummary.setTradeStockIndexOpenAverage(((BigDecimal) o[1])
            .setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));

        marketSummary.setTradeStockIndexVolume(((BigDecimal) o[2])
            .setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
        marketSummary.setChange(((BigDecimal) o[4]));
      }
    }

    return marketSummary;
  }
View Full Code Here

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

        quote2.setChange1(BigDecimal.valueOf(4.00));
        quote2.setOpen1(BigDecimal.valueOf(120.00));
        quoteService.saveQuote(quote2);
        entityManager.flush();
    entityManager.clear(); // force reload
    MarketSummary marketSummary = tradingService.findMarketSummary();
    // need to harden this test!!
    Assert.assertTrue("Expected 'MarketSummary' Market Volume should be => than 200000", marketSummary.getTradeStockIndexVolume().intValue() >= 200000);


  }
View Full Code Here

Examples of org.springframework.nanotrader.service.domain.MarketSummary

    public MarketSummary findMarketSummary() {
        if (log.isDebugEnabled()) {
            log.debug("TradingServiceFacade.findMarketSummary: Start");
        }
        org.springframework.nanotrader.data.domain.MarketSummary marketSummary = tradingService.findMarketSummary();
        MarketSummary marketSummaryResponse = new MarketSummary();
        mapper.map(marketSummary, marketSummaryResponse, MARKET_SUMMARY_MAPPING);
        if (log.isDebugEnabled()) {
            log.debug("TradingServiceFacade.findMarketSummary: completed successfully.");
        }
        return marketSummaryResponse;
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.