[Blotter-commits] r985 - pkg/quantstrat/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 25 19:07:06 CEST 2012
Author: braverock
Date: 2012-03-25 19:07:06 +0200 (Sun, 25 Mar 2012)
New Revision: 985
Modified:
pkg/quantstrat/man/add.indicator.Rd
pkg/quantstrat/man/add.rule.Rd
pkg/quantstrat/man/addOrder.Rd
pkg/quantstrat/man/applyRules.Rd
pkg/quantstrat/man/getOrderBook.Rd
pkg/quantstrat/man/getOrders.Rd
pkg/quantstrat/man/initOrders.Rd
pkg/quantstrat/man/initStrategy.Rd
pkg/quantstrat/man/ruleOrderProc.Rd
pkg/quantstrat/man/ruleSignal.Rd
pkg/quantstrat/man/strategy.Rd
pkg/quantstrat/man/updateOrders.Rd
pkg/quantstrat/man/updateStrategy.Rd
Log:
- update roxygen docs
Modified: pkg/quantstrat/man/add.indicator.Rd
===================================================================
--- pkg/quantstrat/man/add.indicator.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/add.indicator.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -72,7 +72,7 @@
\code{mktdata} is typically created internally to
\code{quantstrat} by looking in the global environment
for a time series of prices or returns. mktdata may also
- contain other data you've manipulated outside quatstrat,
+ contain other data you've manipulated outside quantstrat,
though where possible you should use quantstrat to
contain all the logic for the strategy, to aid in
maintenance and modifications.
Modified: pkg/quantstrat/man/add.rule.Rd
===================================================================
--- pkg/quantstrat/man/add.rule.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/add.rule.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -6,7 +6,7 @@
label = NULL, type = c(NULL, "risk", "order",
"rebalance", "exit", "enter"), ..., enabled = TRUE,
indexnum = NULL, path.dep = TRUE, timespan = NULL, store
- = FALSE)
+ = FALSE, storefun = TRUE)
}
\arguments{
\item{strategy}{an object of type 'strategy' to add the
@@ -43,6 +43,11 @@
\item{store}{TRUE/FALSE whether to store the strategy in
the .strategy environment, or return it. default FALSE}
+
+ \item{storefun}{TRUE/FALSE whether to store the function
+ in the rule, default TRUE. setting this option to FALSE
+ may slow the backtest, but makes \code{\link{debug}}
+ usable}
}
\value{
if \code{strategy} was the name of a strategy, the name.
Modified: pkg/quantstrat/man/addOrder.Rd
===================================================================
--- pkg/quantstrat/man/addOrder.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/addOrder.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -5,7 +5,8 @@
addOrder(portfolio, symbol, timestamp, qty, price,
ordertype, side, threshold = NULL, status = "open",
statustimestamp = "", delay = 1e-05, tmult = FALSE,
- replace = TRUE, return = FALSE, ..., TxnFees = 0)
+ replace = TRUE, return = FALSE, ..., TxnFees = 0, label =
+ "")
}
\arguments{
\item{portfolio}{text name of the portfolio to associate
@@ -29,7 +30,7 @@
\item{side}{one of either "long" or "short"}
\item{threshold}{numeric threshold to apply to trailing
- stop orders, default NULL}
+ stop orders and limit orders, default NULL}
\item{status}{one of "open", "closed", "canceled", or
"replaced", default "open"}
@@ -56,6 +57,9 @@
\item{TxnFees}{numeric fees (usually negative) or
function name for calculating TxnFees (processing happens
later, not in this function)}
+
+ \item{label}{text label, default to '', set to rule label
+ by \code{\link{ruleSignal}}}
}
\description{
It is important to understand that all the order
@@ -163,7 +167,14 @@
provide the event loop interface and interact with
\code{mktdata}.
}
+\seealso{
+ getOrderBook
+
+ updateOrders
+}
\concept{
backtest
+
+ order book
}
Modified: pkg/quantstrat/man/applyRules.Rd
===================================================================
--- pkg/quantstrat/man/applyRules.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/applyRules.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -51,6 +51,11 @@
mktdata object.
}
\details{
+ This function, because of its path dependent nature and
+ the order of rule evaluation discussed in
+ \code{\link{add.rule}}, will likely take up most of the
+ execution time of a strategy backtest.
+
Individual rule functions may need to use <<- to place
\code{hold} and \code{holdtill} variables into play.
These would be most likely implemented by risk rules.
@@ -69,22 +74,23 @@
\code{\link{addOrder}}, and \code{\link{applyStrategy}}
will likely need to be replaced to connect to a live
market infrastructure.
+}
+\section{Dimension Reduction for Performance}{
+ In evaluation of path-dependent rules, the simplest
+ method, and the one we used initially, is to check the
+ rules on every observation in the time series of market
+ data. There are cases where this will still be required,
+ but we hope to limit them as much as possible. Looping in
+ \R is generally discouraged, and on high frequency data
+ for strategy evaluation it can produce completely
+ unacceptable results.
- } \section{Dimension Reduction for Performance}{ %roxygen
- requires that we stop the prior section before we add a
- new one In evaluation of path-dependent rules, the
- simplest method, and the one we used initially, is to
- check the rules on every observation in the time series
- of market data. There are cases where this will still be
- required, but we hope to limit them as much as possible.
- Looping in \R is generally discouraged, and on high
- frequency data for strategy evaluation it can produce
- completely unacceptable results.
+ The solution we've employed is to utilize a state machine
+ to evaluate the rules only when deemed necessary. This
+ approach makes use of what we know about the strategy and
+ the orders the strategy places (or may place) to reduce
+ the dimensionality of the problem.
- The solution we've employed makes use of what we know
- about the strategy and the orders the strategy places (or
- may place) to reduce the dimensionality of the problem.
-
As discussed in \code{\link{add.rule}}, the first step in
this dimension reduction is to look for places in the
time series where signals may cause the strategy to enter
@@ -123,13 +129,14 @@
and the point at which the order may move. if there is a
(possible) cross, we insert that index into the indices
for examination. If not, we insert the index of the next
- probably move.
+ probable move.
It should be noted that this dimension reduction
methodology does 'look ahead' in the data. This 'look
ahead' is only done \emph{after} the order has been
- entered in the normal path-dependent process, and so
- should not introduce biases.
+ entered in the normal path-dependent process, and only to
+ insert new indices for evaluation, and so should not
+ introduce biases.
}
\seealso{
\code{\link{add.rule}} \code{\link{applyStrategy}}
Modified: pkg/quantstrat/man/getOrderBook.Rd
===================================================================
--- pkg/quantstrat/man/getOrderBook.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/getOrderBook.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -12,4 +12,12 @@
I don't think this should be exported, but it is for now
while we're in test mode.
}
+\seealso{
+ addOrder
+ getOrders
+}
+\concept{
+ order book
+}
+
Modified: pkg/quantstrat/man/getOrders.Rd
===================================================================
--- pkg/quantstrat/man/getOrders.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/getOrders.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -44,4 +44,12 @@
should this be symbols instead of symbol?
}
+\seealso{
+ getOrderBook
+ addOrder
+}
+\concept{
+ order book
+}
+
Modified: pkg/quantstrat/man/initOrders.Rd
===================================================================
--- pkg/quantstrat/man/initOrders.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/initOrders.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -28,4 +28,7 @@
will attempt to retrieve the symbols list from the
portfolio in the trade blotter.
}
+\concept{
+ order book
+}
Modified: pkg/quantstrat/man/initStrategy.Rd
===================================================================
--- pkg/quantstrat/man/initStrategy.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/initStrategy.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -2,9 +2,9 @@
\alias{initStrategy}
\title{run standard and custom strategy initialization functions}
\usage{
- initStrategy(strategy, portfolio, symbols, get.Symbols =
- TRUE, init.Portf = TRUE, init.Acct = TRUE, init.Orders =
- TRUE, unique = TRUE, ...)
+ initStrategy(strategy, portfolio, symbols, parameters =
+ NULL, get.Symbols = TRUE, init.Portf = TRUE, init.Acct =
+ TRUE, init.Orders = TRUE, unique = TRUE, ...)
}
\arguments{
\item{strategy}{object of type \code{strategy} to
@@ -14,22 +14,44 @@
\item{symbols}{symbols}
- \item{get.Symbols}{TRUE/FALSE, default TRUE:}
+ \item{parameters}{named list of parameters to be applied
+ during evaluation of the strategy, default NULL}
- \item{init.Portf}{TRUE/FALSE, default TRUE:}
+ \item{get.Symbols}{TRUE/FALSE, default TRUE}
- \item{init.Acct}{TRUE/FALSE, default TRUE:}
+ \item{init.Portf}{TRUE/FALSE, default TRUE}
- \item{init.Orders}{TRUE/FALSE, default TRUE:}
+ \item{init.Acct}{TRUE/FALSE, default TRUE}
- \item{unique}{TRUE/FALSE, default TRUE:}
+ \item{init.Orders}{TRUE/FALSE, default TRUE}
- \item{\dots}{any other passtrhrough parameters}
+ \item{unique}{TRUE/FALSE, default TRUE}
+
+ \item{\dots}{any other passthrough parameters}
}
\description{
- run standard and custom strategy initialization functions
+ \code{initStrategy} will run a series of common
+ initialization functions at the beginning of an
+ \code{\link{applyStrategy}} call.
}
+\details{
+ \describe{ \item{get.Symbols}{if TRUE, will call
+ \code{\link[quantmod]{getSymbols}} on all symbols
+ included in the \code{symbols} vector}
+ \item{init.Portf}{if TRUE, will call
+ \code{\link[blotter]{initPortf}} to initialize the
+ portfolio object} \item{init.Acct}{if TRUE, will call
+ \code{\link[blotter]{initAccount}} to initialize the
+ account object} \item{init.Orders}{if TRUE, will call
+ \code{\link{initOrders}} to initialize the order book for
+ this test} \item{unique}{not yet implemented, will force
+ a unique portfolio and account name if the portfolio,
+ account, or order book already exist} }
+}
\author{
Garrett See, Brian Peterson
}
+\seealso{
+ \code{\link{applyStrategy}}, \code{\link{add.init}},
+}
Modified: pkg/quantstrat/man/ruleOrderProc.Rd
===================================================================
--- pkg/quantstrat/man/ruleOrderProc.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/ruleOrderProc.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -68,6 +68,17 @@
\code{slippageFUN}. Code contributions, suggestions, and
requests appreciated.
}
+\seealso{
+ add.rule
+
+ applyRules
+
+ getOrderBook
+
+ addOrder
+
+ updateOrders
+}
\concept{
fill simulator
@@ -75,8 +86,10 @@
backtest
+ fills
+
This function is meant to be sufficient for backtesting
- most strategies, but would need to be replaced for
+ 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.
}
Modified: pkg/quantstrat/man/ruleSignal.Rd
===================================================================
--- pkg/quantstrat/man/ruleSignal.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/ruleSignal.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -7,7 +7,7 @@
NULL, tmult = FALSE, replace = TRUE, delay = 1e-04, osFUN
= "osNoOp", pricemethod = c("market", "opside",
"active"), portfolio, symbol, ..., ruletype, TxnFees = 0,
- prefer = NULL, sethold = FALSE)
+ prefer = NULL, sethold = FALSE, label = "")
}
\arguments{
\item{data}{an xts object containing market data.
@@ -72,6 +72,9 @@
\item{sethold}{boolean, puts entry Rule processing on
hold, default FALSE}
+
+ \item{label}{rule label, default '', added by
+ \code{\link{applyRules}}}
}
\description{
\code{pricemethod} may be one of \describe{
Modified: pkg/quantstrat/man/strategy.Rd
===================================================================
--- pkg/quantstrat/man/strategy.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/strategy.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -21,6 +21,11 @@
the .strategy environment, or return it. default FALSE}
}
\description{
- constructor for objects of type 'strategy'
+ variables passed in dots will be added to the strategy
+ object, and may be used by initialization and wrapup
+ functions, as well as indicators, signals, and rules.
}
+\seealso{
+ \code{\link{applyStrategy}}
+}
Modified: pkg/quantstrat/man/updateOrders.Rd
===================================================================
--- pkg/quantstrat/man/updateOrders.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/updateOrders.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -55,4 +55,14 @@
want to run a process at the close of market that will
cancel all open orders.
}
+\seealso{
+ addOrder
+ getOrders
+
+ getOrderBook
+}
+\concept{
+ order book
+}
+
Modified: pkg/quantstrat/man/updateStrategy.Rd
===================================================================
--- pkg/quantstrat/man/updateStrategy.Rd 2012-03-25 16:25:19 UTC (rev 984)
+++ pkg/quantstrat/man/updateStrategy.Rd 2012-03-25 17:07:06 UTC (rev 985)
@@ -2,12 +2,16 @@
\alias{updateStrategy}
\title{run standard and custom strategy wrapup functions such as updating portfolio, account, and ending equity}
\usage{
- updateStrategy(portfolio = "default", account =
- portfolio, Symbols = NULL, Dates = NULL, Prices = NULL,
- update.Portf = TRUE, update.Acct = TRUE, update.EndEq =
- TRUE, showEq = TRUE, chart = TRUE, ...)
+ updateStrategy(strategy, portfolio = "default", account =
+ portfolio, Symbols = NULL, parameters = NULL, Dates =
+ NULL, Prices = NULL, update.Portf = TRUE, update.Acct =
+ TRUE, update.EndEq = TRUE, showEq = TRUE, chart = TRUE,
+ ...)
}
\arguments{
+ \item{strategy}{object of type \code{strategy} to
+ initialize data/containers for}
+
\item{portfolio}{string identifying a portfolio}
\item{account}{string identifying an account. Same as
@@ -16,6 +20,9 @@
\item{Symbols}{character vector of names of symbols whose
portfolios will be updated}
+ \item{parameters}{named list of parameters to be applied
+ during evaluation of the strategy, default NULL}
+
\item{Dates}{optional xts-style ISO-8601 time range to
run updatePortf over, default NULL (will use times from
Prices)}
@@ -60,6 +67,16 @@
than tick. A custom wrapup function could take your high
frequency data and transform it to lower frequency data
before the call to \code{\link{updatePortf}}.
+
+ The 'standard wrapup functions included are: \describe{
+ \item{update.Portf}{ if TRUE, will call
+ \code{\link[blotter]{updatePortf}} to mark the book in
+ the portfolio. } \item{update.Acct}{ if TRUE, will call
+ \code{\link[blotter]{updateAcct}} to mark the blotter
+ account for this test. } \item{update.EndEq}{ if TRUE,
+ will call \code{\link[blotter]{updateEndEq}} to update
+ the account equity after all other accounting has been
+ completed. } }
}
\author{
Garrett See, Brian Peterson
More information about the Blotter-commits
mailing list