[Blotter-commits] r953 - in pkg/FinancialInstrument: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Mar 3 00:39:28 CET 2012
Author: gsee
Date: 2012-03-03 00:39:28 +0100 (Sat, 03 Mar 2012)
New Revision: 953
Added:
pkg/FinancialInstrument/man/expires.xts.Rd
Modified:
pkg/FinancialInstrument/DESCRIPTION
pkg/FinancialInstrument/NAMESPACE
pkg/FinancialInstrument/R/expires.R
pkg/FinancialInstrument/man/expires.instrument.Rd
Log:
add expires.xts, an xts expires extraction method
Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION 2012-03-02 00:14:51 UTC (rev 952)
+++ pkg/FinancialInstrument/DESCRIPTION 2012-03-02 23:39:28 UTC (rev 953)
@@ -11,7 +11,7 @@
meta-data and relationships. Provides support for
multi-asset class and multi-currency portfolios. Still
in heavy development.
-Version: 0.12.2
+Version: 0.12.3
URL: https://r-forge.r-project.org/projects/blotter/
Date: $Date$
Depends:
Modified: pkg/FinancialInstrument/NAMESPACE
===================================================================
--- pkg/FinancialInstrument/NAMESPACE 2012-03-02 00:14:51 UTC (rev 952)
+++ pkg/FinancialInstrument/NAMESPACE 2012-03-02 23:39:28 UTC (rev 953)
@@ -118,6 +118,7 @@
S3method(all.equal,instrument)
S3method(expires,character)
S3method(expires,instrument)
+S3method(expires,xts)
S3method(print,id.list)
S3method(print,instrument)
S3method(print,suffix.list)
Modified: pkg/FinancialInstrument/R/expires.R
===================================================================
--- pkg/FinancialInstrument/R/expires.R 2012-03-02 00:14:51 UTC (rev 952)
+++ pkg/FinancialInstrument/R/expires.R 2012-03-02 23:39:28 UTC (rev 953)
@@ -69,6 +69,7 @@
#' @param silent silence warnings?
#' @method expires instrument
#' @S3method expires instrument
+#' @seealso \code{\link{expires}}
#' @author Garrett See
#' @keywords internal
expires.instrument <- function(x, Date, expired=TRUE, silent=FALSE, ...) {
@@ -191,7 +192,33 @@
}
-
-
-
-
+#' xts expires extraction method
+#'
+#' determines (or estimates) the expiration from an xts object by either
+#' finding the last row that is not \code{NA} or by passing the name/symbol
+#' of the xts object to \code{\link{expires.character}}
+#'
+#' @param src either \dQuote{data} or \dQuote{instrument}.
+#' @return If \code{src} is \dQuote{"data"}, the returned value will be the
+#' index of the last price that is not \code{NA} (price is determined by
+#' \code{quantmod:::getPrice}. \code{getPrice} arguments \code{symbol} and
+#' \code{prefer} can be passed through dots.)
+#'
+#' If \code{src} is \dQuote{instrument} the symbol of the xts object will
+#' be passed to \code{\link{expires.character}}
+#' @method expires xts
+#' @S3method expires xts
+#' @seealso \code{\link{expires.instrument}}, \code{\link{expires}}
+#' @author Garrett See
+#' @keywords internal
+expires.xts <- function(x, Date, expired=TRUE, silent=FALSE,
+ src=c("data", "instrument"), ...) {
+ src <- c("data", "instrument")[pmatch(src, c("data", "instrument"))[[1L]]]
+ if (src == "data") {
+ end(na.omit(getPrice(x, ...)))
+ } else if (src == "instrument") {
+ Symbol <- deparse(substitute(x))
+ expires.character(Symbol, Date=Date, expired=expired, silent=silent,
+ ...=...)
+ } else NextMethod("expires")
+}
Modified: pkg/FinancialInstrument/man/expires.instrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/expires.instrument.Rd 2012-03-02 00:14:51 UTC (rev 952)
+++ pkg/FinancialInstrument/man/expires.instrument.Rd 2012-03-02 23:39:28 UTC (rev 953)
@@ -30,5 +30,8 @@
\author{
Garrett See
}
+\seealso{
+ \code{\link{expires}}
+}
\keyword{internal}
Added: pkg/FinancialInstrument/man/expires.xts.Rd
===================================================================
--- pkg/FinancialInstrument/man/expires.xts.Rd (rev 0)
+++ pkg/FinancialInstrument/man/expires.xts.Rd 2012-03-02 23:39:28 UTC (rev 953)
@@ -0,0 +1,35 @@
+\name{expires.xts}
+\alias{expires.xts}
+\title{xts expires extraction method}
+\usage{
+ \method{expires}{xts} (x, Date, expired = TRUE,
+ silent = FALSE, src = c("data", "instrument"), ...)
+}
+\arguments{
+ \item{src}{either \dQuote{data} or \dQuote{instrument}.}
+}
+\value{
+ If \code{src} is \dQuote{"data"}, the returned value will
+ be the index of the last price that is not \code{NA}
+ (price is determined by \code{quantmod:::getPrice}.
+ \code{getPrice} arguments \code{symbol} and \code{prefer}
+ can be passed through dots.)
+
+ If \code{src} is \dQuote{instrument} the symbol of the
+ xts object will be passed to
+ \code{\link{expires.character}}
+}
+\description{
+ determines (or estimates) the expiration from an xts
+ object by either finding the last row that is not
+ \code{NA} or by passing the name/symbol of the xts object
+ to \code{\link{expires.character}}
+}
+\author{
+ Garrett See
+}
+\seealso{
+ \code{\link{expires.instrument}}, \code{\link{expires}}
+}
+\keyword{internal}
+
More information about the Blotter-commits
mailing list