braverock / quantstrat

289 stars 114 forks source link

bbandParameters.R fails #112

Closed SamoPP closed 4 years ago

SamoPP commented 5 years ago

For me running bbandParameters.R fails.

> # Parameter example for BBands demo
>      
 ###############################################################################
> 
> require(foreach,quietly=TRUE)
> require(iterators)
> require(quantstrat)
> 
> # example parallel initialization for doParallel. this or doMC, or doRedis are 
> # most probably preferable to doSMP
> #require(doParallel)
> #registerDoParallel() # by default number of physical cores -1
> 
> demo('bbands',ask=FALSE)

    demo(bbands)
    ---- ~~~~~~

> require(quantstrat)

> suppressWarnings(rm("order_book.bbands",pos=.strategy))

> suppressWarnings(rm("account.bbands","portfolio.bbands",pos=.blotter))

> suppressWarnings(rm("account.st","portfolio.st","stock.str","stratBBands","startDate","initEq",'start_t','end_t'))

> # some things to set up here
> stock.str='IBM' # what are we trying it on

> # we'll pass these 
> SD = 2 # how many standard deviations, traditionally 2

> N = 20 # how many periods for the moving average, traditionally 20

> currency('USD')
[1] "USD"

> stock(stock.str,currency='USD',multiplier=1)
[1] "IBM"

> startDate='2006-12-31'

> initEq=1000000

> portfolio.st='bbands'

> account.st='bbands'

> initPortf(portfolio.st, symbols=stock.str)
[1] "bbands"

> initAcct(account.st,portfolios='bbands')
[1] "bbands"

> initOrders(portfolio=portfolio.st)

> addPosLimit(portfolio.st, stock.str, startDate, 200, 2 ) #set max pos

> # set up parameters
> maType='SMA'

> n = 20

> sdp = 2

> strat.st<-portfolio.st

> # define the strategy
> strategy(strat.st, store=TRUE)

> #one indicator
> add.indicator(strategy = strat.st, 
+               name = "BBands", 
+               arguments = list(HLC = quote(HLC(mktdata)), 
+                                n=n, 
+                                maType=maType, 
+                                sd=sdp 
+                                ), 
+               label='BBands')
[1] "bbands"

> #add signals:
> add.signal(strategy = strat.st,
+            name="sigCrossover",
+            arguments = list(columns=c("Close","up"),
+                             relationship="gt"),
+            label="Cl.gt.UpperBand")
[1] "bbands"

> add.signal(strategy = strat.st,
+            name="sigCrossover",
+            arguments = list(columns=c("Close","dn"),
+                             relationship="lt"),
+            label="Cl.lt.LowerBand")
[1] "bbands"

> add.signal(strategy = strat.st,name="sigCrossover",
+            arguments = list(columns=c("High","Low","mavg"),
+                             relationship="op"),
+            label="Cross.Mid")
[1] "bbands"

> # lets add some rules
> add.rule(strategy = strat.st,name='ruleSignal',
+          arguments = list(sigcol="Cl.gt.UpperBand",
+                           sigval=TRUE,
+                           orderqty=-100, 
+                           ordertype='market',
+                           orderside=NULL,
+                           threshold=NULL,
+                           osFUN=osMaxPos),
+          type='enter')
[1] "bbands"

> add.rule(strategy = strat.st,name='ruleSignal',
+          arguments = list(sigcol="Cl.lt.LowerBand",
+                           sigval=TRUE,
+                           orderqty= 100, 
+                           ordertype='market',
+                           orderside=NULL,
+                           threshold=NULL,
+                           osFUN=osMaxPos),
+          type='enter')
[1] "bbands"

> add.rule(strategy = strat.st,name='ruleSignal',
+          arguments = list(sigcol="Cross.Mid",
+                           sigval=TRUE,
+                           orderqty= 'all',
+                           ordertype='market',
+                           orderside=NULL,
+                           threshold=NULL,
+                           osFUN=osMaxPos),
+          label='exitMid',
+          type='exit')
[1] "bbands"

> #alternately, to exit at the opposite band, the rules would be...
> #add.rule(strategy = strat.st,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Lo.gt.UpperBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
> #add.rule(strategy = strat.st,name='ruleSignal', arguments = list(data=quote(mktdata),sigcol="Hi.lt.LowerBand",sigval=TRUE, orderqty= 'all', ordertype='market', orderside=NULL, threshold=NULL),type='exit')
> 
> #TODO add thresholds and stop-entry and stop-exit handling to test
> 
> getSymbols(stock.str,from=startDate,index.class=c('POSIXt','POSIXct'), src='yahoo')
[1] "IBM"

> start_t<-Sys.time()

