[Blotter-commits] r876 - pkg/FinancialInstrument/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 11 23:51:02 CET 2011


Author: gsee
Date: 2011-12-11 23:51:01 +0100 (Sun, 11 Dec 2011)
New Revision: 876

Modified:
   pkg/FinancialInstrument/R/buildSpread.R
   pkg/FinancialInstrument/R/synthetic.R
Log:
 - add "sep" formal arg to make_spread_id 
 - remove dot(s) from ICS_root member future primary_ids before making future_series primary_ids 


Modified: pkg/FinancialInstrument/R/buildSpread.R
===================================================================
--- pkg/FinancialInstrument/R/buildSpread.R	2011-12-11 21:36:17 UTC (rev 875)
+++ pkg/FinancialInstrument/R/buildSpread.R	2011-12-11 22:51:01 UTC (rev 876)
@@ -391,6 +391,7 @@
 #' @param x vector of member primary_ids
 #' @param root optional character string of root_id to use.
 #' @param format string indicating how to format the suffix_ids of the spread.  If \code{NULL} (the default), or \code{FALSE}, no formatting will be done.  the See \code{\link{format_id}} for other accepted values for \code{format}
+#' @param sep character string to separate root_id and suffix_id
 #' @return character string that can be used as a primary_id for a \code{\link{spread}} instrument
 #' @author Garrett See
 #' @seealso \code{\link{spread}}, \code{\link{build_spread_symbols}},  \code{\link{build_series_symbols}}
@@ -400,7 +401,7 @@
 #' make_spread_id(ids, format=FALSE)
 #' make_spread_id(c("VIX_JAN11","VIX_FEB11"),root='VX',format='CY')
 #' @export
-make_spread_id <- function(x, root=NULL, format=NULL){
+make_spread_id <- function(x, root=NULL, format=NULL, sep="_"){
 #    if (length(x) != 2) stop("x must be a vector of length 2")
     if (is.null(root)) {
         root <- unlist(unique(sapply(x, parse_id)['root',]))
@@ -410,7 +411,7 @@
 	#if (is.character(format)) suff <- paste(sapply(strsplit(suff,"\\.")[[1]], format_id, format=format, parse='suffix'), collapse=".")
     if (!is.null(format) && is.character(format)) 
 		suff <- paste(format_id(strsplit(suff,"\\.")[[1]], format=format, parse='suffix'), collapse=".")
-    id <- paste(root,suff, sep="_")
+    id <- paste(root,suff, sep=sep)
     return(make.names(id))
 }
 

Modified: pkg/FinancialInstrument/R/synthetic.R
===================================================================
--- pkg/FinancialInstrument/R/synthetic.R	2011-12-11 21:36:17 UTC (rev 875)
+++ pkg/FinancialInstrument/R/synthetic.R	2011-12-11 22:51:01 UTC (rev 876)
@@ -360,7 +360,7 @@
     members <- sapply(memlist, function(x) {
         if (x$type[1] == 'future') {
             if (is.null(x$root)) {
-                paste(x$primary_id, suff.1, sep="_")
+                paste(gsub("\\.", "", x$primary_id), suff.1, sep="_")
             } else paste(x$root, suff.1, sep="_")
         } else x$primary_id
     })



More information about the Blotter-commits mailing list