[Blotter-commits] r613 - in pkg/FinancialInstrument: R demo man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 6 22:37:00 CEST 2011


Author: gsee
Date: 2011-06-06 22:36:59 +0200 (Mon, 06 Jun 2011)
New Revision: 613

Added:
   pkg/FinancialInstrument/demo/00Index
Removed:
   pkg/FinancialInstrument/man/fund.Rd
Modified:
   pkg/FinancialInstrument/R/buildSpread.R
   pkg/FinancialInstrument/R/instrument.R
   pkg/FinancialInstrument/man/buildSpread.Rd
   pkg/FinancialInstrument/man/future_series.Rd
   pkg/FinancialInstrument/man/getSymbols.FI.Rd
   pkg/FinancialInstrument/man/instrument.Rd
   pkg/FinancialInstrument/man/setSymbolLookup.FI.Rd
Log:
-updated docs to pass R CMD check. fixed some typos/bugs.

Modified: pkg/FinancialInstrument/R/buildSpread.R
===================================================================
--- pkg/FinancialInstrument/R/buildSpread.R	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/R/buildSpread.R	2011-06-06 20:36:59 UTC (rev 613)
@@ -11,7 +11,7 @@
 #' \code{\link{spread}} for instructions on defining the spread
 #' @author bpeterson
 #' @export
