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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 26 18:35:47 CET 2010


Author: braverock
Date: 2010-02-26 18:35:46 +0100 (Fri, 26 Feb 2010)
New Revision: 273

Modified:
   pkg/quantstrat/R/orders.R
Log:
- store a human-readable status update timestamp

Modified: pkg/quantstrat/R/orders.R
===================================================================
--- pkg/quantstrat/R/orders.R	2010-02-26 17:35:22 UTC (rev 272)
+++ pkg/quantstrat/R/orders.R	2010-02-26 17:35:46 UTC (rev 273)
@@ -265,20 +265,6 @@
             yearly = ,
             quarterly = ,
             monthly = ,
-            ## {
-            ##     # first process low frequencies with look-back assumption
-            ##     for (ii in 1:nrow(procorders) ){
-            ##         if(procorders[ii,]$Order.Type=='market'){
-            ##             txnprice=as.numeric(getPrice(mktdata[timestamp], prefer='close'))
-            ##             # if(!is.null(ncol(txnprice)) & ncol(txnprice)>1) txnprice = as.numeric(getPrice(mktdata[timestamp], symbol=symbol, prefer='close'))
-            ##             addTxn(Portfolio=portfolio, Symbol=symbol, TxnDate=prevtime, TxnQty=as.numeric(procorders[ii,]$Order.Qty), TxnPrice=txnprice ,...=...)
-            ##             procorders[ii,]$Order.Status<-'closed'
-            ##             procorders[ii,]$Order.StatusTime<-timestamp
-            ##         } else {
-            ##             stop("order types other than market not (yet?) supported for low-frequency strategies")
-            ##         }
-            ##     }
-            ## }, # end low frequency processing
             daily = { 
                 # next process daily
                 for (ii in 1:nrow(procorders) ){
@@ -287,7 +273,7 @@
                         market = ,
                         limit = {
                             if (procorders[ii,]$Order.Type == 'market' ){
-                                txnprice=as.numeric(getPrice(mktdata[prevtime], prefer='close'))
+                                txnprice=as.numeric(getPrice(mktdata[timestamp], prefer='close'))
                                 #if(!is.null(ncol(txnprice)) & ncol(txnprice)>1) txnprice = as.numeric(getPrice(mktdata[timestamp], symbol=symbol, prefer='close'))
                                 txntime=prevtime
                             } else {
@@ -308,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<-timestamp
+                        procorders[ii,]$Order.StatusTime<-as.character(timestamp)
                     }
                 } #end loop over open orders       
             }, #end daily and lower frequency processing
@@ -393,7 +379,7 @@
                                                  status="open", 
                                                  replace=TRUE)
                                         procorders[ii,]$Order.Status<-'replaced'
-                                        procorders[ii,]$Order.StatusTime<-timestamp 
+                                        procorders[ii,]$Order.StatusTime<-as.character(timestamp)
                                         next()
                                     }
                                 }



More information about the Blotter-commits mailing list