Description Details Author(s) References See Also Examples
A collection of utilities to help back testing of trading strategies. Mostly written in C++, thus, speed is not an issue.
Package: | btutils |
Type: | Package |
Version: | 0.1 |
Date: | 2013-05-07 |
Best place to start:
simple.trade.indicator
processTrades
Ivan Popivanov
Maintainer: Ivan Popivanov <ivan *dot* popivanov *at* gmail *dot* com>
~~ Literature or other references for background information ~~
~~ Optional links to other man pages, e.g. ~~
~~ <pkg>
~~
1 2 3 4 5 6 7 8 9 10 11 12 13 | require(quantmod)
require(btutils)
# Download some data from Yahoo
spy = getSymbols("SPY", auto.assign=FALSE)
# Compute the indicator for a 200 day moving average
spy.macd = MACD(Cl(spy), nFast=1, nSlow=200)[,1]
spy.indicator = ifelse(spy.macd < 0, 0, 1)
spy.trades = trade.indicator(OHLC(spy), spy.indicator, stop.loss=0.02)
spy.rets = ROC(Cl(spy), n=1, type="discrete")
ec = calculate.returns(spy.rets, spy.trades)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.