best.is.strategies {matiming}R Documentation

Reports the best trading strategies in a back-test (in-sample test)

Description

This function reports the best trading strategies in a back-test

Usage

best.is.strategies(results, to.annual=sqrt(12), plot.results=FALSE)

Arguments

results

the results returned by function back.test

to.annual

a coefficient used to annualize the performance measure. For example, when the performance is measured using either Sharpe or Sortino, use sqrt(252) and sqrt(12) when the returns are at the daily and monthly frequency respectively. If the performance is measred by Excret, use 12

plot.results

a logical value indicating whether to plot the cumulative returns to the best trading strategies and to the buy-and-hold strategy

Value

An object of class data.frame containing three columns: Rank, Rule, and Performance.

See Also

Other strategy summary functions: descriptive.statistics()

Examples

## Not run: 
library(matiming)
library(xtable)
library(zoo)

data <- sp500.monthly
dates <- index(data)
data <- coredata(data)
capret <- data[,"CAP"]
totret <- data[,"TOT"]
rfret <- data[,"RF"]

tc <- 0.0025
fast <- 1:9
slow <- 2:18

res.mac <- sim.mac.strategy(totret=totret, rfret=rfret, dates=dates,
                            capret=capret, tc=tc, fast=fast, slow=slow, FUN=SMA)

res.mom <- sim.mom.strategy(totret=totret, rfret=rfret, dates=dates,
                            capret=capret, tc=tc, winsize=slow)

results <- sim.results.merge(res.mac, res.mom)

start.date <- as.Date("1950-01-01", format="%Y-%m-%d")
end.date <- as.Date("2010-12-31", format="%Y-%m-%d")
n.first <- 10
include.bh <- TRUE

res <- back.test(results, start.date=start.date, end.date=end.date,
                       n.first=n.first, include.bh=include.bh, FUN=Sharpe)

df <- best.is.strategies(res, plot.results=TRUE)
xtab <- xtable(df, digits=3)
print(xtab, include.rownames=FALSE)

## End(Not run)

[Package matiming version 1.0 Index]