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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 7 22:00:44 CEST 2011


Author: gsee
Date: 2011-09-07 22:00:43 +0200 (Wed, 07 Sep 2011)
New Revision: 761

Modified:
   pkg/FinancialInstrument/R/format_id.R
   pkg/FinancialInstrument/R/parse_id.R
Log:
oversight from sep implementation patched and patch for parsing synthetic ids

Modified: pkg/FinancialInstrument/R/format_id.R
===================================================================
--- pkg/FinancialInstrument/R/format_id.R	2011-09-07 19:24:20 UTC (rev 760)
+++ pkg/FinancialInstrument/R/format_id.R	2011-09-07 20:00:43 UTC (rev 761)
@@ -60,9 +60,9 @@
                     ifelse(pid$format == "opt2", paste(pid$root, paste("20",suffix,sep=""), sep=sep), i)
                 }, 
                 i)
-		} else tmp <- paste(pid$root,suffix,sep=sep)
-        if (substr(tmp,1,1) == "_") tmp <- substr(tmp,2,nchar(tmp))
-        if (substr(tmp,nchar(tmp),nchar(tmp)) == "_") tmp <- substr(tmp,1,nchar(tmp)-1)
+		} else tmp <- if (suffix=="") {pid$root} else paste(pid$root,suffix,sep=sep)
+        if (substr(tmp,1,nchar(sep)) == sep) tmp <- substr(tmp,nchar(sep)+1,nchar(tmp))
+        if (substr(tmp,nchar(tmp)-nchar(sep)+1,nchar(tmp)) == sep) tmp <- substr(tmp,1,nchar(tmp)-nchar(sep))
         out <- c(out, tmp)
     }
     out

Modified: pkg/FinancialInstrument/R/parse_id.R
===================================================================
--- pkg/FinancialInstrument/R/parse_id.R	2011-09-07 19:24:20 UTC (rev 760)
+++ pkg/FinancialInstrument/R/parse_id.R	2011-09-07 20:00:43 UTC (rev 761)
@@ -41,8 +41,10 @@
                 root <- substr(root, 1,nchar(root)-1)
                 suffix <- gsub(root,"",x) #whatever isn't the root
             } else { #probably a synthetic: SPY.DIA, GLD.EUR
-                suffix <- x
+                suffix <- ""
                 root <- x
+                type <- 'synthetic'
+                sufftype <- FALSE
             }
         } else if (identical(all.equal(nchar(x) - nchar( gsub("\\.","",x)),2), TRUE)) { 
             #2 dots, so we'll treat it as a fly, although it could be a basket



More information about the Blotter-commits mailing list