[Blotter-commits] r269 - in pkg/quantstrat: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Feb 26 15:54:16 CET 2010
Author: braverock
Date: 2010-02-26 15:54:16 +0100 (Fri, 26 Feb 2010)
New Revision: 269
Modified:
pkg/quantstrat/DESCRIPTION
pkg/quantstrat/R/orders.R
pkg/quantstrat/R/traderules.R
pkg/quantstrat/man/add.rule.Rd
pkg/quantstrat/man/addOrder.Rd
pkg/quantstrat/man/addPosLimit.Rd
pkg/quantstrat/man/applyStrategy.Rd
pkg/quantstrat/man/getOrders.Rd
pkg/quantstrat/man/getPosLimit.Rd
pkg/quantstrat/man/match.names.Rd
pkg/quantstrat/man/osMaxPos.Rd
pkg/quantstrat/man/osNoOp.Rd
pkg/quantstrat/man/ruleOrderProc.Rd
pkg/quantstrat/man/ruleSignal.Rd
pkg/quantstrat/man/updateOrders.Rd
Log:
- update roxygen docs
- updates to pass R CMD check
Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/DESCRIPTION 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,7 +1,7 @@
Package: quantstrat
Type: Package
Title: Quantitative Strategy Model Framework
-Version: 0.0.2
+Version: 0.2
Date: 2010-02-06
Author: Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey A. Ryan, Joshua Ulrich
Depends: xts(>= 0.7-0),TTR(>= 0.2),blotter(>= 0.4), FinancialInstrument, quantmod (>= 0.3-14)
Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/R/orders.R 2010-02-26 14:54:16 UTC (rev 269)
@@ -121,7 +121,7 @@
#'
#' @param portfolio text name of the portfolio to associate the order book with
#' @param symbol identfier of the instrument to find orders for. The name of any associated price objects (xts prices, usually OHLC) should match these
-#' @param timespan xts-style character timespan to be the period to find orders of the given status and ordertype
+#' @param timestamp timestamp coercible to POSIXct that will be the time to search for orders before this time
#' @param qty numeric quantity of the order
#' @param price numeric price at which the order is to be inserted
#' @param ordertype one of "market","limit","stoplimit", or "stoptrailing"
@@ -189,7 +189,7 @@
#'
#' @param portfolio text name of the portfolio to associate the order book with
#' @param symbol identfier of the instrument to find orders for. The name of any associated price objects (xts prices, usually OHLC) should match these
-#' @param timestamp timestamp coercible to POSIXct that will be the time to search for orders before this time
+#' @param timespan xts-style character timespan to be the period to find orders of the given status and ordertype
#' @param ordertype one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL
#' @param side one of NULL, "long" or "short", default NULL
#' @param oldstatus one of NULL, "open", "closed", "canceled", or "replaced", default "open"
Modified: pkg/quantstrat/R/traderules.R
===================================================================
--- pkg/quantstrat/R/traderules.R 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/R/traderules.R 2010-02-26 14:54:16 UTC (rev 269)
@@ -80,13 +80,8 @@
#'
#' default function performs no operation (NoOp), returns orderqty
#'
-#' @param mktdata an xts object containing market data. depending on rules, may need to be in OHLCV or BBO formats, and may include indicator and signal information
-#' @param timestamp timestamp coercible to POSIXct that will be the time the order will be inserted on
#' @param orderqty numeric quantity of the desired order, modified by osFUN
-#' @param ordertype one of "market","limit","stoplimit", or "stoptrailing"
-#' @param orderside one of either "long" or "short"
-#' @param portfolio text name of the portfolio to place orders in
-#' @param symbol identifier of the instrument to place orders for. The name of any associated price objects (xts prices, usually OHLC) should match these
+#' @param ... any other passthru parameters
#' @export
osNoOp <- function(orderqty, ...){
return(orderqty)
@@ -163,9 +158,9 @@
#' @export
osMaxPos <- function(mktdata, timestamp, orderqty, ordertype, orderside, portfolio, symbol){
# check for current position
- pos<-getPosQty(portoflio,symbol,timestamp)
+ pos<-getPosQty(portfolio,symbol,timestamp)
# check against max position
- PosLimit<-getPosLimit(portoflio,symbol,timestamp)
+ PosLimit<-getPosLimit(portfolio,symbol,timestamp)
# check levels
# buy long
@@ -180,7 +175,7 @@
} else {
# this order would put us over the MaxPos limit
orderqty<-ifelse((PosLimit[,"MaxPos"]-pos)<=round(PosLimit[,"MaxPos"]/PosLimit[,"LongLevels"],0),PosLimit[,"MaxPos"]-pos, round(PosLimit[,"MaxPos"]/PosLimit[,"LongLevels"],0))
- if(oderqty+pos>PosLimit[,"MaxPos"]) orderqty <- PosLimit[,"MaxPos"]-pos
+ if(orderqty+pos>PosLimit[,"MaxPos"]) orderqty <- PosLimit[,"MaxPos"]-pos
}
return(orderqty)
}
@@ -208,7 +203,7 @@
} else {
# this order would put us over the MinPos limit
orderqty<-ifelse((PosLimit[,"MinPos"]-pos)>=round(PosLimit[,"MinPos"]/PosLimit[,"ShortLevels"],0),PosLimit[,"MinPos"]-pos, round(PosLimit[,"MinPos"]/PosLimit[,"ShortLevels"],0))
- if(oderqty+pos>PosLimit[,"MaxPos"]) orderqty <- PosLimit[,"MinPos"]-pos
+ if(orderqty+pos>PosLimit[,"MaxPos"]) orderqty <- PosLimit[,"MinPos"]-pos
}
return(orderqty)
}
Modified: pkg/quantstrat/man/add.rule.Rd
===================================================================
--- pkg/quantstrat/man/add.rule.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/add.rule.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -40,7 +40,7 @@
\arguments{\item{strategy}{an object of type 'strategy' to add the rule to}
\item{name}{name of the rule, must correspond to an R function}
\item{arguments}{default arguments to be passed to an rule function when executed}
-\item{label}{arbitrary text label for signal output, NULL default will be converted to '<name>.sig'}
+\item{label}{arbitrary text label for rule output, NULL default will be converted to '<name>.rule'}
\item{type}{one of "risk","order","rebalance","exit","entry", see Details}
\item{...}{any other passthru parameters}
\item{enabled}{TRUE/FALSE whether the rule is enabled for use in applying the strategy, default TRUE}
Modified: pkg/quantstrat/man/addOrder.Rd
===================================================================
--- pkg/quantstrat/man/addOrder.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/addOrder.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -21,7 +21,7 @@
a market order will be executed at the then-prevailing price. We have not modeled this type of order.}
\arguments{\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) should match these}
-\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be inserted on}
+\item{timestamp}{timestamp coercible to POSIXct that will be the time to search for orders before this time}
\item{qty}{numeric quantity of the order}
\item{price}{numeric price at which the order is to be inserted}
\item{ordertype}{one of "market","limit","stoplimit", or "stoptrailing"}
Modified: pkg/quantstrat/man/addPosLimit.Rd
===================================================================
--- pkg/quantstrat/man/addPosLimit.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/addPosLimit.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -3,6 +3,12 @@
\title{add position and level limits at timestamp...}
\usage{addPosLimit(portfolio, symbol, timestamp, maxpos, longlevels=1, minpos=0, shortlevels=0)}
\description{add position and level limits at timestamp}
+\details{levels are a simplification of more complex (proprietary)
+techniques sometimes used for order sizing.
+the max orderqty returned will be the limit/levels
+Obviously the strategy rules could ask for smaller order sizes,
+but this is the default. If you don't want to use levels, set
+them to 1.}
\seealso{\code{\link{osMaxPos}}
\code{\link{getPosLimit}}}
\arguments{\item{portfolio}{text name of the portfolio to place orders in}
Modified: pkg/quantstrat/man/applyStrategy.Rd
===================================================================
--- pkg/quantstrat/man/applyStrategy.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/applyStrategy.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -3,6 +3,8 @@
\title{apply the strategy to arbitrary market data...}
\usage{applyStrategy(strategy, portfolios, mktdata, ...)}
\description{apply the strategy to arbitrary market data}
+\details{if \code{mktdata} is NULL, the default, the mktdata variable will be populated
+for each symbol via a call to get (getSymbols??, not yet)}
\arguments{\item{strategy}{an object of type 'strategy' to add the indicator to}
\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}
Modified: pkg/quantstrat/man/getOrders.Rd
===================================================================
--- pkg/quantstrat/man/getOrders.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/getOrders.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,7 +1,7 @@
\name{getOrders}
\alias{getOrders}
\title{get orders by time span, status, type, and side...}
-\usage{getOrders(portfolio, symbol, status="open", timestamp, ordertype, side, starttime=-86400)}
+\usage{getOrders(portfolio, symbol, status="open", timespan, ordertype, side, starttime=-86400)}
\description{get orders by time span, status, type, and side}
\details{This function exists so that other code can find open orders, potentially to update or cancel them.
@@ -11,7 +11,7 @@
\arguments{\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) should match these}
\item{status}{one of "open", "closed", "canceled", or "replaced", default "open"}
-\item{timestamp}{timestamp coercible to POSIXct that will be the period to find orders of the given status and ordertype}
+\item{timespan}{xts-style character timespan to be the period to find orders of the given status and ordertype}
\item{ordertype}{one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL}
\item{side}{one of NULL, "long" or "short", default NULL}
\item{starttime}{difference to current timestamp to search, in seconds(numeric) or as a POSIXct timestamp, defaults to -86400 (one day)}}
Modified: pkg/quantstrat/man/getPosLimit.Rd
===================================================================
--- pkg/quantstrat/man/getPosLimit.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/getPosLimit.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -3,6 +3,7 @@
\title{get position and level limits on timestamp...}
\usage{getPosLimit(portfolio, symbol, timestamp)}
\description{get position and level limits on timestamp}
+\seealso{\code{\link{addPosLimit}},\code{\link{osMaxPos}}}
\arguments{\item{portfolio}{text name of the portfolio to place orders in}
\item{symbol}{identifier of the instrument to place orders for. The name of any associated price objects (xts prices, usually OHLC) should match these}
\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be inserted on}}
Modified: pkg/quantstrat/man/match.names.Rd
===================================================================
--- pkg/quantstrat/man/match.names.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/match.names.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,7 +1,7 @@
\name{match.names}
\alias{match.names}
\title{match names in data to a list of partial name matches...}
-\usage{match.names(data_names, match_names)}
+\usage{match.names(match_names, data_names)}
\description{match names in data to a list of partial name matches}
\details{Often, the generic definition of a signal or indicator will include
partial name matches. In financial data, common partial matches include
Modified: pkg/quantstrat/man/osMaxPos.Rd
===================================================================
--- pkg/quantstrat/man/osMaxPos.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/osMaxPos.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -9,6 +9,7 @@
Obviously the strategy rules could ask for smaller order sizes,
but this is the default. If you don't want to use levels, set
them to 1.}
+\seealso{\code{\link{addPosLimit}},\code{\link{getPosLimit}}}
\arguments{\item{mktdata}{an xts object containing market data. depending on rules, may need to be in OHLCV or BBO formats, and may include indicator and signal information}
\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be inserted on}
\item{orderqty}{numeric quantity of the desired order, modified by osFUN}
Modified: pkg/quantstrat/man/osNoOp.Rd
===================================================================
--- pkg/quantstrat/man/osNoOp.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/osNoOp.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,13 +1,8 @@
\name{osNoOp}
\alias{osNoOp}
\title{default order sizing function...}
-\usage{osNoOp(mktdata, timestamp, orderqty, ordertype, orderside, portfolio, symbol)}
+\usage{osNoOp(orderqty, ...)}
\description{default order sizing function}
\details{default function performs no operation (NoOp), returns orderqty}
-\arguments{\item{mktdata}{an xts object containing market data. depending on rules, may need to be in OHLCV or BBO formats, and may include indicator and signal information}
-\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be inserted on}
-\item{orderqty}{numeric quantity of the desired order, modified by osFUN}
-\item{ordertype}{one of "market","limit","stoplimit", or "stoptrailing"}
-\item{orderside}{one of either "long" or "short"}
-\item{portfolio}{text name of the portfolio to place orders in}
-\item{symbol}{identifier of the instrument to place orders for. The name of any associated price objects (xts prices, usually OHLC) should match these}}
+\arguments{\item{orderqty}{numeric quantity of the desired order, modified by osFUN}
+\item{...}{any other passthru parameters}}
Modified: pkg/quantstrat/man/ruleOrderProc.Rd
===================================================================
--- pkg/quantstrat/man/ruleOrderProc.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/ruleOrderProc.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,12 +1,12 @@
\name{ruleOrderProc}
\alias{ruleOrderProc}
\title{process open orders at time t, generating transactions or new orders...}
-\usage{ruleOrderProc(portfolio, symbol, mktdata, timestamp, ordertype, ..., slippageFUN)}
+\usage{ruleOrderProc(portfolio, symbol, mktdata, timespan, ordertype, ..., slippageFUN)}
\description{process open orders at time t, generating transactions or new orders}
\arguments{\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) 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 to search for orders before this time}
+\item{timespan}{xts-style character timespan to be the period to find orders to process in}
\item{ordertype}{one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL}
\item{...}{any other passthru parameters}
\item{slippageFUN}{default NULL, not yet implemented}}
Modified: pkg/quantstrat/man/ruleSignal.Rd
===================================================================
--- pkg/quantstrat/man/ruleSignal.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/ruleSignal.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,10 +1,18 @@
\name{ruleSignal}
\alias{ruleSignal}
-\title{default rule to execute a trade on a signal...}
+\title{default rule to generate a trade order on a signal...}
\usage{ruleSignal(mktdata, timestamp, sigcol, sigval, orderqty=0, ordertype, orderside, threshold, replace=TRUE, delay=1e-04, osFUN="osNoOp",
pricemethod=c("market", "opside"), portfolio, symbol, ...)}
-\description{default rule to execute a trade on a signal}
-\details{\code{pricemethod} may be one of 'market' and 'opside' which will either try to get the price of the market at \code{timestamp} and use this as the order price}
+\description{default rule to generate a trade order on a signal}
+\details{\code{pricemethod} may be one of 'market' or 'opside'
+which will either try to get the price of the 'market' at \code{timestamp} and use this as the order price
+or 'opside' which will use the 'ask' price if you're buying and the 'bid' price if you're selling
+
+If \code{threshold} is not numeric or \code{NULL} it should be the character string describing a function that can calculate a threshold.
+Ideally this will be a column lookup on a non-path-dependent indicator calculated in advance.
+
+If \code{orderside} is NULL, the function will attempt to calculate the side from the current position
+(if any) and the order quantity.}
\seealso{\code{\link{osNoOp}}}
\arguments{\item{mktdata}{an xts object containing market data. depending on rules, may need to be in OHLCV or BBO formats, and may include indicator and signal information}
\item{timestamp}{timestamp coercible to POSIXct that will be the time the order will be inserted on}
@@ -12,8 +20,8 @@
\item{sigval}{signal value to match against}
\item{orderqty}{numeric quantity of the desired order, modified by osFUN}
\item{ordertype}{one of "market","limit","stoplimit", or "stoptrailing"}
-\item{orderside}{one of either "long" or "short"}
-\item{threshold}{numeric threshold to apply to trailing stop orders, default NULL}
+\item{orderside}{one of either "long" or "short", default NULL, see details}
+\item{threshold}{numeric or function threshold to apply to trailing stop orders, default NULL, see Details}
\item{replace}{TRUE/FALSE, whether to replace any other open order(s) on this portfolio symbol, default TRUE}
\item{delay}{what delay to add to timestamp when inserting the order into the order book, in seconds}
\item{osFUN}{function or text descriptor of function to use for order sizing, default \code{\link{osNoOp}}}
Modified: pkg/quantstrat/man/updateOrders.Rd
===================================================================
--- pkg/quantstrat/man/updateOrders.Rd 2010-02-26 14:17:24 UTC (rev 268)
+++ pkg/quantstrat/man/updateOrders.Rd 2010-02-26 14:54:16 UTC (rev 269)
@@ -1,7 +1,7 @@
\name{updateOrders}
\alias{updateOrders}
\title{update an order or orders...}
-\usage{updateOrders(portfolio, symbol, timestamp, ordertype, side, oldstatus="open", newstatus, statustimestamp)}
+\usage{updateOrders(portfolio, symbol, timespan, ordertype, side, oldstatus="open", newstatus, statustimestamp)}
\description{update an order or orders}
\details{When an order gets filled, it should have its status moved to 'closed'.
@@ -15,7 +15,7 @@
Many models will also want to run a process at the close of market that will cancel all open orders.}
\arguments{\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) should match these}
-\item{timestamp}{timestamp coercible to POSIXct that will be the time to search for orders before this time}
+\item{timespan}{xts-style character timespan to be the period to find orders of the given status and ordertype}
\item{ordertype}{one of NULL, "market","limit","stoplimit", or "stoptrailing" default NULL}
\item{side}{one of NULL, "long" or "short", default NULL}
\item{oldstatus}{one of NULL, "open", "closed", "canceled", or "replaced", default "open"}
More information about the Blotter-commits
mailing list