@Override public Map<String, Double> getClientNetPositions() { Map<String, Double> rtn = new HashMap<>(); for (Map.Entry<String, List<OrderOutcome>> clientOrderAuditEntry : inMemoryClientOrderAudit.entrySet()) { List<OrderOutcome> ordersForClient = clientOrderAuditEntry.getValue(); Double sumOfTransactionsPerDigicoin = 0d; Double allAmounts = 0d; for (OrderOutcome orderOutcome : ordersForClient) { sumOfTransactionsPerDigicoin += orderOutcome.getPrice() / Math.abs(orderOutcome.getOrder().getAmount()); allAmounts += orderOutcome.getOrder().getAmount(); } Double average = new Double(sumOfTransactionsPerDigicoin / ordersForClient.size()) * allAmounts; rtn.put( clientOrderAuditEntry.getKey(), new BigDecimal(average).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue()); } return rtn; }