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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 17 13:01:33 CEST 2013


Author: opentrades
Date: 2013-04-17 13:01:33 +0200 (Wed, 17 Apr 2013)
New Revision: 1436

Added:
   pkg/quantstrat/demo/luxor.strategy.R
Removed:
   pkg/quantstrat/demo/luxor.1.R
   pkg/quantstrat/demo/luxor.2.R
   pkg/quantstrat/demo/luxor.strategy.R
Modified:
   pkg/quantstrat/demo/luxor.3.Parameters.tradegraphs.R
Log:
- removed luxor.1.R, as the only diff with luxor.2.R is txnfees
- renamed luxor.2.R to luxor.strategy.R: the basic strategy
- adjusted luxor.3.Parameters.tradegraphs.R for new fixed.parameters



Deleted: pkg/quantstrat/demo/luxor.1.R
===================================================================
--- pkg/quantstrat/demo/luxor.1.R	2013-04-16 15:23:34 UTC (rev 1435)
+++ pkg/quantstrat/demo/luxor.1.R	2013-04-17 11:01:33 UTC (rev 1436)
@@ -1,188 +0,0 @@
-#!/usr/bin/Rscript --vanilla
-#
-# Jan Humme (@opentrades) - August 2012, revised April 2013
-#
-# Tested and found to work correctly using blotter r1420
-#
-# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
-#
-# Paragraph 3.2: luxor without any optimizations
-
-options(width = 240)
-Sys.setenv(TZ="UTC")
-
-###
-
-.fast = 10
-.slow = 30
-
-.orderqty = 100000
-.threshold = 0.0005
-
-##### PLACE DEMO AND TEST DATES HERE #################
-#
-#if(isTRUE(options('in_test')$in_test))
-#  # use test dates
-#  {initDate="2011-01-01" 
-#  endDate="2012-12-31"   
-#  } else
-#  # use demo defaults
-#  {initDate="1999-12-31"
-#  endDate=Sys.Date()}
-
-initDate = '2002-10-21'
-
-.from='2002-10-21'
-#.to='2008-07-04'
-.to='2002-10-31'
-
-####
-
-strategy.st = 'luxor'
-portfolio.st = 'forex'
-account.st = 'IB1'
-
-### packages
-#
-# quantstrat package will pull in some other packages:
-# FinancialInstrument, quantmod, blotter, xts
-
-require(quantstrat)
-
-### FinancialInstrument
-
-currency(c('GBP', 'USD'))
-
-exchange_rate('GBPUSD', tick_size=0.0001)
-
-### quantmod
-
-getSymbols.FI(Symbols='GBPUSD',
-	      dir=system.file('extdata',package='quantstrat'),
-	      from=.from, to=.to
-)
-
-# ALTERNATIVE WAY TO FETCH SYMBOL DATA
-#setSymbolLookup.FI(system.file('extdata',package='quantstrat'), 'GBPUSD')
-#getSymbols('GBPUSD', from=.from, to=.to, verbose=FALSE)
-
-### xts
-
-GBPUSD = to.minutes30(GBPUSD)
-GBPUSD = align.time(to.minutes30(GBPUSD), 1800)
-
-### blotter
-
-initPortf(portfolio.st, symbols='GBPUSD', initDate=initDate, currency='USD')
-initAcct(account.st, portfolios=portfolio.st, initDate=initDate, currency='USD')
-
-### quantstrat
-
-initOrders(portfolio.st, initDate=initDate)
-
-### define strategy
-
-strategy(strategy.st, store=TRUE)
-
-### indicators
-
-add.indicator(strategy.st, name = "SMA",
-	arguments = list(
-		x = quote(Cl(mktdata)[,1]),
-		n = .fast
-	),
-	label="nFast"
-)
-
-add.indicator(strategy.st, name="SMA",
-	arguments = list(
-		x = quote(Cl(mktdata)[,1]),
-		n = .slow
-	),
-	label="nSlow"
-)
-
-### signals
-
-add.signal(strategy.st, 'sigCrossover',
-	arguments = list(
-		columns=c("nFast","nSlow"),
-		relationship="gte"
-	),
-	label='long'
-)
-
-add.signal(strategy.st, 'sigCrossover',
-	arguments = list(
-		columns=c("nFast","nSlow"),
-		relationship="lt"
-	),
-	label='short'
-)
-
-### rules
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		orderside='short',
-		ordertype='market',
-		orderqty='all',
-		replace=TRUE
-	),
-	type='exit',
-	label='Exit2LONG'
-)
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='short', sigval=TRUE,
-		orderside='long' ,
-		ordertype='market',
-		orderqty='all',
-		replace=TRUE
-	),
-	type='exit',
-	label='Exit2SHORT')
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		orderside='long' ,
-		ordertype='stoplimit', prefer='High', threshold=.threshold,
-		orderqty=+.orderqty,
-		replace=FALSE
-	),
-	type='enter',
-	label='EnterLONG'
-)
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='short', sigval=TRUE,
-		orderside='short',
-		ordertype='stoplimit', prefer='Low', threshold=-.threshold,
-		orderqty=-.orderqty,
-		replace=FALSE
-	),
-	type='enter',
-	label='EnterSHORT'
-)
-
-###############################################################################
-
-applyStrategy(strategy.st, portfolio.st, verbose = FALSE)
-
-View(getOrderBook(portfolio.st)[[portfolio.st]]$GBPUSD)
-
-###############################################################################
-
-updatePortf(portfolio.st, Symbols='GBPUSD', Dates=paste('::',as.Date(Sys.time()),sep=''))
-
-chart.Posn(portfolio.st, "GBPUSD")
-
-###############################################################################
-
-View(tradeStats(portfolio.st, 'GBPUSD'))
-
-##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
-# book  = getOrderBook(port)
-# stats = tradeStats(port)
-# rets  = PortfReturns(acct)
-################################################################

