[Blotter-commits] r1621 - pkg/quantstrat/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 11 15:32:09 CEST 2014


Author: bodanker
Date: 2014-07-11 15:32:09 +0200 (Fri, 11 Jul 2014)
New Revision: 1621

Modified:
   pkg/quantstrat/R/indicators.R
   pkg/quantstrat/R/rules.R
   pkg/quantstrat/R/signals.R
Log:
- Check mktdata for duplicate index values in applyIndicators/Signals/Rules
  call make.index.unique if necessary


Modified: pkg/quantstrat/R/indicators.R
===================================================================
--- pkg/quantstrat/R/indicators.R	2014-07-11 01:40:08 UTC (rev 1620)
+++ pkg/quantstrat/R/indicators.R	2014-07-11 13:32:09 UTC (rev 1621)
@@ -141,6 +141,12 @@
     
     # TODO check for symbol name in mktdata using Josh's code:
     # symbol <- strsplit(colnames(mktdata)[1],"\\.")[[1]][1]
+
+    # ensure no duplicate index values in mktdata
+    if(any(diff(.index(mktdata)) == 0)) {
+        warning("'mktdata' index contains duplicates; calling 'make.index.unique'")
+        mktdata <- make.index.unique(mktdata)
+    }
     
     if (!is.strategy(strategy)) {
         strategy<-try(getStrategy(strategy))

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2014-07-11 01:40:08 UTC (rev 1620)
+++ pkg/quantstrat/R/rules.R	2014-07-11 13:32:09 UTC (rev 1621)
@@ -261,6 +261,12 @@
     
     # TODO handle indicator and signal lists as well as indicators/signals that were cbound to mktdata
 
+    # ensure no duplicate index values in mktdata
+    if(any(diff(.index(mktdata)) == 0)) {
+        warning("'mktdata' index contains duplicates; calling 'make.index.unique'")
+        mktdata <- make.index.unique(mktdata)
+    }
+
     # ported from IBrokers thanks to Jeff
     # environment for data to be stored/accessed during applyRules execution
     # an example of this functionality is for the "symbols" variable

Modified: pkg/quantstrat/R/signals.R
===================================================================
--- pkg/quantstrat/R/signals.R	2014-07-11 01:40:08 UTC (rev 1620)
+++ pkg/quantstrat/R/signals.R	2014-07-11 13:32:09 UTC (rev 1621)
@@ -78,6 +78,12 @@
 
     # TODO handle indicator lists as well as indicators that were cbound to mktdata
 
+    # ensure no duplicate index values in mktdata
+    if(any(diff(.index(mktdata)) == 0)) {
+        warning("'mktdata' index contains duplicates; calling 'make.index.unique'")
+        mktdata <- make.index.unique(mktdata)
+    }
+
     if (!is.strategy(strategy)) {
         strategy<-try(getStrategy(strategy))
         if(inherits(strategy,"try-error"))



More information about the Blotter-commits mailing list