I think you are going to have to go through it bit by bit. Start with your stream. To get back to your original post, start with the first line and print it.
List<Trade> aggregatedActivities = activities.stream
.collect(Collectors.groupingBy(a -> a.getHolder() + a.getStockID()))
.entrySet().stream()…
System.out.println(activities.stream());
I am pretty sure you missed out a pair of () which I have marked in red. You won't get a lot from that, but you will get an output. Streams don't override
Object#toString(), so you won't get an informative printout. If you want any more than that, change that to
activities.stream().forEach(System.out::println);
Now add the second stage (.collect(...)) and print that out. You will see what is happening to the Stream/Streams as you go. You will also be able to see what compiles and what won't.
Decide what your endpoint is, and see how you are working towards that. Add ore code, but by bit and print it with either of the versions I showed (both use System.out.println somewhere). You will probably get there by adding little bits at a time and
testing them all as you go.
You have a difficult task getting all that lot to work if you aren't experienced with Streams. Have you been through the
Java Tutorials and seen how Streams work with collections? Have you been through the Stream documentation, because some of the methods have examples shown?