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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 21 14:55:27 CEST 2012


Author: opentrades
Date: 2012-06-21 14:55:27 +0200 (Thu, 21 Jun 2012)
New Revision: 1061

Modified:
   pkg/quantstrat/demo/luxor.p3_2.R
   pkg/quantstrat/demo/rocema.R
Log:
* changed rocema.R to use --vanilla and define instruments, now with ES future, and options(width = 240)
* changed luxor.p3_2.R to use --vanilla and define instruments, now with ES future, and options(width = 240)



Modified: pkg/quantstrat/demo/luxor.p3_2.R
===================================================================
--- pkg/quantstrat/demo/luxor.p3_2.R	2012-06-21 12:27:03 UTC (rev 1060)
+++ pkg/quantstrat/demo/luxor.p3_2.R	2012-06-21 12:55:27 UTC (rev 1061)
@@ -16,6 +16,8 @@
 .to='2008-07-04'
 #.to='2002-10-23'
 
+options(width = 240)
+
 ####
 
 p = 'forex'
@@ -26,9 +28,7 @@
 require(quantstrat)
 
 currency(c('GBP', 'USD'))
-
 exchange_rate(c('GBPUSD'), tick_size=0.0001)
-
 setSymbolLookup.FI('~/R.symbols/', 'GBPUSD')
 
 ###

Modified: pkg/quantstrat/demo/rocema.R
===================================================================
--- pkg/quantstrat/demo/rocema.R	2012-06-21 12:27:03 UTC (rev 1060)
+++ pkg/quantstrat/demo/rocema.R	2012-06-21 12:55:27 UTC (rev 1061)
@@ -1,4 +1,4 @@
-#!/usr/bin/Rscript --no-save
+#!/usr/bin/Rscript --vanilla
 #
 # Rocema strategy, demonstrating among others:
 # * using ternaryindicator that returns -1 (short), 0 (cash) or 1 (long)
@@ -10,9 +10,9 @@
 #
 # JH, June 2012
 
-.ema = 19
-.roc = 45
-.trend = 118
+.ema = 15
+.roc = 50
+.trend = 100
 
 .tplong = 3.0
 .tpshort = -3.0
@@ -35,6 +35,8 @@
 p = 'rocema'
 a = 'IB'
 
+options(width = 240)
+
 ###############################################################################
 
 RocSys = function(x, nEMA, nROC, nTREND)
@@ -57,14 +59,20 @@
 
 require(quantstrat)
 
-getSymbols('GBPUSD')
-GBPUSD <- align.time(to.period(GBPUSD, 'minutes', 15), 900)
-GBPUSD <- GBPUSD[.subset]
+currency('USD')
 
+future('ES', "USD", multiplier=1000, tick_size=.25, exchange="Comex", description="SP500 Future")
+
+setSymbolLookup.FI('~/R.symbols/', 'ES')
+
+getSymbols('ES')
+ES <- align.time(to.period(ES, 'minutes', 15), 900)
+ES <- ES[.subset]
+
 ###############################################################################
 
-initPortf(p, symbols='GBPUSD', initDate=initDate, currency="EUR")
-initAcct(a, portfolios=p, initDate=initDate, currency="EUR")
+initPortf(p, symbols='ES', initDate=initDate, currency="USD")
+initAcct(a, portfolios=p, initDate=initDate, currency="USD")
 
 initOrders(p, initDate=initDate)
 
@@ -207,11 +215,11 @@
 
 applyStrategy(s, p, parameters=list(nEMA=.ema,nROC=.roc,nTREND=.trend), verbose = FALSE, prefer='Open')
 
-chart.Posn(p, "GBPUSD")
+chart.Posn(p, "ES")
 
 print(getOrderBook(p))
 
-txns <- getTxns(p, 'GBPUSD')
+txns <- getTxns(p, 'ES')
 txns
 
 cat('Net profit:', sum(txns$Net.Txn.Realized.PL), '\n')



More information about the Blotter-commits mailing list