[Blotter-commits] r1664 - in pkg/quantstrat: . man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 31 15:38:01 CET 2014
Author: braverock
Date: 2014-12-31 15:38:01 +0100 (Wed, 31 Dec 2014)
New Revision: 1664
Added:
pkg/quantstrat/man/apply.paramset.signal.analysis.Rd
pkg/quantstrat/man/applyIndicatorSignals.Rd
pkg/quantstrat/man/applyStrategy.rebalancing.training.Rd
pkg/quantstrat/man/beanplot.signals.Rd
pkg/quantstrat/man/distributional.boxplot.Rd
pkg/quantstrat/man/initSymbol.Rd
pkg/quantstrat/man/plot.signal.path.Rd
pkg/quantstrat/man/plot.signals.Rd
pkg/quantstrat/man/post.signal.returns.Rd
pkg/quantstrat/man/signal.generate.statistics.Rd
pkg/quantstrat/man/signal.obj.slope.Rd
Modified:
pkg/quantstrat/DESCRIPTION
pkg/quantstrat/man/ruleOrderProc.Rd
Log:
- update roxygen docs to include new signal generation functions
Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION 2014-12-31 13:19:05 UTC (rev 1663)
+++ pkg/quantstrat/DESCRIPTION 2014-12-31 14:38:01 UTC (rev 1664)
@@ -1,7 +1,7 @@
Package: quantstrat
Type: Package
Title: Quantitative Strategy Model Framework
-Version: 0.9.1663
+Version: 0.9.1664
Date: $Date$
Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme
Depends:
Added: pkg/quantstrat/man/apply.paramset.signal.analysis.Rd
===================================================================
--- pkg/quantstrat/man/apply.paramset.signal.analysis.Rd (rev 0)
+++ pkg/quantstrat/man/apply.paramset.signal.analysis.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,73 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{apply.paramset.signal.analysis}
+\alias{apply.paramset.signal.analysis}
+\title{Signal Analysis With Parmeter Optimization}
+\usage{
+apply.paramset.signal.analysis(strategy.st, paramset.label, portfolio.st,
+ sigcol, sigval, on, forward.days, cum.sum = TRUE, include.day.of.signal,
+ obj.fun, decreasing, mktdata = NULL, verbose = TRUE)
+}
+\arguments{
+\item{strategy.st}{an object of type 'strategy' to add the indicator to}
+
+\item{paramset.label}{a label uniquely identifying the paramset within the strategy}
+
+\item{portfolio.st}{text name of the portfolio to associate the order book with}
+
+\item{sigcol}{column name to check for signal}
+
+\item{sigval}{signal value to match against}
+
+\item{on}{the periods endpoints to find as a character string}
+
+\item{forward.days}{days to exit post signal}
+
+\item{cum.sum}{whether to use cumsum on price changes}
+
+\item{include.day.of.signal}{whether to include the day of signal generation}
+
+\item{obj.fun}{objective function for determining goodness of each paramset}
+
+\item{decreasing}{how to sort the obj.fun output values}
+
+\item{mktdata}{market data}
+
+\item{verbose}{whether to output processing messages}
+}
+\value{
+A list of objects that contains the results
+\describe{
+ \item{signals}{List of signals named by parameter combination. Each object within the list is a XTS object with columns being assets and rows being signals.}
+ \item{sigret.by.paramset}{List of list. Sorted by parameter combination and then by asset. Contains matrix of next day returns; columns are period (N day look ahead) and rows are signals}
+ \item{sigret.by.asset}{List of list. Sorted by Asset and then by parameter combinations. Contains same matrix as sigret.by.paramset}
+ \item{signal.stats}{List of signal statistics as calculated via custom user defined fitness function. Sorted by assets.}
+}
+}
+\description{
+This function allows user to analyze signals independently from rules.
+}
+\details{
+This function is similar to \code{applyParameter} but includes additionally \code{applySignal} wrapped within it. To use it, the user
+will need to initially define the distribution and constraints by using \code{add.distribution} and \code{add.distribution.constraint}.
+
+More generally, the function is designed to generate signals across various parameter combinations defined within the distribution and
+constraints. Afterwards it extract the next N day price changes for further anlaysis.
+
+The parameter \code{on} allows user to calculate post signal returns in different frequencies. Different signals have different timeframes effectiveness.
+\code{forward.days} lets the user select the number of post signal days to analyze results.
+
+To determine the goodness of a parameter set relative to all others, we let the user specify their own objective function (via parameter \code{obj.func})
+that will be used to calculate an objective value representing each parameter. These will then be sorted from best to worst. The
+objective function will take in a single matrix \code{ret.mat} of price changes. Each row represents an individual signal
+while each column represents periods/post signal.
+
+See demo 'signalAnalysisExample1.R' & 'signalAnalysisExample2.R'
+}
+\author{
+Michael Guan
+}
+\seealso{
+\code{\link{add.distribution}}
+\code{\link{add.distribution.constraint}}
+}
+
Added: pkg/quantstrat/man/applyIndicatorSignals.Rd
===================================================================
--- pkg/quantstrat/man/applyIndicatorSignals.Rd (rev 0)
+++ pkg/quantstrat/man/applyIndicatorSignals.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,31 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{applyIndicatorSignals}
+\alias{applyIndicatorSignals}
+\title{Calculate Indicators and Signals for a Strategy}
+\usage{
+applyIndicatorSignals(strategy, portfolio, mktdata, sigcol, ...)
+}
+\arguments{
+\item{strategy}{an object (or the name of an object) type 'strategy' to add the indicator to}
+
+\item{portfolio}{text name of the portfolio to associate the order book with}
+
+\item{mktdata}{market data}
+
+\item{sigcol}{String name of signal to use for analysis}
+}
+\value{
+\code{xts} object with columns representing signals for each symbol
+}
+\description{
+Calculate signals given indicators and signal definitions.
+}
+\author{
+Michael Guan
+}
+\seealso{
+\code{\link{apply.paramset.signal.analysis}}
+\code{\link{applyIndicators}}
+\code{\link{applySignals}}
+}
+
Added: pkg/quantstrat/man/applyStrategy.rebalancing.training.Rd
===================================================================
--- pkg/quantstrat/man/applyStrategy.rebalancing.training.Rd (rev 0)
+++ pkg/quantstrat/man/applyStrategy.rebalancing.training.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,39 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{applyStrategy.rebalancing.training}
+\alias{applyStrategy.rebalancing.training}
+\title{apply the strategy to arbitrary market data, with periodic rebalancing}
+\usage{
+applyStrategy.rebalancing.training(strategy, portfolios, mktdata = NULL,
+ parameters = NULL, ..., verbose = TRUE, symbols = NULL,
+ initStrat = FALSE, updateStrat = FALSE, training = 3)
+}
+\arguments{
+\item{strategy}{an object of type 'strategy' or the name of a stored strategy to apply}
+
+\item{portfolios}{a list of portfolios to apply the strategy to}
+
+\item{mktdata}{an xts object containing market data. depending on indicators, may need to be in OHLCV or BBO formats, default NULL}
+
+\item{parameters}{named list of parameters to be applied during evaluation of the strategy, default NULL}
+
+\item{...}{any other passthru parameters}
+
+\item{verbose}{if TRUE, return output list}
+
+\item{symbols}{character vector identifying symbols to initialize a portfolio for, default NULL}
+
+\item{initStrat}{whether to use (experimental) initialization code, default FALSE}
+
+\item{updateStrat}{whether to use (experimental) wrapup code, default FALSE}
+
+\item{training}{minimum number of periods before we should try to apply rebalance rules}
+}
+\description{
+This function is the wrapper that holds together the execution of a strategy with rebalancing rules.
+}
+\seealso{
+\code{\link{strategy}}, \code{\link{applyIndicators}},
+ \code{\link{applySignals}}, \code{\link{applyRules}},
+ \code{\link{initStrategy}}, \code{\link{applyStrategy}}
+}
+
Added: pkg/quantstrat/man/beanplot.signals.Rd
===================================================================
--- pkg/quantstrat/man/beanplot.signals.Rd (rev 0)
+++ pkg/quantstrat/man/beanplot.signals.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,45 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{beanplot.signals}
+\alias{beanplot.signals}
+\title{Visualization of Signal Across Lookback with Beanplots}
+\usage{
+beanplot.signals(signals, rows = NULL, columns = NULL, mai = c(0.1, 0.4,
+ 0.2, 0.1), mgp = c(1, 1, 0), xlab = "", ylab = "", cex.main = 0.6,
+ xaxt = "n", cex.axis = 0.5, h = 0, hlinecol = "red", ...)
+}
+\arguments{
+\item{rows}{number of rows for plot}
+
+\item{columns}{number of columns for plot}
+
+\item{mai}{A numerical vector of the form c(bottom, left, top, right) which gives the margin size specified in inches.}
+
+\item{mgp}{The margin line (in mex units) for the axis title, axis labels and axis line. Note that mgp[1] affects title whereas mgp[2:3] affect axis. The default is c(3, 1, 0).}
+
+\item{xlab}{a title for the x axis}
+
+\item{ylab}{a title for the y axis}
+
+\item{cex.main}{The magnification to be used for main titles relative to the current setting of cex.}
+
+\item{xaxt}{A character which specifies the x axis type. Specifying "n" suppresses plotting of the axis. The standard value is "s": for compatibility with S values "l" and "t" are accepted but are equivalent to "s": any value other than "n" implies plotting.}
+
+\item{cex.axis}{The magnification to be used for axis annotation relative to the current setting of cex.}
+
+\item{h}{the y-value(s) for horizontal line(s).}
+
+\item{hlinecol}{A specification for the default plotting color. See section ‘Color Specification’.}
+
+\item{signal}{list of paramset forward looking price changes by asset}
+}
+\value{
+plot
+}
+\description{
+This function is similar to \code{plot.signals} but uses beanplots
+instead of barplots. Requires 'beanplot' package
+}
+\author{
+Michael Guan
+}
+
Added: pkg/quantstrat/man/distributional.boxplot.Rd
===================================================================
--- pkg/quantstrat/man/distributional.boxplot.Rd (rev 0)
+++ pkg/quantstrat/man/distributional.boxplot.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,33 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{distributional.boxplot}
+\alias{distributional.boxplot}
+\title{Visualization of Single Signal}
+\usage{
+distributional.boxplot(signal, x.val = seq(1, 50, 5), val = 10,
+ ylim = c(-5, 5), xlim = c(0, 50), mai = c(1, 1, 0.3, 0.5), h = 0, ...)
+}
+\arguments{
+\item{signal}{list of paramset forward looking price changes by asset}
+
+\item{x.val}{he values of the explanatory variable where we want to see the distribution}
+
+\item{val}{this parameter determines how the plotted distribution is shown, increase/decrease it if the distribution is not shown properly}
+
+\item{ylim}{the y limits in the plot}
+
+\item{xlim}{the x limits in the plot}
+
+\item{mai}{A numerical vector of the form c(bottom, left, top, right) which gives the margin size specified in inches.}
+
+\item{h}{the y-value(s) for horizontal line(s).}
+}
+\value{
+plot
+}
+\description{
+This function employs \code(plotSimpleGamlss) in package \code(gamlss.util).
+}
+\author{
+Michael Guan
+}
+
Added: pkg/quantstrat/man/initSymbol.Rd
===================================================================
--- pkg/quantstrat/man/initSymbol.Rd (rev 0)
+++ pkg/quantstrat/man/initSymbol.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,28 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{initSymbol}
+\alias{initSymbol}
+\title{Run standard and custom symbol initialization functions}
+\usage{
+initSymbol(strategy, symbol, ...)
+}
+\arguments{
+\item{strategy}{an object (or the name of an object) of type 'strategy' to add the init function definition to}
+
+\item{symbol}{symbol}
+
+\item{...}{}
+}
+\description{
+\code{initSymbol} will load a symbol and run user-defined functions to pre-process the symbol's data
+before constructing indicators.
+}
+\details{
+The custom initialization must be defined as named list containing
+\describe{
+ \item{name}{function name}
+ \item{argument}{list of arguments}
+ \item{enabled}{TRUE or FALSE}
+}
+and included as the slot \code{init_symbol} of the strategy object.
+}
+
Added: pkg/quantstrat/man/plot.signal.path.Rd
===================================================================
--- pkg/quantstrat/man/plot.signal.path.Rd (rev 0)
+++ pkg/quantstrat/man/plot.signal.path.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,28 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{plot.signal.path}
+\alias{plot.signal.path}
+\title{Visualization of Signal Path}
+\usage{
+\method{plot}{signal.path}(data, main = "Cumulative Return Paths")
+}
+\arguments{
+\item{data}{signal data}
+
+\item{main}{plot title}
+}
+\value{
+plot
+}
+\description{
+This function creates a rChart - hplot that is interactive. It displays
+}
+\examples{
+\dontrun{
+# signalAnalysisExample1.R
+plot.signal.path(results$sigret.by.asset$RTH$paramset.1.5[1:10,])
+}
+}
+\author{
+Michael Guan
+}
+
Added: pkg/quantstrat/man/plot.signals.Rd
===================================================================
--- pkg/quantstrat/man/plot.signals.Rd (rev 0)
+++ pkg/quantstrat/man/plot.signals.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,48 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{plot.signals}
+\alias{plot.signals}
+\title{Visualization of Signal Across Lookback}
+\usage{
+\method{plot}{signals}(signals, rows = NULL, columns = NULL, mai = c(0.1,
+ 0.4, 0.2, 0.1), mgp = c(1, 1, 0), xlab = "", ylab = "",
+ cex.main = 0.6, xaxt = "n", cex.axis = 0.5, h = 0, hlinecol = "red",
+ ...)
+}
+\arguments{
+\item{rows}{number of rows for plot}
+
+\item{columns}{number of columns for plot}
+
+\item{mai}{A numerical vector of the form c(bottom, left, top, right) which gives the margin size specified in inches.}
+
+\item{mgp}{The margin line (in mex units) for the axis title, axis labels and axis line. Note that mgp[1] affects title whereas mgp[2:3] affect axis. The default is c(3, 1, 0).}
+
+\item{xlab}{a title for the x axis}
+
+\item{ylab}{a title for the y axis}
+
+\item{cex.main}{The magnification to be used for main titles relative to the current setting of cex.}
+
+\item{xaxt}{A character which specifies the x axis type. Specifying "n" suppresses plotting of the axis. The standard value is "s": for compatibility with S values "l" and "t" are accepted but are equivalent to "s": any value other than "n" implies plotting.}
+
+\item{cex.axis}{The magnification to be used for axis annotation relative to the current setting of cex.}
+
+\item{h}{the y-value(s) for horizontal line(s).}
+
+\item{hlinecol}{A specification for the default plotting color. See section ‘Color Specification’.}
+
+\item{signal}{list of paramset forward looking price changes by asset}
+}
+\value{
+plot
+}
+\description{
+This function takes a list of matrix of post signal price changes and
+plots boxplots. Note function plots whatever is given to it therefore when
+there are lots paramsets, it is best to plot a smaller portion so the
+information can be displayed clearly.
+}
+\author{
+Michael Guan
+}
+
Added: pkg/quantstrat/man/post.signal.returns.Rd
===================================================================
--- pkg/quantstrat/man/post.signal.returns.Rd (rev 0)
+++ pkg/quantstrat/man/post.signal.returns.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,36 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{post.signal.returns}
+\alias{post.signal.returns}
+\title{Generate Post Signal Returns}
+\usage{
+post.signal.returns(signals, sigval, on = NULL, forward.days,
+ cum.sum = TRUE, include.day.of.signal = FALSE, mktdata = NULL)
+}
+\arguments{
+\item{signals}{xts object with signals, one column}
+
+\item{on}{the periods endpoints to find as a character string}
+
+\item{forward.days}{number of days to look forward after signal (days to exit post signal)}
+
+\item{cum.sum}{\code{TRUE},\code{FALSE}; cumulative sum of price changes}
+
+\item{include.day.of.signal}{whether to analyze the return on signal day}
+
+\item{mktdata}{market data}
+
+\item{sigvals}{signal value to match against}
+}
+\value{
+\code{matrix} of post signal price changes; rows = nth signal, column = nth period since signal
+}
+\description{
+This function collects and aggregates post signal price changes for N days forward.
+}
+\author{
+Michael Guan
+}
+\seealso{
+\code{\link{apply.paramset.signal.analysis}}
+}
+
Modified: pkg/quantstrat/man/ruleOrderProc.Rd
===================================================================
--- pkg/quantstrat/man/ruleOrderProc.Rd 2014-12-31 13:19:05 UTC (rev 1663)
+++ pkg/quantstrat/man/ruleOrderProc.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -5,6 +5,9 @@
\usage{
ruleOrderProc(portfolio, symbol, mktdata, timestamp = NULL,
ordertype = NULL, ..., slippageFUN = NULL)
+
+ruleOrderProc(portfolio, symbol, mktdata, timestamp = NULL,
+ ordertype = NULL, ..., slippageFUN = NULL)
}
\arguments{
\item{portfolio}{text name of the portfolio to associate the order book with}
@@ -20,12 +23,31 @@
\item{...}{any other passthru parameters}
\item{slippageFUN}{default NULL, not yet implemented}
+
+\item{portfolio}{text name of the portfolio to associate the order book with}
+
+\item{symbol}{identfier of the instrument to find orders for. The name of any associated price objects (xts prices, usually OHLC or BBO) should match these}
+
+\item{mktdata}{an xts object containing market data. depending on indicators, may need to be in OHLCV or BBO formats, default NULL}
+
+\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be processed on}
+
+\item{ordertype}{one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL}
+
+\item{...}{any other passthru parameters}
+
+\item{slippageFUN}{default NULL, not yet implemented}
}
\description{
The ruleOrderProc function is effectively the default fill simulator for quantstrat.
This function is meant to be sufficient for backtesting most strategies,
but would need to be replaced for production use. It provides the interface
for taking the order book and determining when orders become trades.
+
+The ruleOrderProc function is effectively the default fill simulator for quantstrat.
+This function is meant to be sufficient for backtesting most strategies,
+but would need to be replaced for production use. It provides the interface
+for taking the order book and determining when orders become trades.
}
\details{
In this version, in contrast with an earlier version,
@@ -49,6 +71,28 @@
We would like to model slippage here via \code{slippageFUN}. Code contributions, suggestions,
and requests appreciated.
+
+In this version, in contrast with an earlier version,
+this function will allow a transaction to cross your current
+position through zero. The accounting rules for realizing gains in such cases
+are quite complicated, so blotter will split this transaction into two transactions.
+Many brokers will break, revise, or split such transactions for the same reason.
+
+This function would need to be revised or replaced for connection to a live trading infrastructure.
+In a production mode, you would replace the \code{\link{addOrder}} function
+with a custom function to connect to your market infrastructure.
+In that case, you might need to add additional code to your strategy,
+or overload functions for checking position.
+
+Note that this function is called by default in the 'orders' slot of the
+\code{\link{applyRules}} processing. If you have defined another order
+processing rule, it will \emph{replace} this function. If you want your
+custom order rule and ruleOrderProc to both be called, you will need
+explicitly add a rule to call ruleOrderProc either before or after your
+custom order processing function.
+
+We would like to model slippage here via \code{slippageFUN}. Code contributions, suggestions,
+and requests appreciated.
}
\seealso{
add.rule
@@ -60,6 +104,16 @@
addOrder
updateOrders
+
+add.rule
+
+applyRules
+
+getOrderBook
+
+addOrder
+
+updateOrders
}
\concept{
fill simulator
@@ -73,5 +127,17 @@
This function is meant to be sufficient for backtesting many/most strategies,
but would need to be replaced for production use. It provides the interface
for taking the order book and determining when orders become trades.
+
+fill simulator
+
+orders
+
+backtest
+
+fills
+
+This function is meant to be sufficient for backtesting many/most strategies,
+but would need to be replaced for production use. It provides the interface
+for taking the order book and determining when orders become trades.
}
Added: pkg/quantstrat/man/signal.generate.statistics.Rd
===================================================================
--- pkg/quantstrat/man/signal.generate.statistics.Rd (rev 0)
+++ pkg/quantstrat/man/signal.generate.statistics.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,28 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{signal.generate.statistics}
+\alias{signal.generate.statistics}
+\title{Signal Objective Function Calculation}
+\usage{
+signal.generate.statistics(post.ret, obj.fun = NULL, decreasing = TRUE)
+}
+\arguments{
+\item{post.ret}{\code{matrix} of parameter set of post signal price deltas}
+
+\item{obj.fun}{custom objective function for measuring signal goodness}
+
+\item{decreasing}{if true, the higher the objective value, the better}
+}
+\value{
+objective function values
+}
+\description{
+This function takes a list of matrix of post signal price changes and
+applies an user defined objective function on it.
+}
+\author{
+Michael Guan
+}
+\seealso{
+\code{\link{apply.paramset.signal.analysis}}
+}
+
Added: pkg/quantstrat/man/signal.obj.slope.Rd
===================================================================
--- pkg/quantstrat/man/signal.obj.slope.Rd (rev 0)
+++ pkg/quantstrat/man/signal.obj.slope.Rd 2014-12-31 14:38:01 UTC (rev 1664)
@@ -0,0 +1,30 @@
+% Generated by roxygen2 (4.0.2): do not edit by hand
+\name{signal.obj.slope}
+\alias{signal.obj.slope}
+\title{Signal Objective Function}
+\usage{
+signal.obj.slope(x)
+}
+\arguments{
+\item{x}{Return matrix, each row represents price deltas for a single signal, each column represents periods}
+}
+\value{
+Single Objective Value
+}
+\description{
+Simple example of objective function that can can be used to measure the effectiveness of various parameter combinations.
+}
+\details{
+Calculates the slope of the Cumulative Equity line. Higher the better.
+
+It is important to note that all objective functions are called within \code{signal.generate.statistics}. What gets
+passed in to it as parameter is an matrix of post signal price changes or cumulative equity for each signal. The matrix
+is of N-by-M dimensions. N being the row representing the Nth signal. M being the column representing Mth period.
+}
+\author{
+Michael Guan
+}
+\seealso{
+\code{\link{apply.paramset.signal.analysis}}
+}
+
More information about the Blotter-commits
mailing list