private PerformanceIndex getClientIndex(List<Exception> warnings) {
   PerformanceIndex index = dataCache.get(Client.class);
   if (index == null) {
     ReportingPeriod interval = getReportingPeriod();
     index = PerformanceIndex.forClient(getClient(), interval, warnings);
     dataCache.put(Client.class, index);
   }
   return index;
 }
Esempio n. 2
0
  @Test
  public void testVolatilityOfSharesHeldIsIdenticalToExcel() throws IOException {
    ReportingPeriod report =
        new ReportingPeriod.FromXtoY(Dates.date("2014-01-31"), Dates.date("2014-07-31"));
    List<Exception> warnings = new ArrayList<>();
    PerformanceIndex index = PerformanceIndex.forClient(client, report, warnings);

    assertThat(warnings, empty());
    assertThat(
        index.getVolatility().getStandardDeviation(), closeTo(0.01251323582, 0.000001)); // excel
  }
Esempio n. 3
0
  @Test
  public void testVolatilityIfBenchmarkHasNoQuotes() throws IOException {
    ReportingPeriod report =
        new ReportingPeriod.FromXtoY(Dates.date("2014-01-31"), Dates.date("2015-01-31"));
    List<Exception> warnings = new ArrayList<>();

    PerformanceIndex index = PerformanceIndex.forClient(client, report, warnings);

    Security sap =
        client.getSecurities().stream().filter(s -> "Sap AG".equals(s.getName())).findAny().get();
    PerformanceIndex sapIndex = PerformanceIndex.forSecurity(index, sap, warnings);

    assertThat(warnings, empty());
    // quotes only until December 31st
    assertThat(sapIndex.getDates()[sapIndex.getDates().length - 1], is(Dates.date("2014-12-31")));
    assertThat(
        sapIndex.getVolatility().getStandardDeviation(),
        closeTo(0.0126152529671108, 0.00001)); // excel
  }
Esempio n. 4
0
  @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()));
  }