-buildSpread<- function(spread_id, ..., Dates = NULL, method=c('Close','Midpoint','BA','BB')) {
+buildSpread<- function(spread_id, ..., Dates = NULL, prefer='Mid.Price', onelot=FALSE, method=c('Close','Midpoint','BA','BB')) {
     #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
     spread_instr<-try(getInstrument(spread_id))
@@ -39,7 +39,7 @@
             if(i==1) primary_currency=instr_currency
             stopifnot(is.currency(instr_currency))
             if(!all.equal(primary_currency,instr_currency)){
-                instr_currency<-instr_instr$currency
+                instr_currency<-instr$currency
                 stopifnot(is.currency(instr_currency))
                 exchange_rate<-try(get( paste(primary_currency,instr_currency,sep='')))
                 if(inherits(exchange_rate,"try-error")){
@@ -60,7 +60,7 @@
             #instr_prices<-getPrice(get(as.character(spread_instr$memberlist$members[i])),prefer=prefer)
             instr_prices<-try(get(as.character(spread_instr$memberlist$members[i])))
             if(inherits(instr_prices,"try-error")){
-                instr_prices<-gtetSymbols(as.character(spread_instr$memberlist$members[i]),from=from,to=to)
+                instr_prices<-getSymbols(as.character(spread_instr$memberlist$members[i]),from=from,to=to)
             }
         }        
         instr_norm<-instr_prices*instr_mult*instr_ratio*exchange_rate

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/R/instrument.R	2011-06-06 20:36:59 UTC (rev 613)
@@ -254,6 +254,11 @@
 
 option_series.yahoo <- function(symbol, Exp, currency="USD", multiplier=100, first_traded=NULL, tick_size=NULL) {
     #FIXME: identifiers?
+    
+    if (!("package:quantmod" %in% search() || require("quantmod",quietly=TRUE))) {
+        stop("Please install quantmod before using this function.")
+    }    
+
     opts <- getOptionChain(Symbol=symbol,Exp=Exp, src="yahoo")
 	
 	locals <- function(x) c(rownames(x$calls),rownames(x$puts))
@@ -323,7 +328,8 @@
 #' @param x object to test for type
 #' @export
 is.currency <- function( x ) {
-  x<-getInstrument(x)
+#FIXME: This should not get instrument, but it will break everyone's code if I change it. -Garrett
+  x<-getInstrument(x)       
   inherits( x, "currency" )
 }
 
@@ -365,7 +371,7 @@
     if(inherits(temp_series,"bond_series")) {
         message("updating existing first_traded and maturity for ",id)
         temp_series$first_traded<-c(temp_series$first_traded,first_traded)
-        temp_series$expires<-c(temp_series$expires,expires)
+        temp_series$maturity<-c(temp_series$maturity,maturity)
         assign(id, temp_series, envir=as.environment(.instrument))
     } else {
         dargs<-list(...)

Added: pkg/FinancialInstrument/demo/00Index
===================================================================
--- pkg/FinancialInstrument/demo/00Index	                        (rev 0)
+++ pkg/FinancialInstrument/demo/00Index	2011-06-06 20:36:59 UTC (rev 613)
@@ -0,0 +1 @@
+demo    FinancialInstrument demo

Modified: pkg/FinancialInstrument/man/buildSpread.Rd
===================================================================
--- pkg/FinancialInstrument/man/buildSpread.Rd	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/man/buildSpread.Rd	2011-06-06 20:36:59 UTC (rev 613)
@@ -1,7 +1,7 @@
 \name{buildSpread}
 \alias{buildSpread}
 \title{construct a price/level series for a spread...}
-\usage{buildSpread(spread_id, ..., Dates, onelot=FALSE)}
+\usage{buildSpread(spread_id, ..., Dates = NULL, prefer='Mid.Price', onelot=FALSE, method=c('Close','Midpoint','BA','BB'))}
 \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}
@@ -9,4 +9,6 @@
 \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'}}
+\item{prefer}{preferred column to use}
+\item{onelot}{TRUE/FALSE, if TRUE, will divide by the number of units of the front leg to get a 'onelot'}
+\item{method}{method for pricing: Close, Midpoint BA, BB} }

Deleted: pkg/FinancialInstrument/man/fund.Rd
===================================================================
--- pkg/FinancialInstrument/man/fund.Rd	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/man/fund.Rd	2011-06-06 20:36:59 UTC (rev 613)
@@ -1,4 +0,0 @@
-\name{fund}
-\alias{fund}
-\title{fund}
-\usage{fund(primary_id, currency, multiplier=1, tick_size=0.01, identifiers, ...)}

Modified: pkg/FinancialInstrument/man/future_series.Rd
===================================================================
--- pkg/FinancialInstrument/man/future_series.Rd	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/man/future_series.Rd	2011-06-06 20:36:59 UTC (rev 613)
@@ -1,10 +1,15 @@
 \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{
+future_series(primary_id, suffix_id, first_traded, expires, identifiers, ...)
+bond_series(primary_id , suffix_id, ..., first_traded=NULL, maturity=NULL, identifiers = NULL, payment_schedule=NULL)
+option_series(primary_id , suffix_id, first_traded=NULL, expires=NULL, callput=c("call","put"), identifiers = NULL, ...)
+}
 \description{constructors for series contracts on instruments such as options and futures}
 \details{In custom parameters for these series contracts, we have often found it
 useful to store attributes such as local roll-on and roll-off dates
 (rolling not on the \code{first_listed} or \code{expires}}
+\seealso{option_series.yahoo}
 \alias{option_series}
 \alias{future_series}
 \alias{bond_series}
@@ -14,4 +19,6 @@
 \item{expires}{string coercible to Date for expiration date}
 \item{maturity}{string coercible to Date for maturity date of bond series}
 \item{identifiers}{named list of any other identifiers that should also be stored for this instrument}
+\item{callput}{right of option; call or put}
+\item{payment_schedule}{not currently being implemented}
 \item{...}{any other passthru parameters}}

Modified: pkg/FinancialInstrument/man/getSymbols.FI.Rd
===================================================================
--- pkg/FinancialInstrument/man/getSymbols.FI.Rd	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/man/getSymbols.FI.Rd	2011-06-06 20:36:59 UTC (rev 613)
@@ -1,7 +1,18 @@
 \name{getSymbols.FI}
 \alias{getSymbols.FI}
 \title{getSymbols method for loading data from split files...}
-\usage{getSymbols.FI(Symbols, from="2010-01-01", to=Sys.Date(), ..., env, dir="", return.class="xts", extension="rda", date_format)}
+\usage{getSymbols.FI(Symbols,
+                            from='2010-01-01',
+                            to=Sys.Date(),
+                            ..., 
+                            env,
+                            dir="",
+                            return.class="xts",
+                            extension="rda",
+                            date_format=NULL,
+							verbose=TRUE,
+							auto.assign=TRUE
+                         )}
 \description{getSymbols method for loading data from split files}
 \details{This function should probably get folded back into getSymbols.rda in quantmod.
 
@@ -23,4 +34,7 @@
 \item{dir}{if not specified in getSymbolLookup, directory string to use.  default ""}
 \item{return.class}{only "xts" is currently supported}
 \item{extension}{file extension, default "rda"}
-\item{date_format}{format as per the \code{\link{strptime}}, see Details}}
+\item{date_format}{format as per the \code{\link{strptime}}, see Details}
+\item{verbose}{be verbose?}
+\item{auto.assign}{auto assign?}
+}

Modified: pkg/FinancialInstrument/man/instrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/instrument.Rd	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/man/instrument.Rd	2011-06-06 20:36:59 UTC (rev 613)
@@ -41,11 +41,11 @@
 \code{\link{future_series}}
 \code{\link{load.instruments}}}
 \arguments{\item{primary_id}{string describing the unique ID for the instrument}
-\item{...}{any other passthru parameters}
+\item{...}{any other passthru parameters, including sQuote{underlying_id} for derivatives}
 \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{tick_size}{the tick increment of the instrument price in it's trading venue, as numeric quantity (e.g. 1/8 is .125)}
 \item{identifiers}{named list of any other identifiers that should also be stored for this instrument}
 \item{type}{instrument type to be appended to the class definition, typically not set by user}
-\item{underlying_id}{for derivatives, the identifier of the instrument that this one is derived from, may be NULL for cash settled instruments}
+%\item{underlying_id}{for derivatives, the identifier of the instrument that this one is derived from, may be NULL for cash settled instruments}
 \item{assign_i}{TRUE/FALSE if TRUE, assign the instrument to the .instrument environment, default FALSE}}

Modified: pkg/FinancialInstrument/man/setSymbolLookup.FI.Rd
===================================================================
--- pkg/FinancialInstrument/man/setSymbolLookup.FI.Rd	2011-06-05 18:13:01 UTC (rev 612)
+++ pkg/FinancialInstrument/man/setSymbolLookup.FI.Rd	2011-06-06 20:36:59 UTC (rev 613)
@@ -1,7 +1,7 @@
 \name{setSymbolLookup.FI}
 \alias{setSymbolLookup.FI}
 \title{set quantmod-style SymbolLookup for instruments...}
-\usage{setSymbolLookup.FI(base_dir, ..., split_method=c("days", "common"), storage_method="rda", use_identifier="primary_id", extension="rda")}
+\usage{setSymbolLookup.FI(base_dir,..., split_method=c("days","common"), storage_method='rda', use_identifier='primary_id', extension='rda', src='FI')}
 \description{set quantmod-style SymbolLookup for instruments}
 \details{This function exists to tell \code{\link[quantmod]{getSymbols}} where to look for your repository of market data.
 
@@ -23,4 +23,6 @@
 \item{storage_method}{currently only \sQuote{rda}, but we will eventually support \sQuote{indexing} at least, and maybe others}
 \item{split_method}{string specifying the method files are split, currently \sQuote{days} or \sQuote{common}, see Details}
 \item{use_identifier}{string identifying which column should be use to construct the \code{primary_id} of the instrument, default 'primary_id'}
-\item{extension}{file extension, default "rda"}}
+\item{extension}{file extension, default "rda"}
+\item{src}{which getSymbols sub-type to use}
+}



More information about the Blotter-commits mailing list