[Blotter-commits] r248 - in pkg/FinancialInstrument: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 17 20:07:32 CET 2010


Author: braverock
Date: 2010-02-17 20:07:31 +0100 (Wed, 17 Feb 2010)
New Revision: 248

Added:
   pkg/FinancialInstrument/R/volep.R
   pkg/FinancialInstrument/man/buildSpread.Rd
   pkg/FinancialInstrument/man/exchange_rate.Rd
   pkg/FinancialInstrument/man/future_series.Rd
   pkg/FinancialInstrument/man/getInstrument.Rd
   pkg/FinancialInstrument/man/is.currency.Rd
   pkg/FinancialInstrument/man/is.instrument.Rd
   pkg/FinancialInstrument/man/synthetic.ratio.Rd
   pkg/FinancialInstrument/man/volep.Rd
Modified:
   pkg/FinancialInstrument/DESCRIPTION
   pkg/FinancialInstrument/NAMESPACE
   pkg/FinancialInstrument/R/buildSpread.R
   pkg/FinancialInstrument/R/instrument.R
   pkg/FinancialInstrument/R/synthetic.R
   pkg/FinancialInstrument/man/instrument.Rd
Log:
- add minimal documentation for package

Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION	2010-02-16 22:23:10 UTC (rev 247)
+++ pkg/FinancialInstrument/DESCRIPTION	2010-02-17 19:07:31 UTC (rev 248)
@@ -2,12 +2,14 @@
 Type: Package
 Title: Financial Instrument Model Infrastructure for R
 Version: 0.0.2
-Date: $Date: 2009-11-12 15:36:18 -0600 (Thu, 12 Nov 2009) $
+Date: $Date$
 Author: Peter Carl, Dirk Eddelbuettel, Jeffrey Ryan, Joshua Ulrich, Brian G. Peterson
 Maintainer: Peter Carl <peter at braverock.com>
-Description: Infrastructure for defining instruments meta-data and relationships. Provides support for multi-asset class and multi-currency portfolios.  Still in heavy development.
+Description: Infrastructure for defining instruments meta-data and relationships. Provides support for multi-asset class and multi-currency
+    portfolios.  Still in heavy development.
 License: GPL
 LazyLoad: yes
 Depends: R (>= 2.9.0), xts, zoo
 Suggests: quantmod
 Copyright: (c) 2004 - 2010
+Collate: 'buildSpread.R' 'instrument.R' 'synthetic.R' 'volep.R'


Property changes on: pkg/FinancialInstrument/DESCRIPTION
___________________________________________________________________
Name: svn:keywords
   + Id Revision Date Author

Modified: pkg/FinancialInstrument/NAMESPACE
===================================================================
--- pkg/FinancialInstrument/NAMESPACE	2010-02-16 22:23:10 UTC (rev 247)
+++ pkg/FinancialInstrument/NAMESPACE	2010-02-17 19:07:31 UTC (rev 248)
@@ -1,2 +1,9 @@
-
-exportPattern("^([^.]|\\..+\\.)")
+export(buildSpread)
+export(is.instrument)
+export(instrument)
+export(future_series)
+export(is.currency)
+export(exchange_rate)
+export(getInstrument)
+export(synthetic.ratio)
+export(volep)

