Group Abstract Group Abstract

Message Boards Message Boards

Trading strategy backtesting: calculating trade profit and loss

POSTED BY: Jonathan Kinlay
5 Replies
POSTED BY: Clarisse Wagner

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:

This is interesting but I am suspicious of Do loops being an order of magnitude slower for this purpose.

(1) Did you ascertain that both give the same result? (I assume so.)

(2) Did you do anything to locate possible bottlenecks? This is admittedly not so easy. I usually do pedestrian things like add Print and Timing in various places. These are blunt tools but nevertheless can be effective. I have learned that often enough the problem is not what or where I would have expected.

POSTED BY: Daniel Lichtblau
POSTED BY: Jonathan Kinlay

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard