Hi Jonathan - I've been working in a similar vein for some time. I appreciate your approach with FoldList and, like you, have struggled to put the parts together - so use loops everywhere. Your post helped me see how much of this simple trade accounting could be done in a FoldList and so I've merged some of yours with some of mine. In particular I've added more P&L accounting and expanded the step-by-step (across the table) so a user can start at the left, read numbers while doing arithmetic in their head, and confirm the results. Mined you, I've not spent much time auditing so there could be scenarios that need rework. In the code I've included comments regarding my preferences and various assumptions being make for these calculations.
Needless to say a full on trade accounting module is not a small project.
Attachments: