private void addSecurityPerformance( DataSeries item, Security security, List<Exception> warnings) { PerformanceIndex securityIndex = dataCache.get(security.getUUID()); if (securityIndex == null) { securityIndex = PerformanceIndex.forInvestment(getClient(), security, getReportingPeriod(), warnings); dataCache.put(security.getUUID(), securityIndex); } addScatterSeries(item, securityIndex); }
@Test public void testVolatilityIfSecurityIsSoldAndLaterBoughtDuringReportingPeriod() throws IOException { ReportingPeriod report = new ReportingPeriod.FromXtoY(Dates.date("2014-01-31"), Dates.date("2015-02-20")); List<Exception> warnings = new ArrayList<>(); Security basf = client.getSecurities().stream().filter(s -> "Basf SE".equals(s.getName())).findAny().get(); PerformanceIndex index = PerformanceIndex.forInvestment(client, basf, report, warnings); assertThat(warnings, empty()); assertThat( index.getVolatility().getStandardDeviation(), closeTo(0.0134468200485513, 0.00001)); // excel assertThat(index.getDates()[index.getDates().length - 1], is(Dates.date("2015-02-20"))); }
@Test public void testVolatilityIfSecurityIsSoldDuringReportingPeriod() throws IOException { ReportingPeriod report = new ReportingPeriod.FromXtoY(Dates.date("2014-01-31"), Dates.date("2015-01-31")); List<Exception> warnings = new ArrayList<>(); Security basf = client.getSecurities().stream().filter(s -> "Basf SE".equals(s.getName())).findAny().get(); PerformanceIndex index = PerformanceIndex.forInvestment(client, basf, report, warnings); assertThat(warnings, empty()); assertThat( index.getVolatility().getStandardDeviation(), closeTo(0.01371839502, 0.00001)); // excel assertThat(index.getDates()[index.getDates().length - 1], is(Dates.date("2015-01-31"))); // compare with client -> must be lower because cash has volatility of 0 PerformanceIndex clientIndex = PerformanceIndex.forClient(client, report, warnings); assertThat( clientIndex.getVolatility().getStandardDeviation(), lessThan(index.getVolatility().getStandardDeviation())); }