Skip to content
Prev 7851 / 15274 Next

EndEquity lower than initEq despite positive p/l

S
On 5/6/11 8:31 AM, Brian G. Peterson wrote:
Thank you Brian for taking a look at this. I appreciate your time.

This problem feeds into other functionalities, which you probably
already know but I thought I would provide more details just in case.

For example:

charts.PerformanceSummary(ROC(getAccount(account.st)$summary$End.Eq)[-1])

What happens is that the call to log(x), where x is the daily equity
value produces -Inf for Log(0) and NaN for log(-negative values). As a
result the log(x) values you see below are fed to chart.TimeSeries where
it fails.

exiting from: checkData(R)
Error in plot.window(xlim, ylim, xaxs = "r", log = logaxis) :
  need finite 'ylim' values

debug: {
    if (type == "discrete") {
        roc <- x/lag(x, n, na.pad = na.pad) - 1
    }
    if (type == "continuous") {
        roc <- diff(log(x), n, na.pad = na.pad)
    }
    reclass(roc, x)
}

----snippet of log(end equity) below ---

2008-09-30     -Inf
2008-10-01     -Inf
2008-10-02     -Inf
2008-10-03     -Inf
2008-10-06     -Inf
2008-10-07     -Inf
2008-10-08     -Inf
2008-10-09     -Inf
2008-10-10 8.191097
2008-10-13      NaN
2008-10-14      NaN
2008-10-15      NaN
2008-10-16      NaN
2008-10-17      NaN
2008-10-20      NaN
2008-10-21      NaN
2008-10-22      NaN

----snippet of end equity below ----

2008-09-30     0.00
2008-10-01     0.00
2008-10-02     0.00
2008-10-03     0.00
2008-10-06     0.00
2008-10-07     0.00
2008-10-08     0.00
2008-10-09     0.00
2008-10-10  3608.68
2008-10-13 -3053.23
2008-10-14 -2154.78
2008-10-15 -2518.47
2008-10-16  -705.72
2008-10-17  -671.87
2008-10-20   -20.29
2008-10-21 -1837.16
2008-10-22 -4495.50

This leads me to think about the situation where initial equity is set
correctly but draw downs have wiped out the equity and are again
producing negative end equity values. In real life this wouldnt be an
issue as your trading would end if that were to happen. But for purposes
of backtesting I could set an initial equity value that could be easily
wiped out by draw downs.  Not sure if you want to address that or leave
it up to the user to set initial equity values that are appropriate for
the size of their trading.