SCM

SCM Repository

[blotter] View of /pkg/quantstrat/demo/luxor.2.add.paramsets.R
ViewVC logotype

View of /pkg/quantstrat/demo/luxor.2.add.paramsets.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1720 - (download) (annotate)
Sun Dec 6 21:46:31 2015 UTC (3 years, 6 months ago) by bodanker
File size: 2195 byte(s)
Get luxor.4 demo running

This demo never worked as committed. The timespan paramset contained
component.type = "rule", which was never supported. It's also unclear
how variable = list(n = .timespans) was supposed to work.

Add a paramset distribution for each combination of entry/exit and
long/short. Change variable from 'n' to 'timespan', since that's the
variable we're parameterizing.

The correctness of the demo is still uncertain, but at least it runs.
#!/usr/bin/Rscript --vanilla
#
# Jan Humme (@opentrades) - August 2012, revised April 2013
#
# Tested and found to work correctly using blotter r1457
#
# After Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)

require(quantstrat)

##### 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()}

source(paste0(path.package("quantstrat"),"/demo/luxor.include.R"))

###

strategy.st <- 'luxor'

###

load.strategy(strategy.st)

### SMA paramset

add.distribution(strategy.st,
	paramset.label = 'SMA',
	component.type = 'indicator',
	component.label = 'nFast',
	variable = list(n = .FastSMA),
	label = 'nFAST'
)

add.distribution(strategy.st,
	paramset.label = 'SMA',
	component.type = 'indicator',
	component.label = 'nSlow',
	variable = list(n = .SlowSMA),
	label = 'nSLOW'
)

add.distribution.constraint(strategy.st,
	paramset.label = 'SMA',
	distribution.label.1 = 'nFAST',
	distribution.label.2 = 'nSLOW',
	operator = '<',
	label = 'SMA'
)

### Timespan paramset

add.distribution(strategy.st,
	paramset.label = 'Timespan',
	component.type = 'enter',
	component.label = 'EnterLONG',
	variable = list(timespan = .timespans),
	label = 'Timespan'
)

add.distribution(strategy.st,
	paramset.label = 'Timespan',
	component.type = 'enter',
	component.label = 'EnterSHORT',
	variable = list(timespan = .timespans),
	label = 'Timespan'
)

add.distribution(strategy.st,
	paramset.label = 'Timespan',
	component.type = 'exit',
	component.label = 'Exit2LONG',
	variable = list(timespan = .timespans),
	label = 'Timespan'
)

add.distribution(strategy.st,
	paramset.label = 'Timespan',
	component.type = 'exit',
	component.label = 'Exit2SHORT',
	variable = list(timespan = .timespans),
	label = 'Timespan'
)

###

save.strategy(strategy.st)

##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
# book  = getOrderBook(port)
# stats = tradeStats(port)
# rets  = PortfReturns(acct)
################################################################

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge