---
title: "The Strategy - Package"
author: "J. Busch"
date: "`r Sys.Date()`"
output: 
  pdf_document:
    toc: true
vignette: >
  %\VignetteIndexEntry{The Strategy - Package}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r}
library(xts)
```

## 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

```{r}
library(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))

```

```{r, echo=FALSE, results='asis'}
# Plot MA(200)-strategy of first asset
plot(myStrat.MA200, which.assets=1, from="2015-01-01", main="HA")
```




> "He who gives up [code] safety for [code] speed deserves neither."
([via](https://twitter.com/hadleywickham/status/504368538874703872))
