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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 28 19:41:35 CEST 2011


Author: gsee
Date: 2011-09-28 19:41:35 +0200 (Wed, 28 Sep 2011)
New Revision: 804

Modified:
   pkg/FinancialInstrument/R/instrument.R
Log:
 if you tinker with $IB of an instrument using instrument_attr, it will add or remove the twsInstrument class

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2011-09-27 20:41:44 UTC (rev 803)
+++ pkg/FinancialInstrument/R/instrument.R	2011-09-28 17:41:35 UTC (rev 804)
@@ -897,6 +897,14 @@
         tclass <- unique(c(value, "instrument"))
         class(instr) <- tclass
     }
+    if (attr == 'IB') {
+        if (inherits(value, 'twsContract')) {
+            class(instr) <- unique(c(class(instr)[1], 'twsInstrument', class(instr)[-1]))
+        } else {
+            warning('non-twsContract assigned to $IB')
+            class(instr) <- class(instr)[!class(instr) %in% 'twsInstrument']
+        }
+    }
     if (attr == 'src') {
         sarg <- list()
         sarg[[instr$primary_id]] <- value



More information about the Blotter-commits mailing list