cReturns {ttrTests} | R Documentation |
For a series x(t) and a given TTR, computes - the return series r(t) = ln( x(t+1) / x(t) ) - the conditional return series, r(t)*s(t), where s(t) is the position indicated by the TTR i.e. s(t) = 1 for long, -1 for short, 0 for neutral
cReturns(x, ttr = "macd4", params = 0, burn = 0, short = FALSE, condition = NULL, TC = 0.001)
x |
The data set |
ttr |
The TTR to be used. Can be a character string for built-in TTRs, or a user defined function whose output is a position series s(t). See 'defaults' for a list of built-in TTRs. |
params |
Used to compute the TTR. Will be passed to a user defined function. Hence a user defined function should have at least 2 inputs, the data set and a vector or list of parameters |
burn |
When computing the position function s(t), values for t < burn will be forced to 0, i.e. no position held during the 'burn' period |
short |
Logical. If false the position function s(t) will be forced to 0 when it would otherwise be -1, i.e. no short selling |
condition |
An extra opportunity to restrict the TTR so that position is forced to 0 under some condition. Must be a binary string of the same length as the data 'x'. See 'position' for more details. |
TC |
Trading cost, as a percentage. Used to compute an adjusted average return. |
cReturns |
The conditional returns series |
aReturns |
The mean one-period return, adjusted for trading costs |
EXTREMELY IMPORTANT NOTE: The functions in this package evaluate past performance only. No warranty is made that the results of these tests should, or even can, be used to inform business decisions or make predictions of future events.
The author does not make any claim that any results will predict future performance. No such prediction is made, directly or implied, by the outputs of these function, and any attempt to use these function for such prediction is done solely at the risk of the end user.
David St John
William Brock, Josef Lakonishok, and Blake LeBaron. Simple technical trading rules and the stochastic properties of stock returns. The Journal of Finance, 47(5):1731-1764, 1992.
## Is the mean conditional return higher than the mean unconditional return? spData <- as.vector(getYahooData("SPY",start="20060101",end="20081231")[,"Close"]) mean(diff(log(spData))) cr <- cReturns(spData) mean(cr)