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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 12 15:53:23 CET 2010


Author: braverock
Date: 2010-01-12 15:53:23 +0100 (Tue, 12 Jan 2010)
New Revision: 138

Modified:
   pkg/blotter/R/addTxn.R
Log:
- fix needed as.numeric so that c.xts isn't called when c() will do

Modified: pkg/blotter/R/addTxn.R
===================================================================
--- pkg/blotter/R/addTxn.R	2010-01-12 14:19:20 UTC (rev 137)
+++ pkg/blotter/R/addTxn.R	2010-01-12 14:53:23 UTC (rev 138)
@@ -63,8 +63,8 @@
     #NewTxns=xts()
     for (row in 1:nrow(TxnData)) {
         #TODO create vectorized versions of all these functions so we don't have to loop
-        TxnQty         <- TxnData[row,'Quantity']
-        TxnPrice       <- TxnData[row,'Price']
+        TxnQty         <- as.numeric(TxnData[row,'Quantity'])
+        TxnPrice       <- as.numeric(TxnData[row,'Price'])
         TxnFee         <- 0 #TODO FIXME support transaction fees in addTxns
         TxnValue       <- calcTxnValue(TxnQty, TxnPrice, TxnFee)
         TxnAvgCost     <- calcTxnAvgCost(TxnValue, TxnQty)
@@ -83,6 +83,7 @@
                          PosAvgCost, 
                          RealizedPL)),
                          order.by=index(TxnData[row,]))
+
         if(row==1){
             NewTxns <- NewTxn
             colnames(NewTxns) = c('Txn.Qty', 'Txn.Price', 'Txn.Fees', 'Txn.Value', 'Txn.Avg.Cost', 'Pos.Qty', 'Pos.Avg.Cost', 'Realized.PL')



More information about the Blotter-commits mailing list