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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 17 16:22:31 CET 2010


Author: braverock
Date: 2010-03-17 16:22:31 +0100 (Wed, 17 Mar 2010)
New Revision: 294

Modified:
   pkg/quantstrat/R/orders.R
   pkg/quantstrat/R/rules.R
Log:
- update time stamp calculation for low-frequency strategies

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2010-03-17 12:56:25 UTC (rev 293)
+++ pkg/quantstrat/R/orders.R	2010-03-17 15:22:31 UTC (rev 294)
@@ -269,18 +269,18 @@
                 # next process daily
                 for (ii in 1:nrow(procorders) ){
                     txnprice=NULL
+                    txntime=as.character(index(procorders[ii,]))
                     switch(procorders[ii,]$Order.Type,
                         market = ,
                         limit = {
                             if (procorders[ii,]$Order.Type == 'market' ){
-                                txnprice=as.numeric(getPrice(mktdata[as.character(timestamp)], prefer='close'))
+                                txnprice=as.numeric(getPrice(mktdata[txntime], prefer='close'))
                                 #if(!is.null(ncol(txnprice)) & ncol(txnprice)>1) txnprice = as.numeric(getPrice(mktdata[timestamp], symbol=symbol, prefer='close'))
-                                txntime=prevtime
                             } else {
                                 # check to see if price moved through the limit
                                 if(procorders[ii,]$Order.Price>Lo(mktdata[as.character(timestamp)]) & procorders[ii,]$Order.Price<Hi(mktdata[as.character(timestamp)]) ) {
                                     txnprice=as.numeric(procorders[ii,]$Order.Price)
-                                    txntime=timestamp
+                                    txntime=as.character(timestamp)
                                 } else {
                                     # price did not move through my order
                                     next() # should go to next order
@@ -294,7 +294,7 @@
                     if(!is.null(txnprice)){
                         addTxn(Portfolio=portfolio, Symbol=symbol, TxnDate=txntime, TxnQty=as.numeric(procorders[ii,]$Order.Qty), TxnPrice=txnprice ,...=...)
                         procorders[ii,]$Order.Status<-'closed'
-                        procorders[ii,]$Order.StatusTime<-as.character(timestamp)
+                        procorders[ii,]$Order.StatusTime<-txntime
                     }
                 } #end loop over open orders       
             }, #end daily and lower frequency processing

Modified: pkg/quantstrat/R/rules.R
===================================================================
--- pkg/quantstrat/R/rules.R	2010-03-17 12:56:25 UTC (rev 293)
+++ pkg/quantstrat/R/rules.R	2010-03-17 15:22:31 UTC (rev 294)
@@ -135,8 +135,7 @@
             onames <- names(.formals)
             rule$arguments$timestamp=timestamp
             pm <- pmatch(names(rule$arguments), onames, nomatch = 0L)
-            if (any(pm == 0L))
-                message(paste("some arguments stored for",rule$name,"do not match"))
+            # if (any(pm == 0L)) message(paste("some arguments stored for",rule$name,"do not match"))
             names(rule$arguments[pm > 0L]) <- onames[pm]
             .formals[pm] <- rule$arguments[pm > 0L]
             #now add dots



More information about the Blotter-commits mailing list