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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 31 22:33:25 CEST 2010


Author: braverock
Date: 2010-03-31 22:33:25 +0200 (Wed, 31 Mar 2010)
New Revision: 319

Modified:
   pkg/blotter/R/chart.Posn.R
Log:
- add symbol name to chart.POSN
- plot both current (na.locf) Position and changes in Position

Modified: pkg/blotter/R/chart.Posn.R
===================================================================
--- pkg/blotter/R/chart.Posn.R	2010-03-31 15:06:49 UTC (rev 318)
+++ pkg/blotter/R/chart.Posn.R	2010-03-31 20:33:25 UTC (rev 319)
@@ -43,7 +43,7 @@
 #    Sells = align.time(rbind(Sells,tzero),n)[-1]
     #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)))
+    Positionfill = na.locf(merge(Position,index(Prices)))
     CumPL = cumsum(Portfolio[[Symbol]]$posPL$Net.Trading.PL)
     if(length(CumPL)>1)
         CumPL = na.locf(merge(CumPL,index(Prices)))
@@ -60,10 +60,13 @@
     # scope the date, this is heavy-handed, but should work
     if(!is.null(Dates)) Prices=Prices[Dates]
     
-    chart_Series(Prices, TA=NULL,...)
+    chart_Series(Prices, name=Symbol, TA=NULL,...)
     if(nrow(Buys)>=1) (add_TA(Buys,pch=2,type='p',col='green', on=1));
     if(nrow(Sells)>=1) (add_TA(Sells,pch=6,type='p',col='red', on=1));
-    if(nrow(Position)>=1) (add_TA(Position,type='b',col='blue', lwd=2));
+    if(nrow(Position)>=1) {
+        (add_TA(Positionfill,type='l',col='blue', lwd=2))   
+        (add_TA(Position,type='p',col='blue', lwd=2, on=2))   
+    }
     if(!is.null(CumPL))  (add_TA(CumPL, col='darkgreen', lwd=2))
     plot(current.chob())
 }



More information about the Blotter-commits mailing list