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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 29 22:12:17 CET 2010


Author: braverock
Date: 2010-01-29 22:12:16 +0100 (Fri, 29 Jan 2010)
New Revision: 219

Modified:
   pkg/blotter/R/chart.Spread.R
Log:
- add cumulative P&L

Modified: pkg/blotter/R/chart.Spread.R
===================================================================
--- pkg/blotter/R/chart.Spread.R	2010-01-29 18:11:21 UTC (rev 218)
+++ pkg/blotter/R/chart.Spread.R	2010-01-29 21:12:16 UTC (rev 219)
@@ -76,10 +76,18 @@
 
     #FIXME right now we don't separate trading PL by *Spread*, just by *Portfolios*, so this isn't quite right in the general case
     #TODO change this to use a two-line shaded graphic as soon as Jeff provides the infrastructure
-    TradingPL = pacctdata$Trading.PL
-    if(length(TradingPL)>1) TradingPL = na.locf(merge(TradingPL,index(Prices)))
-    else TradingPL = NULL
-    if(!is.null(TradingPL))  plot(addTA(TradingPL, col='darkgreen', lwd=2))
+    UnrealizedPL = pacctdata$Unrealized.PL
+
+    if(length(UnrealizedPL)>1) UnrealizedPL = na.locf(merge(UnrealizedPL,index(Prices)))
+    else UnrealizedPL = NULL
+    if(!is.null(UnrealizedPL))  plot(addTA(UnrealizedPL, col='darkgreen', lwd=2))
+
+    RealizedPL = pacctdata$Realized.PL
+    CumPL=cumsum(RealizedPL+UnrealizedPL)
+    if(length(CumPL)>1) CumPL = na.locf(merge(CumPL,index(Prices)))
+    else CumPL = NULL
+    if(!is.null(CumPL))  plot(addTA(CumPL, col='green', lwd=2))
+    
 }
 
 ###############################################################################



More information about the Blotter-commits mailing list