SCM

SCM Repository

[blotter] Annotation of /pkg/quantstrat/demo/luxor.6.paramset.takeprofit.R
ViewVC logotype

Annotation of /pkg/quantstrat/demo/luxor.6.paramset.takeprofit.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1734 - (view) (download)

1 : opentrades 1457 #!/usr/bin/Rscript --vanilla
2 :     #
3 :     # Jan Humme (@opentrades) - August 2012
4 :     #
5 : opentrades 1458 # Tested and found to work correctly using blotter r1457
6 : opentrades 1457 #
7 : opentrades 1458 # After Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)
8 : opentrades 1457 #
9 :     # compute TakeProfit percentage for various paramsets
10 :    
11 :     require(quantstrat)
12 :    
13 : erastus 1515 source(paste0(path.package("quantstrat"),"/demo/luxor.include.R"))
14 :     source(paste0(path.package("quantstrat"),"/demo/luxor.getSymbols.R"))
15 : opentrades 1457
16 :     ###
17 :    
18 : bodanker 1724 initPortf(portfolio.st, symbols='GBPUSD', currency='USD')
19 : opentrades 1457 addPosLimit(
20 :     portfolio=portfolio.st,
21 :     symbol='GBPUSD',
22 : bodanker 1724 timestamp=startDate,
23 : opentrades 1457 maxpos=.orderqty)
24 :    
25 : bodanker 1724 initAcct(account.st, portfolios=portfolio.st, currency='USD')
26 : opentrades 1457
27 :     ###
28 :    
29 : bodanker 1724 initOrders(portfolio.st)
30 : opentrades 1457
31 :     load.strategy(strategy.st)
32 :    
33 :     ### BEGIN uncomment lines to activate StopLoss and/or StopTrailing and/or TakeProfit rules
34 :    
35 :     enable.rule('luxor', 'chain', 'StopLoss')
36 : opentrades 1467 #enable.rule('luxor', 'chain', 'StopTrailing')
37 : opentrades 1457 enable.rule('luxor', 'chain', 'TakeProfit')
38 :    
39 :     ### END uncomment lines to activate StopLoss and/or StopTrailing and/or TakeProfit rules
40 :     require(foreach)
41 :     #registerDoSEQ()
42 :    
43 : erastus 1515 if (!"doMC" %in% installed.packages()[,1]) {
44 :     install.packages("doMC")
45 :     }
46 : opentrades 1457 require(doMC)
47 :     registerDoMC(cores=8)
48 :    
49 :     #require(doParallel)
50 :     #registerDoParallel(cores=2)
51 :    
52 :     #require(doRedis)
53 :     #registerDoRedis('jobs')
54 :    
55 :     ############################
56 :    
57 :     results <- apply.paramset(strategy.st, paramset.label='TakeProfit', portfolio.st=portfolio.st, account.st=account.st, nsamples=80, verbose=TRUE)
58 :    
59 :     stats <- results$tradeStats
60 :    
61 : bodanker 1734 print(t(stats))
62 : opentrades 1457
63 :     plot(100*stats$TakeProfitLONG, stats$Net.Trading.PL, type='b', xlab='TakeProfit %', ylab='Net.Trading.PL', main='Luxor')

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