[Blotter-commits] r1429 - pkg/quantstrat/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 7 23:29:51 CEST 2013


Author: opentrades
Date: 2013-04-07 23:29:51 +0200 (Sun, 07 Apr 2013)
New Revision: 1429

Modified:
   pkg/quantstrat/demo/luxor.1.R
   pkg/quantstrat/demo/luxor.2.R
Log:
- some small improvements 



Modified: pkg/quantstrat/demo/luxor.1.R
===================================================================
--- pkg/quantstrat/demo/luxor.1.R	2013-04-06 22:34:04 UTC (rev 1428)
+++ pkg/quantstrat/demo/luxor.1.R	2013-04-07 21:29:51 UTC (rev 1429)
@@ -16,8 +16,8 @@
 .fast = 10
 .slow = 30
 
-.orderqty=100000
-.threshold=0.0005
+.orderqty = 100000
+.threshold = 0.0005
 
 ##### PLACE DEMO AND TEST DATES HERE #################
 #
@@ -44,7 +44,7 @@
 
 ### packages
 #
-# quantstrat package will pull in many other packages:
+# quantstrat package will pull in some other packages:
 # FinancialInstrument, quantmod, blotter, xts
 
 require(quantstrat)
@@ -146,9 +146,7 @@
 add.rule(strategy.st, 'ruleSignal',
 	arguments=list(sigcol='long' , sigval=TRUE,
 		orderside='long' ,
-		ordertype='stoplimit',
-		prefer='High',
-		threshold=.threshold,
+		ordertype='stoplimit', prefer='High', threshold=.threshold,
 		orderqty=+.orderqty,
 		replace=FALSE
 	),
@@ -159,9 +157,7 @@
 add.rule(strategy.st, 'ruleSignal',
 	arguments=list(sigcol='short', sigval=TRUE,
 		orderside='short',
-		ordertype='stoplimit',
-		prefer='Low',
-		threshold=-.threshold,
+		ordertype='stoplimit', prefer='Low', threshold=-.threshold,
 		orderqty=-.orderqty,
 		replace=FALSE
 	),
@@ -173,7 +169,7 @@
 
 applyStrategy(strategy.st, portfolio.st, verbose = FALSE)
 
-print(getOrderBook(portfolio.st))
+View(getOrderBook(portfolio.st)[[portfolio.st]]$GBPUSD)
 
 ###############################################################################
 
@@ -181,8 +177,10 @@
 
 chart.Posn(portfolio.st, "GBPUSD")
 
-tradeStats(portfolio.st, 'GBPUSD')
+###############################################################################
 
+View(tradeStats(portfolio.st, 'GBPUSD'))
+
 ##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
 # book  = getOrderBook(port)
 # stats = tradeStats(port)

Modified: pkg/quantstrat/demo/luxor.2.R
===================================================================
--- pkg/quantstrat/demo/luxor.2.R	2013-04-06 22:34:04 UTC (rev 1428)
+++ pkg/quantstrat/demo/luxor.2.R	2013-04-07 21:29:51 UTC (rev 1429)
@@ -16,9 +16,9 @@
 .fast = 10
 .slow = 30
 
-.orderqty=100000
-.threshold=0.0005
-.txn.fees=-30
+.orderqty = 100000
+.threshold = 0.0005
+.txn.fees = -30
 
 ##### PLACE DEMO AND TEST DATES HERE #################
 #
@@ -45,7 +45,7 @@
 
 ### packages
 #
-# quantstrat package will pull in many other packages:
+# quantstrat package will pull in some other packages:
 # FinancialInstrument, quantmod, blotter, xts
 
 require(quantstrat)
@@ -172,7 +172,7 @@
 
 applyStrategy(strategy.st, portfolio.st, verbose = FALSE)
 
-print(getOrderBook(portfolio.st))
+View(getOrderBook(portfolio.st)[[portfolio.st]]$GBPUSD)
 
 ###############################################################################
 
@@ -180,8 +180,16 @@
 
 chart.Posn(portfolio.st, "GBPUSD")
 
-tradeStats(portfolio.st, 'GBPUSD')
+###############################################################################
 
+View(tradeStats(portfolio.st, 'GBPUSD'))
+
+###############################################################################
+
+# save the strategy in an .RData object for later retrieval
+
+save.strategy(strategy.st)
+
 ##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
 # book  = getOrderBook(port)
 # stats = tradeStats(port)



More information about the Blotter-commits mailing list