Modified: pkg/FinancialInstrument/R/buildSpread.R
===================================================================
--- pkg/FinancialInstrument/R/buildSpread.R	2010-02-16 22:23:10 UTC (rev 247)
+++ pkg/FinancialInstrument/R/buildSpread.R	2010-02-17 19:07:31 UTC (rev 248)
@@ -1,3 +1,16 @@
+#' construct a price/level series for a spread
+#' 
+#' this function should provide a generic spread series builder.  
+#' 
+#' 
+#' @param spread_id string descrining the primary_id of an instrument of type 'spread 
+#' @param ... any other passthru parameters
+#' @param Dates date range to subset on, currently not implemented
+#' @param onelot TRUE/FALSE, if TRUE, will divide by the number of units of the front leg to get a 'onelot'
+#' @seealso 
+#' \code{\link{spread}} for instructions on defining the spread
+#' @author bpeterson
+#' @export
 buildSpread<- function(spread_id, ..., Dates = NULL, onelot=FALSE) {
     #TODO subset using Dates arg?  or let the +/- operators deal with it?
     #TODO FIXME put some intelligence in the subsetting and intersection, maybe up front or in a checkData style
@@ -52,10 +65,11 @@
 
 
 ###############################################################################
-# Blotter: Tools for transaction-oriented trading systems development
-# for R (see http://r-project.org/) 
-# Copyright (c) 2008-2010 Peter Carl and Brian G. Peterson
+# R (http://r-project.org/) Instrument Class Model
 #
+# Copyright (c) 2009-2010
+# Peter Carl, Dirk Eddelbuettel, Jeffrey Ryan, Joshua Ulrich and Brian G. Peterson
+#
 # This library is distributed under the terms of the GNU Public License (GPL)
 # for full details see the file COPYING
 #

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2010-02-16 22:23:10 UTC (rev 247)
+++ pkg/FinancialInstrument/R/instrument.R	2010-02-17 19:07:31 UTC (rev 248)
@@ -18,10 +18,36 @@
 
 ## we should probably assign instruments into a special namespace and create get* functions.  Jeff?
 
+#' class test for object supposedly of type 'instrument'
+#' @param x object to test for type
+#' @export
 is.instrument <- function( x ) {
   inherits( x, "instrument" )
 }
 
+#' instrument class constructors
+#' 
+#' All 'currency' instruments must be defined before instruments of other types may be defined
+#' 
+#' @param primary_id string describing the unique ID for the instrument
+#' @param currency string describing the currency ID of an object of type \code{\link{currency}}
+#' @param multiplier numeric multiplier to apply to the price in the instrument currency to get to notional value
+#' @param identifiers character vector of any other identifiers that should also be stored for this instrument
+#' @param ... any other passthru parameters 
+#' @param type instrument type to be appended to the class definition
+#' @param underlying_id for derivatives, the identifier of the instrument that this one is derived from, may be NULL for cash settled instruments
+#' @aliases 
+#' stock
+#' bond
+#' future
+#' option
+#' currency
+#' instrument
+#' @seealso 
+#' \code{\link{exchange_rate}}
+#' \code{\link{option_series}}
+#' \code{\link{future_series}}
+#' @export
 instrument<-function(primary_id , currency , multiplier , identifiers = NULL, ...,type=NULL ){
   if(is.null(primary_id)) stop("you must specify a primary_id for the instrument")
 
@@ -82,6 +108,17 @@
   )
 }
 
+#' constructors for series contracts on instruments such as options and futures
+#' @param primary_id string describing the unique ID for the instrument
+#' @param suffix_id string suffix that should be associated with the series, usually something like 'Z9' or 'Mar10' denoting expiration and year
+#' @param first_traded string coercible to Date for first trading day
+#' @param expires string coercible to Date for expiration date
+#' @param identifiers character vector of any other identifiers that should also be stored for this instrument
+#' @param ... any other passthru parameters
+#' @aliases 
+#' option_series
+#' future_series
+#' @export
 future_series <- function(primary_id , suffix_id, first_traded=NULL, expires=NULL, identifiers = NULL, ...){
   contract<-try(getInstrument(primary_id))
   if(!inherits(contract,"future")) stop("futures contract spec must be defined first")
@@ -176,11 +213,21 @@
   )
 }
 
+#' class test for object supposedly of type 'currency'
+#' @param x object to test for type
+#' @export
 is.currency <- function( x ) {
   x<-getInstrument(x)
   inherits( x, "currency" )
 }
 
+#' constructor for spot exchange rate instruments
+#' @param primary_id string identifier, usually expressed as a currency pair 'USDYEN' or 'EURGBP'
+#' @param currency string identifying front currency
+#' @param second_currency string identifying second currency
+#' @param identifiers character vector of any other identifiers that should also be stored for this instrument
+#' @param ... any other passthru parameters
+#' @export
 exchange_rate <- function (primary_id , currency , second_currency, identifiers = NULL, ...){
   exchange_rate_temp = instrument(primary_id , currency , multiplier=1 , identifiers = identifiers, ..., type="exchange_rate")
 
@@ -216,7 +263,10 @@
 }
 
 