> out<-try(applyStrategy(strategy='bbands' , portfolios='bbands',parameters=list(sd=SD,n=N)) )
[1] "2007-02-27 00:00:00 IBM 100 @ 93.959999"
[1] "2007-03-21 00:00:00 IBM -100 @ 95.360001"
[1] "2007-04-04 00:00:00 IBM -100 @ 96.209999"
[1] "2007-04-13 00:00:00 IBM 100 @ 94.93"
[1] "2007-04-18 00:00:00 IBM -100 @ 94.800003"
[1] "2007-04-19 00:00:00 IBM 100 @ 94.290001"
[1] "2007-04-25 00:00:00 IBM -100 @ 101.459999"
[1] "2007-05-25 00:00:00 IBM 100 @ 105.18"
[1] "2007-06-07 00:00:00 IBM 100 @ 101.800003"
[1] "2007-06-18 00:00:00 IBM -100 @ 105.330002"
[1] "2007-07-06 00:00:00 IBM -100 @ 109.029999"
[1] "2007-07-18 00:00:00 IBM -100 @ 111.080002"
[1] "2007-08-01 00:00:00 IBM 200 @ 112.040001"
[1] "2007-08-31 00:00:00 IBM -100 @ 116.690002"
[1] "2007-09-18 00:00:00 IBM 100 @ 116.629997"
[1] "2007-10-02 00:00:00 IBM -100 @ 118.360001"
[1] "2007-10-04 00:00:00 IBM 100 @ 115.690002"
[1] "2007-10-17 00:00:00 IBM -100 @ 115.779999"
[1] "2007-10-18 00:00:00 IBM 100 @ 114.800003"
[1] "2007-10-19 00:00:00 IBM 100 @ 112.279999"
[1] "2007-11-01 00:00:00 IBM -100 @ 113.650002"
[1] "2007-11-09 00:00:00 IBM 100 @ 100.25"
[1] "2007-11-29 00:00:00 IBM -100 @ 107.5"
[1] "2007-12-07 00:00:00 IBM -100 @ 108.860001"
[1] "2007-12-17 00:00:00 IBM 100 @ 104.529999"
[1] "2007-12-24 00:00:00 IBM -100 @ 111.650002"
[1] "2008-01-02 00:00:00 IBM 100 @ 104.690002"
[1] "2008-01-07 00:00:00 IBM 100 @ 100.050003"
[1] "2008-01-15 00:00:00 IBM -100 @ 101.830002"
[1] "2008-02-04 00:00:00 IBM -100 @ 107.93"
[1] "2008-02-07 00:00:00 IBM 100 @ 102.339996"
[1] "2008-02-26 00:00:00 IBM -100 @ 114.379997"
[1] "2008-03-27 00:00:00 IBM 100 @ 115.519997"
[1] "2008-04-11 00:00:00 IBM -100 @ 116"
[1] "2008-04-14 00:00:00 IBM 100 @ 117.279999"
[1] "2008-04-17 00:00:00 IBM -100 @ 123.080002"
[1] "2008-05-07 00:00:00 IBM 100 @ 124.139999"
[1] "2008-05-14 00:00:00 IBM -100 @ 127.519997"
[1] "2008-05-22 00:00:00 IBM 100 @ 124.699997"
[1] "2008-05-29 00:00:00 IBM -100 @ 129.710007"
[1] "2008-06-05 00:00:00 IBM 100 @ 128.470001"
[1] "2008-06-12 00:00:00 IBM 100 @ 123.849998"
[1] "2008-06-16 00:00:00 IBM -100 @ 126.709999"
[1] "2008-06-27 00:00:00 IBM 100 @ 120.050003"
[1] "2008-07-09 00:00:00 IBM -100 @ 120.400002"
[1] "2008-07-17 00:00:00 IBM -100 @ 126.519997"
[1] "2008-08-12 00:00:00 IBM 100 @ 125.220001"
[1] "2008-08-13 00:00:00 IBM 100 @ 125.800003"
[1] "2008-08-15 00:00:00 IBM -100 @ 126.360001"
[1] "2008-08-19 00:00:00 IBM 100 @ 122.559998"
[1] "2008-09-03 00:00:00 IBM 100 @ 118.339996"
[1] "2008-09-22 00:00:00 IBM -200 @ 116.209999"
[1] "2008-10-02 00:00:00 IBM 100 @ 104.739998"
[1] "2008-10-31 00:00:00 IBM -100 @ 92.970001"
[1] "2008-11-21 00:00:00 IBM 100 @ 74.879997"
[1] "2008-12-04 00:00:00 IBM -100 @ 77.440002"
[1] "2008-12-17 00:00:00 IBM -100 @ 85.839996"
[1] "2008-12-23 00:00:00 IBM 100 @ 80.599998"
[1] "2009-01-05 00:00:00 IBM -100 @ 86.82"
[1] "2009-01-07 00:00:00 IBM -100 @ 87.790001"
[1] "2009-01-15 00:00:00 IBM 200 @ 84.120003"
[1] "2009-01-22 00:00:00 IBM -100 @ 90.07"
[1] "2009-01-27 00:00:00 IBM -100 @ 91.660004"
[1] "2009-02-18 00:00:00 IBM 200 @ 91.510002"
[1] "2009-02-24 00:00:00 IBM 100 @ 86.400002"
[1] "2009-03-02 00:00:00 IBM -100 @ 89.050003"
[1] "2009-03-24 00:00:00 IBM -100 @ 98.300003"
[1] "2009-04-16 00:00:00 IBM 100 @ 101.43"
[1] "2009-04-30 00:00:00 IBM -100 @ 103.209999"
[1] "2009-05-04 00:00:00 IBM -100 @ 106.190002"
[1] "2009-05-08 00:00:00 IBM 200 @ 101.489998"
[1] "2009-06-02 00:00:00 IBM -100 @ 106.830002"
[1] "2009-06-19 00:00:00 IBM 100 @ 105.889999"
[1] "2009-07-06 00:00:00 IBM 100 @ 101.650002"
[1] "2009-07-16 00:00:00 IBM -100 @ 110.639999"
[1] "2009-07-17 00:00:00 IBM -100 @ 115.419998"
[1] "2009-08-17 00:00:00 IBM 100 @ 116.860001"
[1] "2009-09-02 00:00:00 IBM 100 @ 116.089996"
[1] "2009-09-09 00:00:00 IBM -100 @ 116.760002"
[1] "2009-09-17 00:00:00 IBM -100 @ 121.879997"
[1] "2009-09-29 00:00:00 IBM 100 @ 118.809998"
[1] "2009-10-12 00:00:00 IBM -100 @ 127.040001"
[1] "2009-10-19 00:00:00 IBM 100 @ 123.059998"
[1] "2009-11-12 00:00:00 IBM -100 @ 126.260002"
[1] "2009-11-17 00:00:00 IBM -100 @ 128.630005"
[1] "2009-11-30 00:00:00 IBM 200 @ 126.349998"
[1] "2009-12-11 00:00:00 IBM -100 @ 129.679993"
[1] "2009-12-18 00:00:00 IBM 100 @ 127.910004"
[1] "2009-12-29 00:00:00 IBM -100 @ 131.850006"
[1] "2010-01-08 00:00:00 IBM 100 @ 130.850006"
[1] "2010-01-20 00:00:00 IBM -100 @ 130.25"
[1] "2010-01-21 00:00:00 IBM 100 @ 129"
[1] "2010-01-25 00:00:00 IBM 100 @ 126.120003"
[1] "2010-01-29 00:00:00 IBM 100 @ 122.389999"
[1] "2010-02-18 00:00:00 IBM -200 @ 127.809998"
[1] "2010-03-17 00:00:00 IBM -100 @ 127.760002"
[1] "2010-03-22 00:00:00 IBM 100 @ 127.980003"
[1] "2010-03-24 00:00:00 IBM -100 @ 128.529999"
[1] "2010-04-01 00:00:00 IBM 100 @ 128.25"
[1] "2010-04-15 00:00:00 IBM -100 @ 130.889999"
[1] "2010-04-20 00:00:00 IBM -100 @ 129.690002"
[1] "2010-04-21 00:00:00 IBM 200 @ 128.990005"
[1] "2010-05-07 00:00:00 IBM 100 @ 122.099998"
[1] "2010-05-13 00:00:00 IBM -100 @ 131.479996"
[1] "2010-06-17 00:00:00 IBM -100 @ 130.979996"
[1] "2010-06-28 00:00:00 IBM 100 @ 128.979996"
[1] "2010-08-25 00:00:00 IBM 100 @ 125.269997"
[1] "2010-08-27 00:00:00 IBM 100 @ 124.730003"
[1] "2010-09-07 00:00:00 IBM -200 @ 125.949997"
[1] "2010-09-21 00:00:00 IBM -100 @ 131.979996"
[1] "2010-10-20 00:00:00 IBM 100 @ 139.070007"
[1] "2010-11-01 00:00:00 IBM -100 @ 143.320007"
[1] "2010-11-17 00:00:00 IBM 100 @ 141.949997"
[1] "2010-12-01 00:00:00 IBM 100 @ 144.410004"
[1] "2010-12-02 00:00:00 IBM -100 @ 145.179993"
[1] "2010-12-30 00:00:00 IBM -100 @ 146.669998"
[1] "2011-01-07 00:00:00 IBM -100 @ 147.929993"
[1] "2011-02-23 00:00:00 IBM 200 @ 160.179993"
[1] "2011-03-02 00:00:00 IBM 100 @ 160.160004"
[1] "2011-03-04 00:00:00 IBM -100 @ 161.830002"
[1] "2011-03-10 00:00:00 IBM -100 @ 162.020004"
[1] "2011-03-11 00:00:00 IBM 100 @ 162.429993"
[1] "2011-03-17 00:00:00 IBM 100 @ 154.179993"
[1] "2011-03-25 00:00:00 IBM -100 @ 162.179993"
[1] "2011-04-25 00:00:00 IBM -100 @ 167.669998"
[1] "2011-05-03 00:00:00 IBM -100 @ 172.869995"
[1] "2011-05-12 00:00:00 IBM 200 @ 172.240005"
[1] "2011-06-02 00:00:00 IBM 100 @ 166.089996"
[1] "2011-06-21 00:00:00 IBM -100 @ 166.220001"
[1] "2011-06-29 00:00:00 IBM -100 @ 170.539993"
[1] "2011-07-20 00:00:00 IBM -100 @ 183.649994"
[1] "2011-08-02 00:00:00 IBM 200 @ 178.050003"
[1] "2011-08-09 00:00:00 IBM 100 @ 170.610001"
[1] "2011-08-11 00:00:00 IBM 100 @ 166.729996"
[1] "2011-08-29 00:00:00 IBM -200 @ 172.619995"
[1] "2011-10-11 00:00:00 IBM -100 @ 185"
[1] "2011-10-17 00:00:00 IBM -100 @ 186.589996"
[1] "2011-10-19 00:00:00 IBM 200 @ 177.389999"
[1] "2011-11-25 00:00:00 IBM 100 @ 177.059998"
[1] "2011-12-01 00:00:00 IBM -100 @ 189.449997"
[1] "2012-01-23 00:00:00 IBM -100 @ 189.979996"
[1] "2012-02-16 00:00:00 IBM 100 @ 193.020004"
[1] "2012-02-24 00:00:00 IBM -100 @ 197.759995"
[1] "2012-03-06 00:00:00 IBM -100 @ 197.259995"
[1] "2012-04-05 00:00:00 IBM 200 @ 205.470001"
[1] "2012-04-11 00:00:00 IBM 100 @ 202.580002"
[1] "2012-04-17 00:00:00 IBM -100 @ 207.449997"
[1] "2012-04-19 00:00:00 IBM 100 @ 199.509995"
[1] "2012-04-27 00:00:00 IBM -100 @ 206.809998"
[1] "2012-06-04 00:00:00 IBM 100 @ 188.539993"
[1] "2012-06-08 00:00:00 IBM -100 @ 195.139999"
[1] "2012-07-11 00:00:00 IBM 100 @ 185.25"
[1] "2012-07-20 00:00:00 IBM -100 @ 192.449997"
[1] "2012-08-31 00:00:00 IBM 100 @ 194.850006"
[1] "2012-09-07 00:00:00 IBM -100 @ 199.5"
[1] "2012-09-12 00:00:00 IBM -100 @ 203.770004"
[1] "2012-10-11 00:00:00 IBM 100 @ 205.759995"
[1] "2012-10-18 00:00:00 IBM 100 @ 194.960007"
[1] "2012-11-26 00:00:00 IBM -100 @ 192.880005"
[1] "2012-12-19 00:00:00 IBM -100 @ 195.080002"
[1] "2012-12-24 00:00:00 IBM 100 @ 192.399994"
[1] "2013-01-03 00:00:00 IBM -100 @ 195.270004"
[1] "2013-01-07 00:00:00 IBM 100 @ 193.139999"
[1] "2013-01-23 00:00:00 IBM -100 @ 204.720001"
[1] "2013-02-08 00:00:00 IBM 100 @ 201.679993"
[1] "2013-03-05 00:00:00 IBM -100 @ 206.529999"
[1] "2013-03-15 00:00:00 IBM -100 @ 214.919998"
[1] "2013-03-28 00:00:00 IBM 200 @ 213.300003"
[1] "2013-04-19 00:00:00 IBM 100 @ 190"
[1] "2013-05-06 00:00:00 IBM -100 @ 202.779999"
[1] "2013-06-13 00:00:00 IBM 100 @ 203.770004"
[1] "2013-06-19 00:00:00 IBM -100 @ 201.940002"
[1] "2013-06-21 00:00:00 IBM 100 @ 195.460007"
[1] "2013-07-01 00:00:00 IBM 100 @ 191.279999"
[1] "2013-07-18 00:00:00 IBM -200 @ 197.990005"
[1] "2013-08-07 00:00:00 IBM 100 @ 188.559998"
[1] "2013-09-10 00:00:00 IBM -100 @ 186.600006"
[1] "2013-09-12 00:00:00 IBM -100 @ 190.729996"
[1] "2013-09-19 00:00:00 IBM -100 @ 193.389999"
[1] "2013-09-30 00:00:00 IBM 200 @ 185.179993"
[1] "2013-10-08 00:00:00 IBM 100 @ 178.720001"
[1] "2013-10-17 00:00:00 IBM -100 @ 174.830002"
[1] "2013-10-18 00:00:00 IBM 100 @ 173.779999"
[1] "2013-10-30 00:00:00 IBM -100 @ 180.149994"
[1] "2013-12-24 00:00:00 IBM -100 @ 183.220001"
[1] "2014-01-15 00:00:00 IBM 100 @ 187.740005"
[1] "2014-01-27 00:00:00 IBM 100 @ 177.899994"
[1] "2014-02-04 00:00:00 IBM 100 @ 172.839996"
[1] "2014-02-12 00:00:00 IBM -200 @ 180.240005"
[1] "2014-03-26 00:00:00 IBM -100 @ 192.619995"
[1] "2014-04-02 00:00:00 IBM -100 @ 193.550003"
[1] "2014-04-21 00:00:00 IBM 200 @ 192.270004"
[1] "2014-05-16 00:00:00 IBM 100 @ 187.059998"
[1] "2014-05-21 00:00:00 IBM 100 @ 186.389999"
[1] "2014-06-09 00:00:00 IBM -200 @ 186.220001"
[1] "2014-06-12 00:00:00 IBM 100 @ 181.220001"
[1] "2014-06-20 00:00:00 IBM -100 @ 181.550003"
[1] "2014-07-03 00:00:00 IBM -100 @ 188.529999"
[1] "2014-07-17 00:00:00 IBM -100 @ 192.490005"
[1] "2014-08-04 00:00:00 IBM 200 @ 189.639999"
[1] "2014-08-08 00:00:00 IBM 100 @ 186.630005"
[1] "2014-08-20 00:00:00 IBM -100 @ 190.100006"
[1] "2014-09-19 00:00:00 IBM -100 @ 194"
[1] "2014-09-24 00:00:00 IBM 100 @ 192.309998"
[1] "2014-09-26 00:00:00 IBM 100 @ 190.059998"
[1] "2014-10-02 00:00:00 IBM 100 @ 186.910004"
[1] "2014-11-17 00:00:00 IBM -200 @ 164.160004"
[1] "2014-11-21 00:00:00 IBM 100 @ 160.919998"
[1] "2014-11-25 00:00:00 IBM -100 @ 161.759995"
[1] "2014-12-04 00:00:00 IBM -100 @ 164.050003"
[1] "2014-12-09 00:00:00 IBM 100 @ 162.990005"
[1] "2014-12-11 00:00:00 IBM 100 @ 161.070007"
[1] "2014-12-15 00:00:00 IBM 100 @ 153.059998"
[1] "2014-12-22 00:00:00 IBM -200 @ 161.440002"
[1] "2015-01-22 00:00:00 IBM 100 @ 155.389999"
[1] "2015-01-27 00:00:00 IBM -100 @ 153.669998"
[1] "2015-01-29 00:00:00 IBM 100 @ 155.479996"
[1] "2015-02-04 00:00:00 IBM -100 @ 156.960007"
[1] "2015-02-17 00:00:00 IBM -100 @ 160.960007"
[1] "2015-03-03 00:00:00 IBM 100 @ 161.029999"
[1] "2015-03-12 00:00:00 IBM 100 @ 157.979996"
[1] "2015-03-16 00:00:00 IBM 100 @ 157.080002"
[1] "2015-03-19 00:00:00 IBM -200 @ 159.809998"
[1] "2015-04-21 00:00:00 IBM -100 @ 164.259995"
[1] "2015-04-24 00:00:00 IBM -100 @ 169.779999"
[1] "2015-05-13 00:00:00 IBM 200 @ 172.279999"
[1] "2015-05-27 00:00:00 IBM 100 @ 172"
[1] "2015-06-01 00:00:00 IBM 100 @ 170.179993"
[1] "2015-06-24 00:00:00 IBM -200 @ 166.970001"
[1] "2015-06-30 00:00:00 IBM 100 @ 162.660004"
[1] "2015-07-13 00:00:00 IBM -100 @ 169.380005"
[1] "2015-07-17 00:00:00 IBM -100 @ 172.509995"
[1] "2015-07-22 00:00:00 IBM 100 @ 160.350006"
[1] "2015-08-24 00:00:00 IBM 100 @ 143.470001"
[1] "2015-09-16 00:00:00 IBM -100 @ 148.410004"
[1] "2015-09-29 00:00:00 IBM 100 @ 142.470001"
[1] "2015-10-01 00:00:00 IBM -100 @ 143.589996"
[1] "2015-10-08 00:00:00 IBM -100 @ 152.279999"
[1] "2015-10-21 00:00:00 IBM 100 @ 140.919998"
[1] "2015-10-28 00:00:00 IBM 100 @ 140.830002"
[1] "2015-11-16 00:00:00 IBM 100 @ 133.710007"
[1] "2015-11-23 00:00:00 IBM -200 @ 138.460007"
[1] "2015-12-21 00:00:00 IBM 100 @ 135.5"
[1] "2015-12-23 00:00:00 IBM -100 @ 138.539993"
[1] "2016-01-08 00:00:00 IBM 100 @ 131.630005"
[1] "2016-01-14 00:00:00 IBM 100 @ 132.910004"
[1] "2016-02-05 00:00:00 IBM -200 @ 128.570007"
[1] "2016-02-19 00:00:00 IBM -100 @ 133.080002"
[1] "2016-03-18 00:00:00 IBM -100 @ 147.089996"
[1] "2016-04-20 00:00:00 IBM 100 @ 146.110001"
[1] "2016-04-22 00:00:00 IBM 100 @ 148.5"
[1] "2016-05-26 00:00:00 IBM -100 @ 152.440002"
[1] "2016-06-14 00:00:00 IBM 100 @ 151.059998"
[1] "2016-06-24 00:00:00 IBM -100 @ 146.589996"
[1] "2016-06-27 00:00:00 IBM 100 @ 143.5"
[1] "2016-07-15 00:00:00 IBM -100 @ 159.779999"
[1] "2016-08-12 00:00:00 IBM -100 @ 161.949997"
[1] "2016-08-17 00:00:00 IBM 200 @ 160.440002"
[1] "2016-08-25 00:00:00 IBM 100 @ 158.630005"
[1] "2016-09-07 00:00:00 IBM -100 @ 161.639999"
[1] "2016-09-12 00:00:00 IBM 100 @ 158.289993"
[1] "2016-09-14 00:00:00 IBM 100 @ 154.050003"
[1] "2016-09-29 00:00:00 IBM -200 @ 158.110001"
[1] "2016-10-19 00:00:00 IBM 100 @ 151.259995"
[1] "2016-10-24 00:00:00 IBM 100 @ 150.570007"
[1] "2016-10-31 00:00:00 IBM -200 @ 153.690002"
[1] "2016-11-11 00:00:00 IBM -100 @ 161.270004"
[1] "2016-12-02 00:00:00 IBM 100 @ 160.020004"
[1] "2016-12-09 00:00:00 IBM -100 @ 166.520004"
[1] "2016-12-14 00:00:00 IBM -100 @ 168.509995"
[1] "2017-01-03 00:00:00 IBM 200 @ 167.190002"
[1] "2017-01-09 00:00:00 IBM -100 @ 167.649994"
[1] "2017-01-11 00:00:00 IBM 100 @ 167.75"
[1] "2017-01-23 00:00:00 IBM -100 @ 171.029999"
[1] "2017-03-07 00:00:00 IBM 100 @ 180.380005"
[1] "2017-03-10 00:00:00 IBM 100 @ 177.830002"
[1] "2017-03-22 00:00:00 IBM 100 @ 174.779999"
[1] "2017-04-06 00:00:00 IBM -200 @ 172.449997"
[1] "2017-04-11 00:00:00 IBM 100 @ 170.580002"
[1] "2017-04-17 00:00:00 IBM 100 @ 171.100006"
[1] "2017-06-02 00:00:00 IBM -200 @ 152.050003"
[1] "2017-06-12 00:00:00 IBM -100 @ 155.179993"
[1] "2017-06-19 00:00:00 IBM -100 @ 154.839996"
[1] "2017-06-30 00:00:00 IBM 200 @ 153.830002"
[1] "2017-07-07 00:00:00 IBM 100 @ 152.940002"
[1] "2017-07-13 00:00:00 IBM -100 @ 153.630005"
[1] "2017-07-20 00:00:00 IBM 100 @ 147.660004"
[1] "2017-08-21 00:00:00 IBM 100 @ 140.330002"
[1] "2017-08-24 00:00:00 IBM -200 @ 142.940002"
[1] "2017-09-13 00:00:00 IBM -100 @ 145.990005"
[1] "2017-09-29 00:00:00 IBM 100 @ 145.080002"
[1] "2017-10-10 00:00:00 IBM -100 @ 148.5"
[1] "2017-10-18 00:00:00 IBM 100 @ 159.529999"
[1] "2017-10-19 00:00:00 IBM -100 @ 160.899994"
[1] "2017-11-06 00:00:00 IBM 100 @ 150.839996"
[1] "2017-12-04 00:00:00 IBM -100 @ 156.460007"
[1] "2017-12-18 00:00:00 IBM 100 @ 153.330002"
[1] "2018-01-04 00:00:00 IBM -100 @ 161.699997"
[1] "2018-01-31 00:00:00 IBM 100 @ 163.699997"
[1] "2018-02-05 00:00:00 IBM 100 @ 152.529999"
[1] "2018-02-27 00:00:00 IBM -100 @ 156.550003"
[1] "2018-03-13 00:00:00 IBM -100 @ 159.320007"
[1] "2018-03-20 00:00:00 IBM 100 @ 156.199997"
[1] "2018-03-23 00:00:00 IBM 100 @ 148.889999"
[1] "2018-04-11 00:00:00 IBM -100 @ 155.360001"
[1] "2018-04-18 00:00:00 IBM -100 @ 148.789993"
[1] "2018-04-19 00:00:00 IBM 100 @ 147.699997"
[1] "2018-04-23 00:00:00 IBM 100 @ 145.860001"
[1] "2018-05-17 00:00:00 IBM -100 @ 144.5"
[1] "2018-05-30 00:00:00 IBM 100 @ 142.619995"
[1] "2018-06-06 00:00:00 IBM -100 @ 144.710007"
[1] "2018-06-26 00:00:00 IBM 100 @ 139.080002"
[1] "2018-06-28 00:00:00 IBM 100 @ 140.039993"
[1] "2018-07-09 00:00:00 IBM -200 @ 144.389999"
[1] "2018-07-20 00:00:00 IBM -100 @ 146.350006"
[1] "2018-07-31 00:00:00 IBM 100 @ 144.929993"
[1] "2018-09-14 00:00:00 IBM -100 @ 148.330002"
[1] "2018-09-20 00:00:00 IBM -100 @ 151.149994"
[1] "2018-10-08 00:00:00 IBM 200 @ 148.389999"
[1] "2018-10-11 00:00:00 IBM 100 @ 139.020004"
[1] "2018-10-18 00:00:00 IBM 100 @ 130.550003"
[1] "2018-11-20 00:00:00 IBM -200 @ 117.199997"
[1] "2018-12-18 00:00:00 IBM 100 @ 116.650002"
[1] "2018-12-21 00:00:00 IBM 100 @ 110.940002"
[1] "2019-01-07 00:00:00 IBM -200 @ 118.150002"
[1] "2019-01-24 00:00:00 IBM -100 @ 132.529999"
[1] "2019-03-07 00:00:00 IBM 100 @ 135.360001"
[1] "2019-04-02 00:00:00 IBM -100 @ 143"
[1] "2019-04-18 00:00:00 IBM 100 @ 140.330002"
[1] "2019-05-10 00:00:00 IBM 100 @ 135.320007"
[1] "2019-05-14 00:00:00 IBM 100 @ 133.309998"
[1] "2019-06-06 00:00:00 IBM -200 @ 132.220001"
[1] "2019-07-16 00:00:00 IBM -100 @ 143.529999"
[1] "2019-07-19 00:00:00 IBM -100 @ 149.679993"
[1] "2019-08-05 00:00:00 IBM 200 @ 140.759995"
[1] "2019-08-12 00:00:00 IBM 100 @ 133.669998"
[1] "2019-08-15 00:00:00 IBM 100 @ 131.919998"
[1] "2019-08-30 00:00:00 IBM -200 @ 135.529999"
[1] "2019-09-06 00:00:00 IBM -100 @ 140.570007"
[1] "2019-10-03 00:00:00 IBM 100 @ 142.020004"
[1] "2019-10-09 00:00:00 IBM 100 @ 139.669998"
[1] "2019-10-14 00:00:00 IBM -100 @ 142.039993"
[1] "2019-10-18 00:00:00 IBM 100 @ 134.089996"

