[Blotter-commits] r1144 - in pkg/quantstrat: data demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 29 02:29:07 CEST 2012


Author: opentrades
Date: 2012-08-29 02:29:07 +0200 (Wed, 29 Aug 2012)
New Revision: 1144

Added:
   pkg/quantstrat/data/luxor-p066.RData
   pkg/quantstrat/demo/luxor-3.12.R
   pkg/quantstrat/demo/luxor-3.16.R
Removed:
   pkg/quantstrat/data/luxor-3.09.RData
Modified:
   pkg/quantstrat/demo/luxor-3.11.R
Log:
added/modified luxor demo's for figures 3.11, 3.12 and 3.16 to use new blotter::chart.ME() for MAE and MFE charts



Deleted: pkg/quantstrat/data/luxor-3.09.RData
===================================================================
(Binary files differ)

Added: pkg/quantstrat/data/luxor-p066.RData
===================================================================
(Binary files differ)


Property changes on: pkg/quantstrat/data/luxor-p066.RData
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: pkg/quantstrat/demo/luxor-3.11.R
===================================================================
--- pkg/quantstrat/demo/luxor-3.11.R	2012-08-28 21:20:12 UTC (rev 1143)
+++ pkg/quantstrat/demo/luxor-3.11.R	2012-08-29 00:29:07 UTC (rev 1144)
@@ -2,66 +2,14 @@
 #
 # Jan Humme (@opentrades) - August 2012
 #
-# Tested and found to work correctly using blotter r1123
+# Tested and found to work correctly using blotter r1143
 #
-# From Jaekle & Tamasini: A new approach to system development and portfolio
-# optimisation (ISBN 978-1-905641-79-6)
+# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
 #
 # Figure 3.11: MAE graph of Luxor system
 
-options(width = 240)
-#Sys.setenv(TZ="GMT")
+require('blotter')
 
-require(xts)
+data('luxor-p066', package='quantstrat', envir=.blotter)
 
-###############################################################################
-
-data('luxor-3.09', package='quantstrat')
-
-posPL <- portfolio$symbols$GBPUSD$posPL
-
-###############################################################################
-
-trades <- list()
-
-trades$Start <- index(posPL[which(posPL$Pos.Value!=0 & lag(posPL$Pos.Value)==0),])
-trades$End <- index(posPL[which(posPL$Pos.Value==0 & lag(posPL$Pos.Value)!=0),])
-
-trades$Start <- trades$Start[1:length(trades$End)]  # discard open last trade, if any
-
-for(i in 1:length(trades$End))
-{
-	timespan <- paste(format(trades$Start[[i]], "%Y-%m-%d %H:%M:%OS6"),
-			  format(trades$End[[i]], "%Y-%m-%d %H:%M:%OS6"), sep="::")
-
-	trade <- posPL[timespan]
-
-	if(first(trade)$Pos.Qty==0) trade <- tail(trade, -1)
-	if(last(trade)$Pos.Qty!=0) trade <- head(trade, -1)
-
-	trades$Net.Trading.PL[i] <- sum(trade$Net.Trading.PL)
-	trades$Drawdown[i] <- min(0,cumsum(trade$Net.Trading.PL))
-}
-
-trades <- as.data.frame(trades)
-
-###############################################################################
-
-profitable <- (trades$Net.Trading.PL > 0)
-
-plot(abs(trades[, c('Drawdown','Net.Trading.PL')]), type='n',
-	xlab='Drawdown ($)', ylab='Profit (Loss) in $',
-	main='Figure 3.11: Maximum Adverse Excursion (MAE)')
-
-points(abs(trades[ profitable, c('Drawdown','Net.Trading.PL')]), pch=2, col='green')
-points(abs(trades[!profitable, c('Drawdown','Net.Trading.PL')]), pch=25, col='red')
-
-grid()
-
-legend(
-	x='right', inset=0.1,
-	legend=c('Profitable Trade','Losing Trade'),
-	pch=c(2,6),
-	col=c('green','red')
-)
-
+chart.ME('luxor', type='MAE', scale='cash')

Added: pkg/quantstrat/demo/luxor-3.12.R
===================================================================
--- pkg/quantstrat/demo/luxor-3.12.R	                        (rev 0)
+++ pkg/quantstrat/demo/luxor-3.12.R	2012-08-29 00:29:07 UTC (rev 1144)
@@ -0,0 +1,15 @@
+#!/usr/bin/Rscript --vanilla
+#
+# Jan Humme (@opentrades) - August 2012
+#
+# Tested and found to work correctly using blotter r1143
+#
+# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
+#
+# Figure 3.12: MAE graph in percentage terms
+
+require('blotter')
+
+data('luxor-p066', package='quantstrat', envir=.blotter)
+
+chart.ME('luxor', type='MAE', scale='percent')


Property changes on: pkg/quantstrat/demo/luxor-3.12.R
___________________________________________________________________
Added: svn:executable
   + *

Added: pkg/quantstrat/demo/luxor-3.16.R
===================================================================
--- pkg/quantstrat/demo/luxor-3.16.R	                        (rev 0)
+++ pkg/quantstrat/demo/luxor-3.16.R	2012-08-29 00:29:07 UTC (rev 1144)
@@ -0,0 +1,15 @@
+#!/usr/bin/Rscript --vanilla
+#
+# Jan Humme (@opentrades) - August 2012
+#
+# Tested and found to work correctly using blotter r1143
+#
+# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
+#
+# Figure 3.16: MFE graph in percentage terms
+
+require('blotter')
+
+data('luxor-p066', package='quantstrat', envir=.blotter)
+
+chart.ME('luxor', type='MFE', scale='percent')


Property changes on: pkg/quantstrat/demo/luxor-3.16.R
___________________________________________________________________
Added: svn:executable
   + *



More information about the Blotter-commits mailing list