-
+#' primare accessor function for getting objects of type 'instrument'
+#' @param x string identifier of instrument to retrieve
+#' @param Dates date range to retrieve 'as of', may not currently be implemented
+#' @export
 getInstrument <- function(x, Dates=NULL){
     tmp_instr<-get(x,pos=.instrument) #removed inherits=TRUE
     if(inherits(tmp_instr,"try-error") | !is.instrument(tmp_instr)){

Modified: pkg/FinancialInstrument/R/synthetic.R
===================================================================
--- pkg/FinancialInstrument/R/synthetic.R	2010-02-16 22:23:10 UTC (rev 247)
+++ pkg/FinancialInstrument/R/synthetic.R	2010-02-17 19:07:31 UTC (rev 248)
@@ -27,6 +27,20 @@
            )
 }
 
+#' constructors for synthetic instruments
+#' @param primary_id string describing the unique ID for the instrument
+#' @param currency string describing the currency ID of an object of type \code{\link{currency}}
+#' @param multiplier numeric multiplier to apply to the price in the instrument currency to get to notional value
+#' @param identifiers character vector of any other identifiers that should also be stored for this instrument
+#' @param ... any other passthru parameters 
+#' @param cl class string, should not be set by users
+#' @param members character vector of instrument identifiers that make up the synthetic
+#' @param memberratio numeric vector of ratio relationchips between members, e.g. c(4,3) for a 4:3 spread
+#' @aliases
+#' synthetic
+#' spread 
+#' synthetic.ratio
+#' @export
 synthetic.ratio <- function(primary_id , currency , multiplier=1, identifiers = NULL, ..., cl=c("synthetic.ratio","synthetic","instrument"), members, memberratio)
 {
     #TODO make sure that with options/futures or other  instruments that we have you use the base contract

Added: pkg/FinancialInstrument/R/volep.R
===================================================================
--- pkg/FinancialInstrument/R/volep.R	                        (rev 0)
+++ pkg/FinancialInstrument/R/volep.R	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,27 @@
+
+
+#' generate endpoints for volume bars
+#' @param x time series containing 'Volume' column
+#' @param units volume sum to mark for bars
+#' @author Joshua Ulrich
+#' @export
+volep <- function (x, units){
+    incepSum <- runSum(Vo(x),1,TRUE)                               
+    bins <- incepSum %/% units
+    bins[1]<-0
+    ep<-which(diff(bins)!=0)
+    return(ep)
+}
+
+###############################################################################
+# R (http://r-project.org/) Instrument Class Model
+#
+# Copyright (c) 2009-2010
+# Peter Carl, Dirk Eddelbuettel, Jeffrey Ryan, Joshua Ulrich and Brian G. Peterson
+#
+# This library is distributed under the terms of the GNU Public License (GPL)
+# for full details see the file COPYING
+#
+# $Id$
+#
+###############################################################################


Property changes on: pkg/FinancialInstrument/R/volep.R
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/buildSpread.Rd
===================================================================
--- pkg/FinancialInstrument/man/buildSpread.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/buildSpread.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,12 @@
+\name{buildSpread}
+\alias{buildSpread}
+\title{construct a price/level series for a spread...}
+\usage{buildSpread(spread_id, ..., Dates, onelot=FALSE)}
+\description{construct a price/level series for a spread}
+\details{this function should provide a generic spread series builder.}
+\seealso{\code{\link{spread}} for instructions on defining the spread}
+\author{bpeterson}
+\arguments{\item{spread_id}{string descrining the primary_id of an instrument of type 'spread}
+\item{...}{any other passthru parameters}
+\item{Dates}{date range to subset on, currently not implemented}
+\item{onelot}{TRUE/FALSE, if TRUE, will divide by the number of units of the front leg to get a 'onelot'}}


Property changes on: pkg/FinancialInstrument/man/buildSpread.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/exchange_rate.Rd
===================================================================
--- pkg/FinancialInstrument/man/exchange_rate.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/exchange_rate.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,10 @@
+\name{exchange_rate}
+\alias{exchange_rate}
+\title{constructor for spot exchange rate instruments...}
+\usage{exchange_rate(primary_id, currency, second_currency, identifiers, ...)}
+\description{constructor for spot exchange rate instruments}
+\arguments{\item{primary_id}{string identifier, usually expressed as a currency pair 'USDYEN' or 'EURGBP'}
+\item{currency}{string identifying front currency}
+\item{second_currency}{string identifying second currency}
+\item{identifiers}{character vector of any other identifiers that should also be stored for this instrument}
+\item{...}{any other passthru parameters}}


Property changes on: pkg/FinancialInstrument/man/exchange_rate.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/future_series.Rd
===================================================================
--- pkg/FinancialInstrument/man/future_series.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/future_series.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,13 @@
+\name{future_series}
+\title{constructors for series contracts on instruments such as options and futures...}
+\usage{future_series(primary_id, suffix_id, first_traded, expires, identifiers, ...)}
+\usage{option_series(primary_id, suffix_id, first_traded, expires, callput=c("call", "put"), identifiers, ...)}
+\description{constructors for series contracts on instruments such as options and futures}
+\alias{option_series}
+\alias{future_series}
+\arguments{\item{primary_id}{string describing the unique ID for the instrument}
+\item{suffix_id}{string suffix that should be associated with the series, usually something like 'Z9' or 'Mar10' denoting expiration and year}
+\item{first_traded}{string coercible to Date for first trading day}
+\item{expires}{string coercible to Date for expiration date}
+\item{identifiers}{character vector of any other identifiers that should also be stored for this instrument}
+\item{...}{any other passthru parameters}}


Property changes on: pkg/FinancialInstrument/man/future_series.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/getInstrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/getInstrument.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/getInstrument.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,7 @@
+\name{getInstrument}
+\alias{getInstrument}
+\title{primare accessor function for getting objects of type 'instrument'...}
+\usage{getInstrument(x, Dates)}
+\description{primare accessor function for getting objects of type 'instrument'}
+\arguments{\item{x}{string identifier of instrument to retrieve}
+\item{Dates}{date range to retrieve 'as of', may not currently be implemented}}


Property changes on: pkg/FinancialInstrument/man/getInstrument.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Modified: pkg/FinancialInstrument/man/instrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/instrument.Rd	2010-02-16 22:23:10 UTC (rev 247)
+++ pkg/FinancialInstrument/man/instrument.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -1,27 +1,27 @@
 \name{instrument}
-\Rdversion{1.1}
+\title{instrument class constructors...}
+\usage{instrument(primary_id, currency, multiplier, identifiers, ..., type)}
+\usage{bond(primary_id, currency, multiplier, identifiers, ...)}
+\usage{stock(primary_id, currency, multiplier, identifiers, ...)}
+\usage{future(primary_id, currency, multiplier, identifiers, ..., underlying_id)}
+\usage{option(primary_id, currency, multiplier, identifiers, ..., underlying_id)}
+\usage{currency(primary_id, currency, multiplier=1, identifiers, ...)}
+
+\description{instrument class constructors}
+\details{All 'currency' instruments must be defined before instruments of other types may be defined}
+\alias{stock}
+\alias{bond}
+\alias{future}
+\alias{option}
+\alias{currency}
 \alias{instrument}
-\docType{data}
-\title{Instrument class model }
-\description{
-%%  ~~ A concise (1-5 lines) description of the dataset. ~~
-}
-\usage{data(instrument)}
-\format{
-  The format is:
- chr "instrument"
-}
-\details{
-%%  ~~ If necessary, more details than the __description__ above ~~
-}
-\source{
-%%  ~~ reference to a publication or URL from which the data were obtained ~~
-}
-\references{
-%%  ~~ possibly secondary sources and usages ~~
-}
-\examples{
-data(instrument)
-## maybe str(instrument) ; plot(instrument) ...
-}
-\keyword{datasets}
+\seealso{\code{\link{exchange_rate}}
+\code{\link{option_series}}
+\code{\link{future_series}}}
+\arguments{\item{primary_id}{string describing the unique ID for the instrument}
+\item{currency}{string describing the currency ID of an object of type \code{\link{currency}}}
+\item{multiplier}{numeric multiplier to apply to the price in the instrument currency to get to notional value}
+\item{identifiers}{character vector of any other identifiers that should also be stored for this instrument}
+\item{...}{any other passthru parameters}
+\item{type}{instrument type to be appended to the class definition}
+\item{underlying_id}{for derivatives, the identifier of the instrument that this one is derived from, may be NULL for cash settled instruments}}


Property changes on: pkg/FinancialInstrument/man/instrument.Rd
___________________________________________________________________
Name: svn:keywords
   + Id Revision Date Author

Added: pkg/FinancialInstrument/man/is.currency.Rd
===================================================================
--- pkg/FinancialInstrument/man/is.currency.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/is.currency.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,6 @@
+\name{is.currency}
+\alias{is.currency}
+\title{class test for object supposedly of type 'currency'...}
+\usage{is.currency(x)}
+\description{class test for object supposedly of type 'currency'}
+\arguments{\item{x}{object to test for type}}


Property changes on: pkg/FinancialInstrument/man/is.currency.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/is.instrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/is.instrument.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/is.instrument.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,6 @@
+\name{is.instrument}
+\alias{is.instrument}
+\title{class test for object supposedly of type 'instrument'...}
+\usage{is.instrument(x)}
+\description{class test for object supposedly of type 'instrument'}
+\arguments{\item{x}{object to test for type}}


Property changes on: pkg/FinancialInstrument/man/is.instrument.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/synthetic.ratio.Rd
===================================================================
--- pkg/FinancialInstrument/man/synthetic.ratio.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/synthetic.ratio.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,16 @@
+\name{synthetic.ratio}
+\title{constructors for synthetic instruments...}
+\usage{synthetic.ratio(primary_id, currency, multiplier=1, identifiers, ..., cl=c("synthetic.ratio", "synthetic", "instrument"), members, memberratio)}
+\usage{synthetic(primary_id, currency, multiplier=1, identifiers, ..., members, cl=c("synthetic", "instrument"))}
+\description{constructors for synthetic instruments}
+\alias{synthetic}
+\alias{spread}
+\alias{synthetic.ratio}
+\arguments{\item{primary_id}{string describing the unique ID for the instrument}
+\item{currency}{string describing the currency ID of an object of type \code{\link{currency}}}
+\item{multiplier}{numeric multiplier to apply to the price in the instrument currency to get to notional value}
+\item{identifiers}{character vector of any other identifiers that should also be stored for this instrument}
+\item{...}{any other passthru parameters}
+\item{cl}{class string, should not be set by users}
+\item{members}{character vector of instrument identifiers that make up the synthetic}
+\item{memberratio}{numeric vector of ratio relationchips between members, e.g. c(4,3) for a 4:3 spread}}


Property changes on: pkg/FinancialInstrument/man/synthetic.ratio.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author

Added: pkg/FinancialInstrument/man/volep.Rd
===================================================================
--- pkg/FinancialInstrument/man/volep.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/volep.Rd	2010-02-17 19:07:31 UTC (rev 248)
@@ -0,0 +1,8 @@
+\name{volep}
+\alias{volep}
+\title{generate endpoints for volume bars...}
+\usage{volep(x, units)}
+\description{generate endpoints for volume bars}
+\author{Joshua Ulrich}
+\arguments{\item{x}{time series containing 'Volume' column}
+\item{units}{volume sum to mark for bars}}


Property changes on: pkg/FinancialInstrument/man/volep.Rd
___________________________________________________________________
Name: svn:keywords
   + Revision Id Date Author



More information about the Blotter-commits mailing list