forward.test {matiming} | R Documentation |
This function simulates the returns to the out-of-sample trading strategy
forward.test(results, start.date, end.is.date, end.oos.date, refit.every=1, rolling=FALSE, include.bh=FALSE, FUN=Sharpe)
results |
the results of simulation of a trading strategy or multiple trading strategies.
Specifically, this is the result returned by function |
start.date |
the start of the in-sample period |
end.is.date |
the end of the initial in-sample period |
end.oos.date |
the end of the out-of-sample period |
refit.every |
this parameter determines how often the best trading strategy in a back test is determined |
rolling |
a logical value indicating whether to use the expanding (if FALSE) or rolling (if TRUE) in-sample window |
include.bh |
a logical value indicating whether to consider the Buy-and-Hold (bh) strategy in addition to the moving average strategies |
FUN |
the function that computes the performance of a trading strategy |
An object to be used by other functions
The argument results
contains the dates vector that defines the historical period
over which the trading strategies are simulated. The function FUN
is either Excret
,
Sharpe
, or Sortino
.
This function only simulates the out-of-sample strategy; to test the outperformance
hypothesis, use either function outperformance.test
or function descriptive.statistics.
Other strategy testing functions:
back.test()
,
outperformance.test()
## Not run: library(matiming) library(xtable) library(zoo) # access the data data <- sp500.monthly dates <- index(data) data <- coredata(data) capret <- data[,"CAP"] totret <- data[,"TOT"] rfret <- data[,"RF"] # simulate the trading strategies tc <- 0.0025 fast <- 1:5 slow <- 2:15 shorts <- F results <- sim.mac.strategy(totret=totret, rfret=rfret, dates=dates, capret=capret, tc=tc, shorts=shorts, fast=fast, slow=slow, FUN=SMA) # perform the out-of-sample test start.date <- as.Date("1930-01-01", format="%Y-%m-%d") end.is.date <- as.Date("1949-12-31", format="%Y-%m-%d") end.oos.date <- as.Date("2015-12-31", format="%Y-%m-%d") refit.every <- 5 include.bh <- TRUE rolling <- TRUE res <- forward.test(results, start.date=start.date, end.is.date=end.is.date, end.oos.date=end.oos.date, refit.every=refit.every, rolling=rolling, include.bh=include.bh, FUN=Sortino) # report the descriptive statistics and the p-value of the test df <- descriptive.statistics(res) xtab <- xtable(df, digits=2) print(xtab) ## End(Not run)