![]() The timeseries version of the function provides the output as a timeseries object in Quantity format and, of course, can be plotted immediately with DateListPlot (it is also convenient for other reasons, as the complete backtest system is built around timeseries objects): tsTradePL = CalculateRealizedPLFromTrades The starting point is to come up with a FoldList compatible function that does the necessary calculations:ĬalculateRealizedTradePL But it can be challenging to get one’s head around the appropriate construct using functions like FoldList, etc, especially as there are often edge cases to be taken into consideration.Ī case in point is the issue of calculating the profit and loss from individual trades in a trading strategy. ![]() This can usually be accomplished with some thought, and the efficiency gains can be significant. One of the challenges when building systems in WL is to avoid looping wherever possible. ![]() This is a snippet from a strategy backtesting system that I am currently building in Mathematica.
0 Comments
Leave a Reply. |