private static void extractSecurityRelatedPortfolioTransactions(
     Portfolio portfolio,
     ReportingPeriod period,
     Map<Security, SecurityPerformanceRecord> records) {
   portfolio
       .getTransactions()
       .stream() //
       .filter(period.containsTransaction()) //
       .forEach(t -> records.get(t.getSecurity()).addTransaction(t));
 }
  private static void addPseudoValuationTansactions(
      Portfolio portfolio,
      CurrencyConverter converter,
      ReportingPeriod period,
      Map<Security, SecurityPerformanceRecord> records) {
    PortfolioSnapshot snapshot =
        PortfolioSnapshot.create(portfolio, converter, period.getStartDate());
    for (SecurityPosition position : snapshot.getPositions()) {
      records
          .get(position.getSecurity())
          .addTransaction(new DividendInitialTransaction(position, period.getStartDate()));
    }

    snapshot = PortfolioSnapshot.create(portfolio, converter, period.getEndDate());
    for (SecurityPosition position : snapshot.getPositions()) {
      records
          .get(position.getSecurity())
          .addTransaction(new DividendFinalTransaction(position, period.getEndDate()));
    }
  }
  private static void extractSecurityRelatedAccountTransactions(
      Account account, ReportingPeriod period, Map<Security, SecurityPerformanceRecord> records) {
    for (AccountTransaction t : account.getTransactions()) {
      if (t.getSecurity() == null) continue;

      if (!period.containsTransaction().test(t)) continue;

      if (t.getType() == AccountTransaction.Type.DIVIDENDS //
          || t.getType() == AccountTransaction.Type.INTEREST) {
        DividendTransaction dt = new DividendTransaction();
        dt.setDate(t.getDate());
        dt.setSecurity(t.getSecurity());
        dt.setAccount(account);
        dt.setCurrencyCode(t.getCurrencyCode());
        dt.setAmount(t.getAmount());
        dt.setShares(t.getShares());
        dt.setNote(t.getNote());
        records.get(t.getSecurity()).addTransaction(dt);
      } else if (t.getType() == AccountTransaction.Type.TAX_REFUND) {
        records.get(t.getSecurity()).addTransaction(t);
      }
    }
  }