> # look at the order book
> #getOrderBook('bbands')
> end_t<-Sys.time()

> print("strat execution time:")
[1] "strat execution time:"

> print(end_t-start_t)
Time difference of 4.697281 secs

> start_t<-Sys.time()

> updatePortf(Portfolio='bbands',Dates=paste('::',as.Date(Sys.time()),sep=''))
[1] "bbands"

> end_t<-Sys.time()

> print("updatePortf execution time:")
[1] "updatePortf execution time:"

> print(end_t-start_t)
Time difference of 0.04851031 secs

> chart.Posn(Portfolio='bbands',Symbol=stock.str)

> plot(add_BBands(on=1,sd=SD,n=N))

> ###############################################################################
> # R (http://r-project.org/) Quantitative Strategy Model Framework
> #
> # Copyright (c) 2009-2012
> # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich 
> #
> # This library is distributed under the terms of the GNU Public License (GPL)
> # for full details see the file COPYING
> #
> # $Id$
> #
> ###############################################################################
Warning message:
In .updatePosPL(Portfolio = pname, Symbol = as.character(symbol),  :
  Could not parse ::2019-10-28 as ISO8601 string, or one/bothends of the range were outside the available prices: 2007-01-03/2019-10-25. Using all data instead.
> strategy.st='bbands'
> 
> ### User Set up pf parameter ranges to test
> .nlist  = 10:40
> .sdlist = 1:4
> 
> # number of random samples of the parameter distribution to use for random run
> .nsamples = 10 
> 
> add.distribution(strategy.st,
+                  paramset.label = 'BBparams',
+                  component.type = 'indicator',
+                  component.label = 'BBands', #this is the label given to the indicator in the strat
+                  variable = list(n = .nlist),
+                  label = 'nFAST'
+ )
[1] "bbands"
> 
> add.distribution(strategy.st,
+                  paramset.label = 'BBparams',
+                  component.type = 'indicator',
+                  component.label = 'BBands', #this is the label given to the indicator in the strat
+                  variable = list(sd = .sdlist),
+                  label = 'nSLOW'
+ )
[1] "bbands"
> 
> 
> results <- apply.paramset(strategy.st, 
+                           paramset.label='BBparams', 
+                           portfolio.st=portfolio.st, 
+                           account.st=account.st, 
+                           nsamples=.nsamples, 
+                           verbose=TRUE)
numValues: 10, numResults: 0, stopped: TRUE
got results for task 1
numValues: 10, numResults: 1, stopped: TRUE
returning status FALSE
got results for task 2
numValues: 10, numResults: 2, stopped: TRUE
returning status FALSE
got results for task 3
numValues: 10, numResults: 3, stopped: TRUE
returning status FALSE
got results for task 4
numValues: 10, numResults: 4, stopped: TRUE
returning status FALSE
got results for task 5
numValues: 10, numResults: 5, stopped: TRUE
returning status FALSE
got results for task 6
numValues: 10, numResults: 6, stopped: TRUE
returning status FALSE
got results for task 7
numValues: 10, numResults: 7, stopped: TRUE
returning status FALSE
got results for task 8
numValues: 10, numResults: 8, stopped: TRUE
returning status FALSE
got results for task 9
numValues: 10, numResults: 9, stopped: TRUE
returning status FALSE
got results for task 10
numValues: 10, numResults: 10, stopped: TRUE
first call to combine function
evaluating call object to combine results:
  fun(result.1, result.2, result.3, result.4, result.5, result.6, 
    result.7, result.8, result.9, result.10)
returning status TRUE
> 
> stats <- results$tradeStats
> 
> print(stats)
NULL
> 
> 
> 
> ##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
> # book  = getOrderBook(port)
> # stats = tradeStats(port)
> # rets  = PortfReturns(acct)
> ################################################################
> 
> ###############################################################################
> # R (http://r-project.org/) Quantitative Strategy Model Framework
> #
> # Copyright (c) 2009-2012
> # Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich 
> #
> # This library is distributed under the terms of the GNU Public License (GPL)
> # for full details see the file COPYING
> #
> # $Id: bbands.R 1097 2012-07-01 00:30:39Z braverock $
> #
> ###############################################################################
> print(results)
<environment: 0x7f15cd51f788>
> print(results$error)
[[1]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[2]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[3]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[4]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[5]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[6]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[7]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[8]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[9]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>

[[10]]
<simpleError in mget(symbols, Portfolio$symbols): second argument must be an environment>
jaymon0703 commented 5 years ago

Hi @SamoPP some regression was introduced with blotter v 0.14.6 which i was sure was resolved in 0.14.7 but apparently not. If you use blotter v 0.14.5 the demo and all WFA and apply.paramset functionality will work as expected. You can use devtools::install_github("braverock/blotter", ref = "62e9edbae98e297b280d46e838da088e30b64118") to install version 0.14.5. Please let me know if that works?

jaymon0703 commented 5 years ago

hi @SamoPP please confirm if downgrading your blotter version to 0.14.5 works for you resolves your bbandsParameters error?

SamoPP commented 5 years ago

I confirm that downgrading blotter resolves the error.

jaymon0703 commented 5 years ago

Thanks for confirming @SamoPP. This is still an issue, but the root cause is in blotter. I will create a separate issue in blotter with a link to this one in quantstrat.

jaymon0703 commented 4 years ago

FYI @braverock. Closing this and will create issue in blotter, linking back to this item for more info and how to reproduce the issue.

EDIT: link to issue in blotter project - https://github.com/braverock/blotter/issues/102