Deleted: pkg/quantstrat/demo/luxor.2.R
===================================================================
--- pkg/quantstrat/demo/luxor.2.R	2013-04-16 15:23:34 UTC (rev 1435)
+++ pkg/quantstrat/demo/luxor.2.R	2013-04-17 11:01:33 UTC (rev 1436)
@@ -1,197 +0,0 @@
-#!/usr/bin/Rscript --vanilla
-#
-# Jan Humme (@opentrades) - August 2012, revised April 2013
-#
-# Tested and found to work correctly using blotter r1420
-#
-# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
-#
-# Paragraph 3.2: luxor with $30 slippage and transaction costs
-
-options(width = 240)
-Sys.setenv(TZ="UTC")
-
-###
-
-.fast = 10
-.slow = 30
-
-.orderqty = 100000
-.threshold = 0.0005
-.txn.fees = -30
-
-##### PLACE DEMO AND TEST DATES HERE #################
-#
-#if(isTRUE(options('in_test')$in_test))
-#  # use test dates
-#  {initDate="2011-01-01" 
-#  endDate="2012-12-31"   
-#  } else
-#  # use demo defaults
-#  {initDate="1999-12-31"
-#  endDate=Sys.Date()}
-
-initDate = '2002-10-21'
-
-.from='2002-10-21'
-#.to='2008-07-04'
-.to='2002-10-31'
-
-####
-
-strategy.st = 'luxor'
-portfolio.st = 'forex'
-account.st = 'IB1'
-
-### packages
-#
-# quantstrat package will pull in some other packages:
-# FinancialInstrument, quantmod, blotter, xts
-
-require(quantstrat)
-
-### FinancialInstrument
-
-currency(c('GBP', 'USD'))
-
-exchange_rate('GBPUSD', tick_size=0.0001)
-
-### quantmod
-
-getSymbols.FI(Symbols='GBPUSD',
-	      dir=system.file('extdata',package='quantstrat'),
-	      from=.from, to=.to
-)
-
-# ALTERNATIVE WAY TO FETCH SYMBOL DATA
-#setSymbolLookup.FI(system.file('extdata',package='quantstrat'), 'GBPUSD')
-#getSymbols('GBPUSD', from=.from, to=.to, verbose=FALSE)
-
-### xts
-
-GBPUSD = to.minutes30(GBPUSD)
-GBPUSD = align.time(to.minutes30(GBPUSD), 1800)
-
-### blotter
-
-initPortf(portfolio.st, symbols='GBPUSD', initDate=initDate, currency='USD')
-initAcct(account.st, portfolios=portfolio.st, initDate=initDate, currency='USD')
-
-### quantstrat
-
-initOrders(portfolio.st, initDate=initDate)
-
-### define strategy
-
-strategy(strategy.st, store=TRUE)
-
-### indicators
-
-add.indicator(strategy.st, name = "SMA",
-	arguments = list(
-		x = quote(Cl(mktdata)[,1]),
-		n = .fast
-	),
-	label="nFast"
-)
-
-add.indicator(strategy.st, name="SMA",
-	arguments = list(
-		x = quote(Cl(mktdata)[,1]),
-		n = .slow
-	),
-	label="nSlow"
-)
-
-### signals
-
-add.signal(strategy.st, 'sigCrossover',
-	arguments = list(
-		columns=c("nFast","nSlow"),
-		relationship="gte"
-	),
-	label='long'
-)
-
-add.signal(strategy.st, 'sigCrossover',
-	arguments = list(
-		columns=c("nFast","nSlow"),
-		relationship="lt"
-	),
-	label='short'
-)
-
-### rules
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		orderside='short',
-		ordertype='market',
-		orderqty='all',
-		TxnFees=.txn.fees,
-		replace=TRUE
-	),
-	type='exit',
-	label='Exit2LONG'
-)
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='short', sigval=TRUE,
-		orderside='long' ,
-		ordertype='market',
-		orderqty='all',
-		TxnFees=.txn.fees,
-		replace=TRUE
-	),
-	type='exit',
-	label='Exit2SHORT')
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		orderside='long' ,
-		ordertype='stoplimit', prefer='High', threshold=.threshold,
-		orderqty=+.orderqty,
-		replace=FALSE
-	),
-	type='enter',
-	label='EnterLONG'
-)
-
-add.rule(strategy.st, 'ruleSignal',
-	arguments=list(sigcol='short', sigval=TRUE,
-		orderside='short',
-		ordertype='stoplimit', prefer='Low', threshold=-.threshold,
-		orderqty=-.orderqty,
-		replace=FALSE
-	),
-	type='enter',
-	label='EnterSHORT'
-)
-
-###############################################################################
-
-applyStrategy(strategy.st, portfolio.st, verbose = FALSE)
-
-View(getOrderBook(portfolio.st)[[portfolio.st]]$GBPUSD)
-
-###############################################################################
-
-updatePortf(portfolio.st, Symbols='GBPUSD', Dates=paste('::',as.Date(Sys.time()),sep=''))
-
-chart.Posn(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)
-# rets  = PortfReturns(acct)
-################################################################

