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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 6 01:25:06 CET 2011


Author: gsee
Date: 2011-12-06 01:25:06 +0100 (Tue, 06 Dec 2011)
New Revision: 862

Modified:
   pkg/FinancialInstrument/R/instrument.R
Log:
 - getInstrument was ignoring names that begin with a dot in its first search through .instrument.
   It now includes all names in its 1st search, so that it will find future/option easier
 - simplied matching syntax


Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2011-12-05 19:26:55 UTC (rev 861)
+++ pkg/FinancialInstrument/R/instrument.R	2011-12-06 00:25:06 UTC (rev 862)
@@ -845,14 +845,13 @@
 #' @export
 #' @rdname getInstrument
 getInstrument <- function(x, Dates=NULL, silent=FALSE, type='instrument'){
-    tmp_instr<-try(get(x,pos=.instrument),silent=TRUE) #removed inherits=TRUE
-    if(inherits(tmp_instr,"try-error") | !inherits(tmp_instr, type)){
+    tmp_instr <- try(get(x,pos=.instrument),silent=TRUE) #removed inherits=TRUE
+    if(inherits(tmp_instr,"try-error") || !inherits(tmp_instr, type)){
         #first search
-        instr_list<-ls(pos=.instrument)
+        instr_list <- ls(pos=.instrument, all.names=TRUE)
         for (instr in instr_list){
-            tmp_instr<-try(get(instr,pos=.instrument),silent=TRUE)
-            if(inherits(tmp_instr, type) && 
-                    (!is.na(suppressWarnings(match(x, tmp_instr$identifiers) || !is.na(suppressWarnings(match(x, make.names(tmp_instr$identifiers)))))))) {
+            tmp_instr <- try(get(instr, pos=.instrument), silent=TRUE)
+            if(inherits(tmp_instr, type) && (x %in% tmp_instr$identifiers || x %in% make.names(tmp_instr$identifiers))) {
                 return(tmp_instr)
             }
         }



More information about the Blotter-commits mailing list