[Blotter-commits] r1266 - in pkg/quantstrat: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 26 20:29:02 CET 2012


Author: braverock
Date: 2012-11-26 20:29:01 +0100 (Mon, 26 Nov 2012)
New Revision: 1266

Modified:
   pkg/quantstrat/DESCRIPTION
   pkg/quantstrat/R/applyStrategy.rebalancing.R
Log:
- fix symbol loop in applyStrategy.rebalancing for rebalancing step
- bump version, remove Collate, turn ByteCompile back on

Modified: pkg/quantstrat/DESCRIPTION
===================================================================
--- pkg/quantstrat/DESCRIPTION	2012-11-24 21:34:43 UTC (rev 1265)
+++ pkg/quantstrat/DESCRIPTION	2012-11-26 19:29:01 UTC (rev 1266)
@@ -1,7 +1,7 @@
 Package: quantstrat
 Type: Package
 Title: Quantitative Strategy Model Framework
-Version: 0.7.5
+Version: 0.7.6
 Date: $Date$
 Author: Peter Carl, Brian G. Peterson, Joshua Ulrich, Jan Humme
 Depends:
@@ -15,23 +15,4 @@
 Contributors: Yu Chen, Joe Dunn, Dirk Eddelbuettel, Jeffrey A. Ryan, Garrett See
 LazyLoad: yes
 License: GPL-3
-ByteCompile: FALSE
-Collate:
-    'applyStrategy.rebalancing.R'
-    'indicators.R'
-    'initialize.R'
-    'match.names.R'
-    'orders.R'
-    'osFUNs.R'
-    'parameters.R'
-    'paramsets.R'
-    'rebalance.rules.R'
-    'ruleOrderProc.R'
-    'ruleRevoke.R'
-    'rules.R'
-    'ruleSignal.R'
-    'signals.R'
-    'strategy.R'
-    'tradeGraphs.R'
-    'utils.R'
-    'wrapup.R'
+ByteCompile: TRUE

Modified: pkg/quantstrat/R/applyStrategy.rebalancing.R
===================================================================
--- pkg/quantstrat/R/applyStrategy.rebalancing.R	2012-11-24 21:34:43 UTC (rev 1265)
+++ pkg/quantstrat/R/applyStrategy.rebalancing.R	2012-11-26 19:29:01 UTC (rev 1266)
@@ -125,46 +125,49 @@
         st$plist<-plist
         
         # combine plist into one sorted index
-        pindex <- sort(do.call(c, c(plist, use.names=FALSE)))
+        pindex <- unique(sort(do.call(c, c(plist, use.names=FALSE))))
         st$rebalance_index<-pindex
         
         #now we need to do the endpoints loop. 
         for(i in 2:length(pindex)){
             #the proper endpoints for each symbol will vary, so we need to get them separately, and subset each one
             for (symbol in symbols){
-                sret<-ret[[portfolio]][[symbol]]
-
+                #sret<-ret[[portfolio]][[symbol]]
                 mktdata<-get(symbol,pos=st)
                 #now subset
                 md_subset<-mktdata[as.POSIXct(index(mktdata))>pindex[i-1]&as.POSIXct(index(mktdata))<=pindex[i]]
-                if(nrow(md_subset)<1) next()
-                #applyRules to this subset for this instrument  
-                #sret$rules$pathdep<-rbind(sret$rules$pathdep,
-                                      applyRules(portfolio=portfolio, symbol=symbol, strategy=s, mktdata=md_subset, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=TRUE)
-                #)
+                if(nrow(md_subset)<1) {
+                    print('next')
+                    next()
+                } else{
+                    #applyRules to this subset for this instrument  
+                    #sret$rules$pathdep<-rbind(sret$rules$pathdep,
+                    applyRules(portfolio=portfolio, symbol=symbol, strategy=s, mktdata=md_subset, Dates=NULL, indicators=sret$indicators, signals=sret$signals, parameters=parameters,  ..., path.dep=TRUE)
+                    #)
+                }
                 
-                ret[[portfolio]][[symbol]]<-sret
+                #ret[[portfolio]][[symbol]]<-sret
+                
+                #now call the rebalancing rules
+                #to nest different rebalancing periods, we need to check if the pindex 'i' is in specific rebalance_on periods
+                # specifically, we need to check if *this* index is in st$plist$period
+                for(period in names(st$plist)){
+                    if(pindex[i] %in% st$plist[[period]]){
+                        #this index is a rebalancing index for period
+                        #call the rebalance rules for this period
+                        #still need to separate the rules by rebalancing period, this will call them all
+                        ruleProc(s$rules$rebalance,
+                                timestamp=pindex[i], 
+                                path.dep=TRUE, 
+                                ruletype='rebalance', 
+                                ..., 
+                                mktdata=md_subset, 
+                                parameters=parameters,
+                                portfolio=portfolio,
+                                symbol=symbol)
+                    }
+                }
             } #end loop over symbols for this sub-period
-            
-            #now call the rebalancing rules
-            #to nest different rebalancing periods, we need to check if the pindex 'i' is in specific rebalance_on periods
-            # specifically, we need to check if *this* index is in st$plist$period
-            for(period in names(st$plist)){
-                if(pindex[i] %in% st$plist[[period]]){
-                    #this index is a rebalancing index for period
-                    #call the rebalance rules for this period
-                    #still need to separate the rules by rebalancing period, this will call them all
-                    ruleProc(s$rules$rebalance,
-                             timestamp=pindex[i], 
-                             path.dep=TRUE, 
-                             ruletype='rebalance', 
-                             ..., 
-                             mktdata=md_subset, 
-                             parameters=parameters,
-                             portfolio=portfolio,
-                             symbol=symbol)
-                }
-            }
         }
         
         # updateStrat



More information about the Blotter-commits mailing list