new AccountBuilder() //
.deposit_(startDate, 100 * Values.Amount.factor()) //
.interest(startDate.plusDays(10), 10 * Values.Amount.factor()) //
.addTo(client);
Security security = new SecurityBuilder() //
.generatePrices(50 * Values.Amount.factor(), middleDate, endDate) //
.addTo(client);
// calculate performance indices
List<Exception> warnings = new ArrayList<Exception>();
ReportingPeriod reportInterval = new ReportingPeriod.FromXtoY(startDate.toDate(), endDate.toDate());
ClientIndex clientIndex = PerformanceIndex.forClient(client, reportInterval, warnings);
PerformanceIndex securityIndex = PerformanceIndex.forSecurity(clientIndex, security, warnings);
// asserts
assertTrue(warnings.isEmpty());
Date[] clientDates = clientIndex.getDates();
Date[] securityDates = securityIndex.getDates();
assertThat(securityDates[0], is(middleDate.toDate()));
assertThat(securityDates[securityDates.length - 1], is(endDate.toDate()));
assertThat(new DateMidnight(clientDates[clientDates.length - 1]), is(new DateMidnight(
securityDates[securityDates.length - 1])));
double[] clientAccumulated = clientIndex.getAccumulatedPercentage();
double[] securityAccumulated = securityIndex.getAccumulatedPercentage();
int index = Days.daysBetween(startDate, middleDate).getDays();
assertThat(new DateMidnight(clientDates[index]), is(middleDate));
assertThat(securityAccumulated[0], IsCloseTo.closeTo(clientAccumulated[index], 0.000001d));
long middlePrice = security.getSecurityPrice(middleDate.toDate()).getValue();
long lastPrice = security.getSecurityPrice(endDate.toDate()).getValue();
// 10% is interest of the deposit
double performance = (double) (lastPrice - middlePrice) / (double) middlePrice + 0.1d;
assertThat(securityAccumulated[securityAccumulated.length - 1], IsCloseTo.closeTo(performance, 0.000001d));
}