Learn R Programming

Strategy (version 1.0.1)

getTrades: Get trades according to the signals from the Strategy-object

Description

Gets the trades of an object of class Strategy that were performed within strategy calculation.

Usage

getTrades(object, from = NULL, until = NULL, which = NULL,
  of = "signals", use.backtest = FALSE)

# S4 method for Strategy getTrades(object, from = NULL, until = NULL, which = NULL, of = c("signals", "weights"), use.backtest = FALSE)

Arguments

object

An object of class Strategy.

from

The date in character format "yyyy-MM-dd" or as date-object from which trades shall be returned. If NULL, no restriction is made.

until

The date in character format "yyyy-MM-dd" or as date-object until which trades shall be returned. If NULL, no restriction is made.

which

Names or column-number of assets that should be included. If NULL, trades for all assets are returned.

of

Trades to be calculated on basis of trading signals or weights of portfolio.

use.backtest

If set to TRUE, the trades of the backtest are returned. Requires backtest to be executed first.

Examples

Run this code
# NOT RUN {
##Not run:

# MA(200)-Strategy
params <- list(k=200)
myStrat.MA <- Strategy(assets=assets, strat="MA", strat.params=params)

# Get price data from MA(200)-Strategy
getTrades(myStrat.MA, from="2015-01-01", until="2015-12-31")

##End(Not run)
# }

Run the code above in your browser using DataLab