The Strategy - Package
J. Busch
2016-12-09
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Structure of Strategy-Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Introduction
This package allows users to apply customizable quantitative trading strategies to historical portfolio data. An
S4 class called “Strategy” is implemented that creates objects from which vaious performance measurements
may be extracted, visualized and compared. A template for custom quantitative strategies is available and so
the package can be extended in an easy way and still all methods are available for consistent evaluations.
Structure of Strategy-Objects
A Strategy-object contains all relevant information about the strategy executed on the portfolio data.
Dependent packages are zoo and xts.
Data
There is no data available within this package.
Examples
require(Strategy)
# Generate positive random walks for random assets
set.seed(2)
len <- 1000
n <- 10
assets <- abs(apply(matrix(rnorm(n*len), ncol=n), 2, cumsum)) + 100
colnames(assets) <- paste0("asset", 1:n)
assets <- xts(assets, order.by = seq(from=Sys.Date()-len, length.out=len, by="d"))
# MA(200)-strategy
myStrat.MA200 <- Strategy(assets = assets
, strat = "MA"
, strat.params = list(k=200))
1
Jan 01 2015
2
Dec
Dec 01
08 2016
2016
Nov 01 2016
Oct 01 2016
Sep 01 2016
Aug 01 2016
Jul 01 2016
Jun 01 2016
May 01 2016
Apr 01 2016
Feb 01 2016
Mar 01 2016
Jan 01 2016
Dec 01 2015
Nov 01 2015
Oct 01 2015
Sep 01 2015
Aug 01 2015
Jul 01 2015
Jun 01 2015
May 01 2015
Apr 01 2015
Feb 01 2015
Mar 01 2015
HA
170
160
150
asset1
MA(200)
140
130
120
110
Position
1.30
1.25
1.20
1.15
1.10
1.05
1.00
0.95
“He who gives up [code] safety for [code] speed deserves neither.” (via)
Performance
© Copyright 2026 Paperzz