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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 4 19:45:32 CET 2011


Author: gsee
Date: 2011-12-04 19:45:32 +0100 (Sun, 04 Dec 2011)
New Revision: 859

Modified:
   pkg/FinancialInstrument/R/instrument.R
Log:
 If 'make.names' changes the primary_id, create an identifier from the original primary_id


Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2011-12-04 16:27:15 UTC (rev 858)
+++ pkg/FinancialInstrument/R/instrument.R	2011-12-04 18:45:32 UTC (rev 859)
@@ -87,7 +87,7 @@
 #' @export
 instrument<-function(primary_id , ..., currency , multiplier , tick_size=NULL, identifiers = NULL, type=NULL, assign_i=FALSE ){
   if(is.null(primary_id)) stop("you must specify a primary_id for the instrument")
-  
+  raw_id <- primary_id
   #deal with leading digits or illegal characters
   if(substr(primary_id,1,1)==1) primary_id <- substr(primary_id,2,nchar(primary_id))
   primary_id<-make.names(primary_id)
@@ -100,6 +100,10 @@
       warning("identifiers",identifiers,"do not appear to be a named list")
   } 
 
+  if (raw_id != primary_id) {
+      identifiers <- c(identifiers, raw_id=raw_id)
+  }
+
   arg<-list(...)
   if(is.list(arg[['...']])){
       if(length(arg)==1) arg <- arg[['...']]



More information about the Blotter-commits mailing list