[Blotter-commits] r572 - pkg/blotter/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 12 19:51:46 CET 2011


Author: braverock
Date: 2011-03-12 19:51:45 +0100 (Sat, 12 Mar 2011)
New Revision: 572

Modified:
   pkg/blotter/R/addTxn.R
Log:
- only call as.POSIXct on TxnDate if it is not already timeBased

Modified: pkg/blotter/R/addTxn.R
===================================================================
--- pkg/blotter/R/addTxn.R	2011-03-12 18:27:32 UTC (rev 571)
+++ pkg/blotter/R/addTxn.R	2011-03-12 18:51:45 UTC (rev 572)
@@ -81,9 +81,11 @@
 		GrossTxnRealizedPL = 0
 	
 	NetTxnRealizedPL = GrossTxnRealizedPL + txnfees
-
+    if(!is.timeBased(TxnDate)){
+        TxnDate<-as.POSIXct(TxnDate)
+    }
     # Store the transaction and calculations
-    NewTxn = xts(t(c(TxnQty, TxnPrice, TxnValue, TxnAvgCost, PosQty, PosAvgCost, GrossTxnRealizedPL, txnfees, NetTxnRealizedPL, ConMult)), order.by=as.POSIXct(TxnDate))
+    NewTxn = xts(t(c(TxnQty, TxnPrice, TxnValue, TxnAvgCost, PosQty, PosAvgCost, GrossTxnRealizedPL, txnfees, NetTxnRealizedPL, ConMult)), order.by=TxnDate)
     #colnames(NewTxns) = c('Txn.Qty', 'Txn.Price', 'Txn.Value', 'Txn.Avg.Cost', 'Pos.Qty', 'Pos.Avg.Cost', 'Gross.Txn.Realized.PL', 'Txn.Fees', 'Net.Txn.Realized.PL', 'Con.Mult')
     Portfolio$symbols[[Symbol]]$txn<-rbind(Portfolio$symbols[[Symbol]]$txn, NewTxn)
 



More information about the Blotter-commits mailing list