sim.mom.strategy {matiming} | R Documentation |
This function simulates the returns to the MOM strategy
sim.mom.strategy(totret, rfret, dates, capret=NULL, tc=0, shorts = FALSE, winsize=200)
totret |
the vector of total returns |
rfret |
the vector of risk-free returns |
dates |
the vector of dates |
capret |
the vector of capital gain returns |
tc |
the amount of one-way transaction costs (a scalar) |
shorts |
a logical value indicating the type of the strategy when a Sell signal is generated.
If |
winsize |
a vector or a scalar that determines the size of the window used to compute the MOM |
An object to be used by other functions. This object contains the returns to the simulated strategies and the description of each strategy
The trading signal is computed using the vector of capital gain returns capret
. If capret=NULL
,
then the trading signal is computed using the vector of total returns totret
.
If winsize
is a vector, then the function simulates a number
of trading strategies for all window sizes such that winsize
>1
Other strategy simulation functions:
sim.cdir.strategy()
,
sim.mac.strategy()
,
sim.macd.strategy()
,
sim.mae.strategy()
## Not run: data <- djia.monthly # use the monthly data for DJIA index dates <- index(data) data <- coredata(data) capret <- data[,"CAP"] totret <- data[,"TOT"] rfret <- data[,"RF"] tc <- 0.0025 # this defines 0.25% one-way transaction costs winsize <- 2:15 shorts <- FALSE results <- sim.mom.strategy(totret=totret, rfret=rfret, dates=dates, capret=capret, tc=tc, shorts=shorts, winsize=winsize) ## End(Not run)