For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Daily Absolute PnL For A Strategy

  • Hello,

    Is there a way to get the absolute daily PnL for a strategy? I am aware of the Time Return analyzer, but it calculates the returns on the beginning of a timeframe. What I require is, say if I am testing a strategy from Jun 1, 2019 to Sep 1, 2019, then I want to get daily profit / loss (in absolute sense rather than a percent return) as well as cumulative profit / loss for this time period. Is there a direct way to do this, without having to calculate the same via Time Return?

  • I believe that TimeReturn analyzer with the timeframe parameter set to TimeFrame.Days will calculate daily returns in %s. So at first glance the easiest way will be just to repeat TimeReturn analyzer code with the small change:


    self.rets[self.dtkey] = (self._value / self._value_start) - 1.0


    self.rets[self.dtkey] = self._value - self._value_start

  • @ab_trader Thanks. So apparently, inheriting TimeReturn would be the only elegant way to go forward. I implemented that and it works perfectly.

Log in to reply