Package org.springframework.nanotrader.data.domain

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


  public HoldingSummary holdingSummary() {
    HoldingSummary holdingSummary = new HoldingSummary();
    List<HoldingAggregate> holdings = new ArrayList<HoldingAggregate>();
    holdingSummary.setHoldingsTotalGains(HOLDING_SUMMARY_GAINS.setScale(2, RoundingMode.HALF_UP));
    HoldingAggregate holding1 = new HoldingAggregate();
    holding1.setSymbol(SYMBOL);
    holding1.setGain(GAIN1.setScale(2, RoundingMode.HALF_UP));
    holding1.setPercent(FinancialUtils.calculateGainPercentage(holding1.getGain(), holdingSummary.getHoldingsTotalGains()).setScale(2, RoundingMode.HALF_UP));
    holdings.add(holding1);
    HoldingAggregate holding2 = new HoldingAggregate();
    holding2.setSymbol(SYMBOL2);
    holding2.setGain(GAIN2.setScale(2, RoundingMode.HALF_UP));
    holding2.setPercent(FinancialUtils.calculateGainPercentage(holding2.getGain(), holdingSummary.getHoldingsTotalGains()).setScale(2, RoundingMode.HALF_UP));
    holdings.add(holding2);
    holdingSummary.setHoldingRollups(holdings);
    return holdingSummary;
  }
View Full Code Here


    List<Object[]> result = query.getResultList();
    int counter = 0;
    // Need to loop over all the aggregated symbols to calculate the totalGain of all the stocks
    // but only want the top N stocks returned.
    for (Object[] o : result) {
      HoldingAggregate summary = new HoldingAggregate();
      String symbol = (String) o[0];
      BigDecimal gain = (BigDecimal) o[1];
      gain = gain.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND);
      totalGains = totalGains.add(gain);
      if (counter < TOP_N) {
        summary.setSymbol(symbol);
        summary.setGain(gain);
        holdingRollups.add(summary);
      }
      counter++;
    }
    holdingSummary.setHoldingsTotalGains(totalGains);
View Full Code Here

    }
    // Since we are only showing the Top N symbols, lump all others into the Other bucket
    // at this point if we are still @ 100%, then no records were found
    // also trying to prevent Other showing simply due to rounding (hence  > 1)
    if (hundredPercent > 1 && hundredPercent != 100) {
      HoldingAggregate summary = new HoldingAggregate();
      summary.setSymbol("Other");
      summary.setPercent(BigDecimal.valueOf(hundredPercent));
      summary.setGain(gainsRemainder);
      holdingRollups.add(summary);
    }
    holdingSummary.setHoldingRollups(holdingRollups);
   
    return holdingSummary;
View Full Code Here

TOP

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

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.