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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 14 23:48:25 CET 2010


Author: braverock
Date: 2010-01-14 23:48:25 +0100 (Thu, 14 Jan 2010)
New Revision: 157

Modified:
   pkg/blotter/R/chart.Posn.R
Log:
- more fixes to alignment


Modified: pkg/blotter/R/chart.Posn.R
===================================================================
--- pkg/blotter/R/chart.Posn.R	2010-01-14 21:44:25 UTC (rev 156)
+++ pkg/blotter/R/chart.Posn.R	2010-01-14 22:48:25 UTC (rev 157)
@@ -34,9 +34,12 @@
     )
     n=round(freq$frequency/mult,0)*mult
     Prices=align.time(Prices,n)
+    tzero = xts(0,order.by=index(Prices[1,]))
     Trades = Portfolio[[Symbol]]$txn$Txn.Price*Portfolio[[Symbol]]$txn$Txn.Qty
-    Buys = align.time(Portfolio[[Symbol]]$txn$Txn.Price[which(Trades>0)],n)
-    Sells = align.time(Portfolio[[Symbol]]$txn$Txn.Price[which(Trades<0)],n)
+    Buys = Portfolio[[Symbol]]$txn$Txn.Price[which(Trades>0)]
+    Buys = align.time(rbind(Buys,tzero),n)
+    Sells = Portfolio[[Symbol]]$txn$Txn.Price[which(Trades<0)]
+    Sells = align.time(rbind(Sells,tzero),n)
     #Position = Portfolio[[Symbol]]$posPL$Pos.Qty # use $txn instead, and make it match the prices index
     Position = Portfolio[[Symbol]]$txn$Pos.Qty
     Position = na.locf(merge(Position,index(Prices)))



More information about the Blotter-commits mailing list