Modified: pkg/quantstrat/demo/luxor.3.Parameters.tradegraphs.R
===================================================================
--- pkg/quantstrat/demo/luxor.3.Parameters.tradegraphs.R	2013-04-16 15:23:34 UTC (rev 1435)
+++ pkg/quantstrat/demo/luxor.3.Parameters.tradegraphs.R	2013-04-17 11:01:33 UTC (rev 1436)
@@ -7,7 +7,6 @@
 tradeGraphs (
 	stats = stats,
 	free.params = c("Param.indicator.1.nFast", "Param.indicator.2.nSlow"),
-	fixed.params = NULL,
 	statistics = c("Net.Trading.PL", "maxDrawdown", "Avg.Trade.PL", "Num.Trades", "Profit.Factor"),
 	title = 'Luxor SMA Parameter Scan'
 )

Deleted: pkg/quantstrat/demo/luxor.strategy.R
===================================================================
--- pkg/quantstrat/demo/luxor.strategy.R	2013-04-16 15:23:34 UTC (rev 1435)
+++ pkg/quantstrat/demo/luxor.strategy.R	2013-04-17 11:01:33 UTC (rev 1436)
@@ -1,262 +0,0 @@
-#!/usr/bin/Rscript --vanilla
-#
-# Jan Humme (@opentrades) - August 2012
-#
-# Tested and found to work correctly using blotter r1123
-#
-# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
-#
-
-.fast = 6
-.slow = 44
-
-.qty=100000
-.th=0.0005
-.txn=-30
-.timespan = 'T08:00/T12:00'
-.timespan = 'T00:00/T23:59'
-
-.stoploss=0.001
-.stoptrailing=0.0015
-.takeprofit=0.003
-
-####
-
-require(quantstrat)
-
-s <- 'luxor'
-
-strategy(s, store=TRUE)
-
-### indicators
-
-add.indicator(s, name = "SMA",
-	arguments = list(
-		x = quote(Cl(mktdata)),
-		n = .fast
-	),
-	label="nFast"
-)
-
-add.indicator(s, name="SMA",
-	arguments = list(
-		x = quote(Cl(mktdata)),
-		n = .slow
-	),
-	label="nSlow"
-)
-
-### signals
-
-add.signal(s, name = 'sigCrossover',
-	arguments = list(
-		columns=c("nFast","nSlow"),
-		relationship="gte"
-	),
-	label='long'
-)
-
-add.signal(s, name = 'sigCrossover',
-	arguments = list(
-		columns=c("nFast","nSlow"),
-		relationship="lt"
-	),
-	label='short'
-)
-
-### rules ############
-
-### stop-loss
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		replace=FALSE,
-		orderside='long',
-		ordertype='stoplimit',
-		tmult=TRUE,
-		threshold=.stoploss,
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocolong'
-	),
-	type='chain',
-	parent='EnterLONG',
-	label='StopLossLONG',
-	storefun=FALSE
-)
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='short' , sigval=TRUE,
-		replace=FALSE,
-		orderside='short',
-		ordertype='stoplimit',
-		tmult=TRUE,
-		threshold=.stoploss,
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocoshort'
-	),
-	type='chain',
-	parent='EnterSHORT',
-	label='StopLossSHORT',
-	storefun=FALSE
-)
-
-### stop-trailing
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		replace=FALSE,
-		orderside='long',
-		ordertype='stoptrailing',
-		tmult=TRUE,
-		threshold=.stoptrailing,
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocolong'
-	),
-	type='chain',
-	parent='EnterLONG',
-	label='StopTrailingLONG',
-	storefun=FALSE
-)
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='short' , sigval=TRUE,
-		replace=FALSE,
-		orderside='short',
-		ordertype='stoptrailing',
-		tmult=TRUE,
-		threshold=.stoptrailing,
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocoshort'
-	),
-	type='chain',
-	parent='EnterSHORT',
-	label='StopTrailingSHORT',
-	storefun=FALSE
-)
-
-### take-profit
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		replace=FALSE,
-		orderside='long',
-		ordertype='limit',
-		tmult=TRUE,
-		threshold=.takeprofit,
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocolong'
-	),
-	type='chain',
-	parent='EnterLONG',
-	label='TakeProfitLONG',
-	storefun=FALSE
-)
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='short' , sigval=TRUE,
-		replace=FALSE,
-		orderside='short',
-		ordertype='limit',
-		tmult=TRUE,
-		threshold=.takeprofit,
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocoshort'
-	),
-	type='chain',
-	parent='EnterSHORT',
-	label='TakeProfitSHORT',
-	storefun=FALSE
-)
-
-### normal exits
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		replace=TRUE,
-		orderside='short',
-		ordertype='market',
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocoshort'
-	),
-	type='exit',
-	timespan = .timespan,
-	label='Exit2LONG',
-	storefun=FALSE
-)
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='short', sigval=TRUE,
-		replace=TRUE,
-		orderside='long' ,
-		ordertype='market',
-		TxnFees=.txn,
-		orderqty='all',
-		orderset='ocolong'
-	),
-	type='exit',
-	timespan = .timespan,
-	label='Exit2SHORT',
-	storefun=FALSE
-)
-
-### entries
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='long' , sigval=TRUE,
-		replace=FALSE,
-		orderside='long' ,
-		ordertype='stoplimit',
-		prefer='High',
-		threshold=.th,
-		TxnFees=0,
-		orderqty=+.qty,
-		osFUN=osMaxPos,
-		orderset='ocolong'
-	),
-	type='enter',
-	timespan = .timespan,
-	label='EnterLONG',
-	storefun=FALSE
-)
-
-add.rule(s, name = 'ruleSignal',
-	arguments=list(sigcol='short', sigval=TRUE,
-		replace=FALSE,
-		orderside='short',
-		ordertype='stoplimit',
-		prefer='Low',
-		threshold=.th,
-		TxnFees=0,
-		orderqty=-.qty,
-		osFUN=osMaxPos,
-		orderset='ocoshort'
-	),
-	type='enter',
-	timespan = .timespan,
-	label='EnterSHORT',
-	storefun=FALSE
-)
-
-###
-
-save.strategy('luxor')
-
-##### PLACE THIS BLOCK AHEAD OF DATE INITS IN DEMO SCRIPT ######
-# if(!exists('in_test') || !isTRUE(in_test)){
-#     initDate='2005-12-31' # ensure this is demo default
-#     endDate=Sys.Date()    # ensure this is demo default
-# }
-################################################################
-
-##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
-# book  = getOrderBook(port)
-# stats = tradeStats(port)
-# rets  = PortfReturns(acct)
-################################################################

