SCM

SCM Repository

[blotter] Annotation of /pkg/quantstrat/demo/bbandParameters.R
ViewVC logotype

Annotation of /pkg/quantstrat/demo/bbandParameters.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1702 - (view) (download)

1 : braverock 1702 # Parameter example for BBands demo
2 :     ###############################################################################
3 :    
4 :     require(foreach,quietly=TRUE)
5 :     require(iterators)
6 :     require(quantstrat)
7 :    
8 :     # example parallel initialization for doParallel. this or doMC, or doRedis are
9 :     # most probably preferable to doSMP
10 :     #require(doParallel)
11 :     #registerDoParallel() # by default number of physical cores -1
12 :    
13 :     demo('bbands',ask=FALSE)
14 :     strategy.st='bbands'
15 :    
16 :     ### User Set up pf parameter ranges to test
17 :     .nlist = 10:40
18 :     .sdlist = 1:4
19 :    
20 :     # number of random samples of the parameter distribution to use for random run
21 :     .nsamples = 10
22 :    
23 :     add.distribution(strategy.st,
24 :     paramset.label = 'BBparams',
25 :     component.type = 'indicator',
26 :     component.label = 'BBands', #this is the label given to the indicator in the strat
27 :     variable = list(n = .nlist),
28 :     label = 'nFAST'
29 :     )
30 :    
31 :     add.distribution(strategy.st,
32 :     paramset.label = 'BBparams',
33 :     component.type = 'indicator',
34 :     component.label = 'BBands', #this is the label given to the indicator in the strat
35 :     variable = list(sd = .sdlist),
36 :     label = 'nSLOW'
37 :     )
38 :    
39 :    
40 :     results <- apply.paramset(strategy.st,
41 :     paramset.label='BBparams',
42 :     portfolio.st=portfolio.st,
43 :     account.st=account.st,
44 :     nsamples=.nsamples,
45 :     verbose=TRUE)
46 :    
47 :     stats <- results$tradeStats
48 :    
49 :     print(stats)
50 :    
51 :    
52 :    
53 :     ##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ###################
54 :     # book = getOrderBook(port)
55 :     # stats = tradeStats(port)
56 :     # rets = PortfReturns(acct)
57 :     ################################################################
58 :    
59 :     ###############################################################################
60 :     # R (http://r-project.org/) Quantitative Strategy Model Framework
61 :     #
62 :     # Copyright (c) 2009-2012
63 :     # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich
64 :     #
65 :     # This library is distributed under the terms of the GNU Public License (GPL)
66 :     # for full details see the file COPYING
67 :     #
68 :     # $Id: bbands.R 1097 2012-07-01 00:30:39Z braverock $
69 :     #
70 :     ###############################################################################

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