Grouping a list of objects by multiple fields and conditional checks and also finding aggregate value in java 17
I have a list of Trade class which has fields like buy amount, buy currency, sell amount, sell currency, buy sell flag, settlement date, account, execution date time etc. I also have a lookback period of time in minutes (which I’ll get from the application.yml file). Now, I want to aggregate buy amount by grouping the trades into combination of account, settlement date and buy currency for all trades within execution date time minus the lookback period. Similarly, I want to aggregate sell amount by grouping them into combination of account, settlement date and sell currency for all trades within execution date time minus the lookback period.