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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 13 20:40:27 CET 2010


Author: braverock
Date: 2010-12-13 20:40:26 +0100 (Mon, 13 Dec 2010)
New Revision: 494

Modified:
   pkg/FinancialInstrument/R/instrument.R
   pkg/FinancialInstrument/R/load.instruments.R
Log:
- add silent argument to getInstrument, FALSE by default

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2010-12-13 19:24:49 UTC (rev 493)
+++ pkg/FinancialInstrument/R/instrument.R	2010-12-13 19:40:26 UTC (rev 494)
@@ -338,7 +338,7 @@
 #' @param x string identifier of instrument to retrieve
 #' @param Dates date range to retrieve 'as of', may not currently be implemented
 #' @export
-getInstrument <- function(x, Dates=NULL){
+getInstrument <- function(x, Dates=NULL, silent=FALSE){
     tmp_instr<-try(get(x,pos=.instrument),silent=TRUE) #removed inherits=TRUE
     if(inherits(tmp_instr,"try-error") | !is.instrument(tmp_instr)){
         #first search
@@ -349,7 +349,7 @@
                 return(tmp_instr)
             }
         }
-        warning(paste("Instrument",x," not found, please create it first."))
+        if(!silent) warning(paste("Instrument",x," not found, please create it first."))
         return(FALSE)
     } else{
         return(tmp_instr)

Modified: pkg/FinancialInstrument/R/load.instruments.R
===================================================================
--- pkg/FinancialInstrument/R/load.instruments.R	2010-12-13 19:24:49 UTC (rev 493)
+++ pkg/FinancialInstrument/R/load.instruments.R	2010-12-13 19:40:26 UTC (rev 494)
@@ -68,7 +68,7 @@
     
     #now process the data
     for(rn in 1:nrow(filedata)){
-        if(!isTRUE(is.instrument(getInstrument(as.character(filedata[rn,id_col]))))){
+        if(!isTRUE(is.instrument(try(getInstrument(as.character(filedata[rn,id_col]),silent=TRUE),silent=TRUE)))){
             type=as.character(filedata[rn,'type'])
             arg<-as.list(filedata[rn,])
             if(type=='spread' || type=='guaranteed_spread'){



More information about the Blotter-commits mailing list