[Blotter-commits] r171 - pkg/blotter/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 16 10:52:30 CET 2010


Author: braverock
Date: 2010-01-16 10:52:30 +0100 (Sat, 16 Jan 2010)
New Revision: 171

Modified:
   pkg/blotter/R/addTxn.R
   pkg/blotter/R/updatePosPL.R
Log:
- make warning check on ConMult more robust

Modified: pkg/blotter/R/addTxn.R
===================================================================
--- pkg/blotter/R/addTxn.R	2010-01-16 09:46:12 UTC (rev 170)
+++ pkg/blotter/R/addTxn.R	2010-01-16 09:52:30 UTC (rev 171)
@@ -18,9 +18,9 @@
     pname<-Portfolio
     Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
     
-    if(is.null(ConMult)){
+    if(is.null(ConMult) | !hasArg(ConMult)){
         tmp_instr<-try(getInstrument(Symbol))
-        if(inherits(tmp_instr,"try-error")){
+        if(inherits(tmp_instr,"try-error") | !is.instrument(tmp_instr)){
             warning(paste("Instrument",Symbol," not found, using contract multiplier of 1"))
             ConMult<-1
         } else {
@@ -72,10 +72,10 @@
     pname<-Portfolio
     Portfolio<-get(paste("portfolio",pname,sep='.'),envir=.blotter)
 
-    if(is.null(ConMult)){
+    if(is.null(ConMult) | !hasArg(ConMult)){
         tmp_instr<-try(getInstrument(Symbol))
-        if(inherits(tmp_instr,"try-error")){
-            warning(paste("Instrument",Symbiol," not found, using contract multiplier of 1"))
+        if(inherits(tmp_instr,"try-error") | !is.instrument(tmp_instr)){
+            warning(paste("Instrument",Symbol," not found, using contract multiplier of 1"))
             ConMult<-1
         } else {
             ConMult<-tmp_instr$multiplier

Modified: pkg/blotter/R/updatePosPL.R
===================================================================
--- pkg/blotter/R/updatePosPL.R	2010-01-16 09:46:12 UTC (rev 170)
+++ pkg/blotter/R/updatePosPL.R	2010-01-16 09:52:30 UTC (rev 171)
@@ -53,14 +53,14 @@
         if(length(PrevDate)==0)
              PrevDate = NA
 
-        if(is.null(ConMult)){
+        if(is.null(ConMult) | !hasArg(ConMult)){
             tmp_instr<-try(getInstrument(Symbol))
-            if(inherits(tmp_instr,"try-error")){
+            if(inherits(tmp_instr,"try-error") | !is.instrument(tmp_instr)){
                 warning(paste("Instrument",Symbol," not found, using contract multiplier of 1"))
                 ConMult<-1
             } else {
                 ConMult<-tmp_instr$multiplier
-            }
+            }  
         }
         PrevConMult = 1 ## @TODO: Change this to look up the value from instrument?
         CcyMult =1 ## @TODO: Change this to look up the value from instrument?



More information about the Blotter-commits mailing list