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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 28 15:04:03 CEST 2011


Author: braverock
Date: 2011-03-28 15:04:02 +0200 (Mon, 28 Mar 2011)
New Revision: 586

Modified:
   pkg/blotter/R/chart.Posn.R
Log:
- scope the chart by Dates, take the scope from the historical price data if necessary
- use Txn.Qty as the indicator for buys/sells, necessary for products w/ negative price

Modified: pkg/blotter/R/chart.Posn.R
===================================================================
--- pkg/blotter/R/chart.Posn.R	2011-03-17 18:53:22 UTC (rev 585)
+++ pkg/blotter/R/chart.Posn.R	2011-03-28 13:04:02 UTC (rev 586)
@@ -33,9 +33,13 @@
     
     tzero = xts(0,order.by=index(Prices[1,]))
 #    Prices=align.time(Prices,n) 
+    if(is.null(Dates)) Dates<-paste(first(index(Prices)),last(index(Prices)),sep='::')
     
-	#Trades = Portfolio$symbols[[Symbol]]$txn$Txn.Price*Portfolio$symbols[[Symbol]]$txn$Txn.Qty
-	Trades = Portfolio$symbols[[Symbol]]$txn$Txn.Value
+    #scope the data by Dates
+    Portfolio$symbols[[Symbol]]$txn<-Portfolio$symbols[[Symbol]]$txn[Dates]
+    Portfolio$symbols[[Symbol]]$posPL<-Portfolio$symbols[[Symbol]]$posPL[Dates]
+    
+	Trades = Portfolio$symbols[[Symbol]]$txn$Txn.Qty
 	
 	Buys = Portfolio$symbols[[Symbol]]$txn$Txn.Price[which(Trades>0)]
 #    Buys = align.time(rbind(Buys,tzero),n)[-1]
@@ -57,7 +61,7 @@
     # addTA(BuyCover,pch=24,type="p",col="green", bg="orange", on=1)
     # addTA(SellCover,pch=25,type="p",col="red", bg="orange", on=1)
 
-    # scope the date, this is heavy-handed, but should work
+    # scope the Price data by Dates
     if(!is.null(Dates)) Prices=Prices[Dates]
     
     chart_Series(Prices, name=Symbol, TA=NULL)



More information about the Blotter-commits mailing list