Copied: pkg/quantstrat/demo/luxor.strategy.R (from rev 1430, pkg/quantstrat/demo/luxor.2.R)
===================================================================
--- pkg/quantstrat/demo/luxor.strategy.R	                        (rev 0)
+++ pkg/quantstrat/demo/luxor.strategy.R	2013-04-17 11:01:33 UTC (rev 1436)
@@ -0,0 +1,198 @@
+#!/usr/bin/Rscript --vanilla
+#
+# Jan Humme (@opentrades) - August 2012, revised April 2013
+#
+# Tested and found to work correctly using blotter r1420
+#
+# From Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
+#
+# Paragraph 3.2: luxor with $30 slippage and transaction costs
+
+options(width = 240)
+Sys.setenv(TZ="UTC")
+
+###
+
+.fast = 10
+.slow = 30
+
+.orderqty = 100000
+.threshold = 0.0005
+.txn.fees = -30
+
+##### PLACE DEMO AND TEST DATES HERE #################
+#
+#if(isTRUE(options('in_test')$in_test))
+#  # use test dates
+#  {initDate="2011-01-01" 
+#  endDate="2012-12-31"   
+#  } else
+#  # use demo defaults
+#  {initDate="1999-12-31"
+#  endDate=Sys.Date()}
+
+initDate = '2002-10-21'
+
+.from='2002-10-21'
+#.to='2008-07-04'
+.to='2002-10-31'
+
+####
+
+strategy.st = 'luxor'
+portfolio.st = 'forex'
+account.st = 'IB1'
+
+### packages
+#
+# quantstrat package will pull in some other packages:
+# FinancialInstrument, quantmod, blotter, xts
+
+require(quantstrat)
+
+### FinancialInstrument
+
+currency(c('GBP', 'USD'))
+
+exchange_rate('GBPUSD', tick_size=0.0001)
+
+### quantmod
+
+getSymbols.FI(Symbols='GBPUSD',
+	      dir=system.file('extdata',package='quantstrat'),
+	      from=.from, to=.to
+)
+
+# ALTERNATIVE WAY TO FETCH SYMBOL DATA
+#setSymbolLookup.FI(system.file('extdata',package='quantstrat'), 'GBPUSD')
+#getSymbols('GBPUSD', from=.from, to=.to, verbose=FALSE)
+
+### xts
+
+GBPUSD = to.minutes30(GBPUSD)
+GBPUSD = align.time(to.minutes30(GBPUSD), 1800)
+
+### blotter
+
+initPortf(portfolio.st, symbols='GBPUSD', initDate=initDate, currency='USD')
+initAcct(account.st, portfolios=portfolio.st, initDate=initDate, currency='USD')
+
+### quantstrat
+
+initOrders(portfolio.st, initDate=initDate)
+
+### define strategy
+
+strategy(strategy.st, store=TRUE)
+
+### indicators
+
+add.indicator(strategy.st, name = "SMA",
+	arguments = list(
+		x = quote(Cl(mktdata)[,1]),
+		n = .fast
+	),
+	label="nFast"
+)
+
+add.indicator(strategy.st, name="SMA",
+	arguments = list(
+		x = quote(Cl(mktdata)[,1]),
+		n = .slow
+	),
+	label="nSlow"
+)
+
+### signals
+
+add.signal(strategy.st, name='sigCrossover',
+	arguments = list(
+		columns=c("nFast","nSlow"),
+		relationship="gte"
+	),
+	label='long'
+)
+
+add.signal(strategy.st, name='sigCrossover',
+	arguments = list(
+		columns=c("nFast","nSlow"),
+		relationship="lt"
+	),
+	label='short'
+)
+
+### rules
+
+add.rule(strategy.st, name='ruleSignal',
+	arguments=list(sigcol='long' , sigval=TRUE,
+		orderside='short',
+		ordertype='market',
+		orderqty='all',
+		TxnFees=.txn.fees,
+		replace=TRUE
+	),
+	type='exit',
+	label='Exit2LONG'
+)
+
+add.rule(strategy.st, name='ruleSignal',
+	arguments=list(sigcol='short', sigval=TRUE,
+		orderside='long' ,
+		ordertype='market',
+		orderqty='all',
+		TxnFees=.txn.fees,
+		replace=TRUE
+	),
+	type='exit',
+	label='Exit2SHORT'
+)
+
+add.rule(strategy.st, name='ruleSignal',
+	arguments=list(sigcol='long' , sigval=TRUE,
+		orderside='long' ,
+		ordertype='stoplimit', prefer='High', threshold=.threshold,
+		orderqty=+.orderqty,
+		replace=FALSE
+	),
+	type='enter',
+	label='EnterLONG'
+)
+
+add.rule(strategy.st, name='ruleSignal',
+	arguments=list(sigcol='short', sigval=TRUE,
+		orderside='short',
+		ordertype='stoplimit', prefer='Low', threshold=-.threshold,
+		orderqty=-.orderqty,
+		replace=FALSE
+	),
+	type='enter',
+	label='EnterSHORT'
+)
+
+###############################################################################
+
+applyStrategy(strategy.st, portfolio.st, verbose = FALSE)
+
+View(getOrderBook(portfolio.st)[[portfolio.st]]$GBPUSD)
+
+###############################################################################
+
+updatePortf(portfolio.st, Symbols='GBPUSD', Dates=paste('::',as.Date(Sys.time()),sep=''))
+
+chart.Posn(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)
+# rets  = PortfReturns(acct)
+################################################################



More information about the Blotter-commits mailing list