Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for Software 20.04.
Download
132 views
ubuntu2004-dev
Kernel: R (system-wide)

Quantstrat on CoCalc

https://github.com/braverock/quantstrat

Example below is a random one taken from their demo folder...

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') stock(stock.str,currency='USD',multiplier=1) startDate='2006-12-31' initEq=1000000 portfolio.st='bbands' account.st='bbands' initPortf(portfolio.st, symbols=stock.str) initAcct(account.st,portfolios='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') #add signals: add.signal(strategy = strat.st, name="sigCrossover", arguments = list(columns=c("Close","up"), relationship="gt"), label="Cl.gt.UpperBand") add.signal(strategy = strat.st, name="sigCrossover", arguments = list(columns=c("Close","dn"), relationship="lt"), label="Cl.lt.LowerBand") add.signal(strategy = strat.st,name="sigCrossover", arguments = list(columns=c("High","Low","mavg"), relationship="op"), label="Cross.Mid") # 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') 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') 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') #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') start_t<-Sys.time() out<-try(applyStrategy(strategy='bbands' , portfolios='bbands',parameters=list(sd=SD,n=N)) ) # look at the order book #getOrderBook('bbands') end_t<-Sys.time() print("strat execution time:") print(end_t-start_t) start_t<-Sys.time() updatePortf(Portfolio='bbands',Dates=paste('::',as.Date(Sys.time()),sep='')) end_t<-Sys.time() print("updatePortf execution time:") print(end_t-start_t) chart.Posn(Portfolio='bbands',Symbol=stock.str) plot(add_BBands(on=1,sd=SD,n=N))
Loading required package: quantstrat Loading required package: quantmod Loading required package: xts Loading required package: zoo Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric Loading required package: TTR Registered S3 method overwritten by 'quantmod': method from as.zoo.data.frame zoo Loading required package: blotter Loading required package: FinancialInstrument Loading required package: PerformanceAnalytics Attaching package: ‘PerformanceAnalytics’ The following object is masked from ‘package:graphics’: legend Loading required package: foreach
[1] "USD"
[1] "IBM"
[1] "bbands"
[1] "bbands"
[1] "bbands"
[1] "bbands"
[1] "bbands"
[1] "bbands"
[1] "bbands"
[1] "bbands"
[1] "bbands"
‘getSymbols’ currently uses auto.assign=TRUE by default, but will use auto.assign=FALSE in 0.5-0. You will still be able to use ‘loadSymbols’ to automatically load data. getOption("getSymbols.env") and getOption("getSymbols.auto.assign") will still be checked for alternate defaults. This message is shown once per session and may be disabled by setting options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
[1] "IBM"
[1] "2007-02-27 00:00:00 IBM 100 @ 89.827919" [1] "2007-03-21 00:00:00 IBM -100 @ 91.166351" [1] "2007-04-04 00:00:00 IBM -100 @ 91.978966" [1] "2007-04-13 00:00:00 IBM 100 @ 90.755257" [1] "2007-04-18 00:00:00 IBM -100 @ 90.630974" [1] "2007-04-19 00:00:00 IBM 100 @ 90.143402" [1] "2007-04-25 00:00:00 IBM -100 @ 96.998085" [1] "2007-05-25 00:00:00 IBM 100 @ 100.554497" [1] "2007-06-07 00:00:00 IBM 100 @ 97.323135" [1] "2007-06-18 00:00:00 IBM -100 @ 100.697899" [1] "2007-07-06 00:00:00 IBM -100 @ 104.235184" [1] "2007-07-18 00:00:00 IBM -100 @ 106.19503" [1] "2007-08-01 00:00:00 IBM 200 @ 107.112808" [1] "2007-08-31 00:00:00 IBM -100 @ 111.558319" [1] "2007-09-18 00:00:00 IBM 100 @ 111.500954" [1] "2007-10-02 00:00:00 IBM -100 @ 113.154877" [1] "2007-10-04 00:00:00 IBM 100 @ 110.602295" [1] "2007-10-17 00:00:00 IBM -100 @ 110.688339" [1] "2007-10-18 00:00:00 IBM 100 @ 109.751434" [1] "2007-10-19 00:00:00 IBM 100 @ 107.342255" [1] "2007-11-01 00:00:00 IBM -100 @ 108.652008" [1] "2007-11-09 00:00:00 IBM 100 @ 95.841301" [1] "2007-11-29 00:00:00 IBM -100 @ 102.772469" [1] "2007-12-07 00:00:00 IBM -100 @ 104.072655" [1] "2007-12-17 00:00:00 IBM 100 @ 99.933075" [1] "2007-12-24 00:00:00 IBM -100 @ 106.73996" [1] "2008-01-02 00:00:00 IBM 100 @ 100.086044" [1] "2008-01-07 00:00:00 IBM 100 @ 95.650093" [1] "2008-01-15 00:00:00 IBM -100 @ 97.351814" [1] "2008-02-04 00:00:00 IBM -100 @ 103.183556" [1] "2008-02-07 00:00:00 IBM 100 @ 97.839386" [1] "2008-02-26 00:00:00 IBM -100 @ 109.349907" [1] "2008-03-27 00:00:00 IBM 100 @ 110.439774" [1] "2008-04-11 00:00:00 IBM -100 @ 110.898659" [1] "2008-04-14 00:00:00 IBM 100 @ 112.122368" [1] "2008-04-17 00:00:00 IBM -100 @ 117.667305" [1] "2008-05-07 00:00:00 IBM 100 @ 118.680687" [1] "2008-05-14 00:00:00 IBM -100 @ 121.912048" [1] "2008-05-22 00:00:00 IBM 100 @ 119.216064" [1] "2008-05-29 00:00:00 IBM -100 @ 124.005737" [1] "2008-06-05 00:00:00 IBM 100 @ 122.820267" [1] "2008-06-12 00:00:00 IBM 100 @ 118.403442" [1] "2008-06-16 00:00:00 IBM -100 @ 121.137665" [1] "2008-06-27 00:00:00 IBM 100 @ 114.770554" [1] "2008-07-09 00:00:00 IBM -100 @ 115.105164" [1] "2008-07-17 00:00:00 IBM -100 @ 120.956024" [1] "2008-08-12 00:00:00 IBM 100 @ 119.713196" [1] "2008-08-13 00:00:00 IBM 100 @ 120.267685" [1] "2008-08-15 00:00:00 IBM -100 @ 120.803062" [1] "2008-08-19 00:00:00 IBM 100 @ 117.170174" [1] "2008-09-03 00:00:00 IBM 100 @ 113.135757" [1] "2008-09-22 00:00:00 IBM -200 @ 111.099426" [1] "2008-10-02 00:00:00 IBM 100 @ 100.133842" [1] "2008-10-31 00:00:00 IBM -100 @ 88.881454" [1] "2008-11-21 00:00:00 IBM 100 @ 71.586998" [1] "2008-12-04 00:00:00 IBM -100 @ 74.034416" [1] "2008-12-17 00:00:00 IBM -100 @ 82.06501" [1] "2008-12-23 00:00:00 IBM 100 @ 77.05545" [1] "2009-01-05 00:00:00 IBM -100 @ 83.001915" [1] "2009-01-07 00:00:00 IBM -100 @ 83.929253" [1] "2009-01-15 00:00:00 IBM 200 @ 80.420647" [1] "2009-01-22 00:00:00 IBM -100 @ 86.108986" [1] "2009-01-27 00:00:00 IBM -100 @ 87.629066" [1] "2009-02-18 00:00:00 IBM 200 @ 87.485657" [1] "2009-02-24 00:00:00 IBM 100 @ 82.60038" [1] "2009-03-02 00:00:00 IBM -100 @ 85.133842" [1] "2009-03-24 00:00:00 IBM -100 @ 93.977058" [1] "2009-04-16 00:00:00 IBM 100 @ 96.969406" [1] "2009-04-30 00:00:00 IBM -100 @ 98.671127" [1] "2009-05-04 00:00:00 IBM -100 @ 101.520073" [1] "2009-05-08 00:00:00 IBM 200 @ 97.026772" [1] "2009-06-02 00:00:00 IBM -100 @ 102.131927" [1] "2009-06-19 00:00:00 IBM 100 @ 101.233269" [1] "2009-07-06 00:00:00 IBM 100 @ 97.179733" [1] "2009-07-16 00:00:00 IBM -100 @ 105.774376" [1] "2009-07-17 00:00:00 IBM -100 @ 110.34417" [1] "2009-08-17 00:00:00 IBM 100 @ 111.72084" [1] "2009-09-02 00:00:00 IBM 100 @ 110.984703" [1] "2009-09-09 00:00:00 IBM -100 @ 111.625237" [1] "2009-09-17 00:00:00 IBM -100 @ 116.520073" [1] "2009-09-29 00:00:00 IBM 100 @ 113.585083" [1] "2009-10-12 00:00:00 IBM -100 @ 121.453156" [1] "2009-10-19 00:00:00 IBM 100 @ 117.648186" [1] "2009-11-12 00:00:00 IBM -100 @ 120.707458" [1] "2009-11-17 00:00:00 IBM -100 @ 122.973228" [1] "2009-11-30 00:00:00 IBM 200 @ 120.793503" [1] "2009-12-11 00:00:00 IBM -100 @ 123.977058" [1] "2009-12-18 00:00:00 IBM 100 @ 122.284897" [1] "2009-12-29 00:00:00 IBM -100 @ 126.051628" [1] "2010-01-08 00:00:00 IBM 100 @ 125.095604" [1] "2010-01-20 00:00:00 IBM -100 @ 124.521988" [1] "2010-01-21 00:00:00 IBM 100 @ 123.326958" [1] "2010-01-25 00:00:00 IBM 100 @ 120.573616" [1] "2010-01-29 00:00:00 IBM 100 @ 117.007645" [1] "2010-02-18 00:00:00 IBM -200 @ 122.189293" [1] "2010-03-17 00:00:00 IBM -100 @ 122.141495" [1] "2010-03-22 00:00:00 IBM 100 @ 122.351814" [1] "2010-03-24 00:00:00 IBM -100 @ 122.877632" [1] "2010-04-01 00:00:00 IBM 100 @ 122.60994" [1] "2010-04-15 00:00:00 IBM -100 @ 125.133842" [1] "2010-04-20 00:00:00 IBM -100 @ 123.986618" [1] "2010-04-21 00:00:00 IBM 200 @ 123.317398" [1] "2010-05-07 00:00:00 IBM 100 @ 116.7304" [1] "2010-05-13 00:00:00 IBM -100 @ 125.697899" [1] "2010-06-17 00:00:00 IBM -100 @ 125.219887" [1] "2010-06-28 00:00:00 IBM 100 @ 123.307838" [1] "2010-08-25 00:00:00 IBM 100 @ 119.760994" [1] "2010-08-27 00:00:00 IBM 100 @ 119.244743" [1] "2010-09-07 00:00:00 IBM -200 @ 120.411087" [1] "2010-09-21 00:00:00 IBM -100 @ 126.175911" [1] "2010-10-20 00:00:00 IBM 100 @ 132.954117" [1] "2010-11-01 00:00:00 IBM -100 @ 137.017212" [1] "2010-11-17 00:00:00 IBM 100 @ 135.707458" [1] "2010-12-01 00:00:00 IBM 100 @ 138.05928" [1] "2010-12-02 00:00:00 IBM -100 @ 138.79541" [1] "2010-12-30 00:00:00 IBM -100 @ 140.219879" [1] "2011-01-07 00:00:00 IBM -100 @ 141.424469" [1] "2011-02-23 00:00:00 IBM 200 @ 153.135757" [1] "2011-03-02 00:00:00 IBM 100 @ 153.116638" [1] "2011-03-04 00:00:00 IBM -100 @ 154.713196" [1] "2011-03-10 00:00:00 IBM -100 @ 154.894836" [1] "2011-03-11 00:00:00 IBM 100 @ 155.286804" [1] "2011-03-17 00:00:00 IBM 100 @ 147.399612" [1] "2011-03-25 00:00:00 IBM -100 @ 155.047806" [1] "2011-04-25 00:00:00 IBM -100 @ 160.296371" [1] "2011-05-03 00:00:00 IBM -100 @ 165.267685" [1] "2011-05-12 00:00:00 IBM 200 @ 164.66539" [1] "2011-06-02 00:00:00 IBM 100 @ 158.785858" [1] "2011-06-21 00:00:00 IBM -100 @ 158.910141" [1] "2011-06-29 00:00:00 IBM -100 @ 163.040146" [1] "2011-07-20 00:00:00 IBM -100 @ 175.573608" [1] "2011-08-02 00:00:00 IBM 200 @ 170.219879" [1] "2011-08-09 00:00:00 IBM 100 @ 163.107071" [1] "2011-08-11 00:00:00 IBM 100 @ 159.397705" [1] "2011-08-29 00:00:00 IBM -200 @ 165.028687" [1] "2011-10-11 00:00:00 IBM -100 @ 176.864243" [1] "2011-10-17 00:00:00 IBM -100 @ 178.384323" [1] "2011-10-19 00:00:00 IBM 200 @ 169.588913" [1] "2011-11-25 00:00:00 IBM 100 @ 169.273422" [1] "2011-12-01 00:00:00 IBM -100 @ 181.118546" [1] "2012-01-23 00:00:00 IBM -100 @ 181.625244" [1] "2012-02-16 00:00:00 IBM 100 @ 184.531555" [1] "2012-02-24 00:00:00 IBM -100 @ 189.063095" [1] "2012-03-06 00:00:00 IBM -100 @ 188.585083" [1] "2012-04-05 00:00:00 IBM 200 @ 196.434036" [1] "2012-04-11 00:00:00 IBM 100 @ 193.671127" [1] "2012-04-17 00:00:00 IBM -100 @ 198.326965" [1] "2012-04-19 00:00:00 IBM 100 @ 190.736145" [1] "2012-04-27 00:00:00 IBM -100 @ 197.715103" [1] "2012-06-04 00:00:00 IBM 100 @ 180.248566" [1] "2012-06-08 00:00:00 IBM -100 @ 186.558319" [1] "2012-07-11 00:00:00 IBM 100 @ 177.103256" [1] "2012-07-20 00:00:00 IBM -100 @ 183.986618" [1] "2012-08-31 00:00:00 IBM 100 @ 186.281067" [1] "2012-09-07 00:00:00 IBM -100 @ 190.726578" [1] "2012-09-12 00:00:00 IBM -100 @ 194.808792" [1] "2012-10-11 00:00:00 IBM 100 @ 196.711288" [1] "2012-10-18 00:00:00 IBM 100 @ 186.38623" [1] "2012-11-26 00:00:00 IBM -100 @ 184.397705" [1] "2012-12-19 00:00:00 IBM -100 @ 186.500961" [1] "2012-12-24 00:00:00 IBM 100 @ 183.938812" [1] "2013-01-03 00:00:00 IBM -100 @ 186.682602" [1] "2013-01-07 00:00:00 IBM 100 @ 184.646271" [1] "2013-01-23 00:00:00 IBM -100 @ 195.71701" [1] "2013-02-08 00:00:00 IBM 100 @ 192.810699" [1] "2013-03-05 00:00:00 IBM -100 @ 197.447418" [1] "2013-03-15 00:00:00 IBM -100 @ 205.468445" [1] "2013-03-28 00:00:00 IBM 200 @ 203.919693" [1] "2013-04-19 00:00:00 IBM 100 @ 181.644363" [1] "2013-05-06 00:00:00 IBM -100 @ 193.862335" [1] "2013-06-13 00:00:00 IBM 100 @ 194.808792" [1] "2013-06-19 00:00:00 IBM -100 @ 193.05928" [1] "2013-06-21 00:00:00 IBM 100 @ 186.864243" [1] "2013-07-01 00:00:00 IBM 100 @ 182.868073" [1] "2013-07-18 00:00:00 IBM -200 @ 189.28299" [1] "2013-08-07 00:00:00 IBM 100 @ 180.267685" [1] "2013-09-10 00:00:00 IBM -100 @ 178.393875" [1] "2013-09-12 00:00:00 IBM -100 @ 182.342255" [1] "2013-09-19 00:00:00 IBM -100 @ 184.885284" [1] "2013-09-30 00:00:00 IBM 200 @ 177.036331" [1] "2013-10-08 00:00:00 IBM 100 @ 170.860428" [1] "2013-10-17 00:00:00 IBM -100 @ 167.141495" [1] "2013-10-18 00:00:00 IBM 100 @ 166.137665" [1] "2013-10-30 00:00:00 IBM -100 @ 172.227539" [1] "2013-12-24 00:00:00 IBM -100 @ 175.162521" [1] "2014-01-15 00:00:00 IBM 100 @ 179.483749" [1] "2014-01-27 00:00:00 IBM 100 @ 170.076477" [1] "2014-02-04 00:00:00 IBM 100 @ 165.238998" [1] "2014-02-12 00:00:00 IBM -200 @ 172.313583" [1] "2014-03-26 00:00:00 IBM -100 @ 184.149139" [1] "2014-04-02 00:00:00 IBM -100 @ 185.038239" [1] "2014-04-21 00:00:00 IBM 200 @ 183.814529" [1] "2014-05-16 00:00:00 IBM 100 @ 178.833649" [1] "2014-05-21 00:00:00 IBM 100 @ 178.193115" [1] "2014-06-09 00:00:00 IBM -200 @ 178.030594" [1] "2014-06-12 00:00:00 IBM 100 @ 173.250473" [1] "2014-06-20 00:00:00 IBM -100 @ 173.565964" [1] "2014-07-03 00:00:00 IBM -100 @ 180.238998" [1] "2014-07-17 00:00:00 IBM -100 @ 184.024857" [1] "2014-08-04 00:00:00 IBM 200 @ 181.300186" [1] "2014-08-08 00:00:00 IBM 100 @ 178.422562" [1] "2014-08-20 00:00:00 IBM -100 @ 181.73996" [1] "2014-09-19 00:00:00 IBM -100 @ 185.468445" [1] "2014-09-24 00:00:00 IBM 100 @ 183.852768" [1] "2014-09-26 00:00:00 IBM 100 @ 181.701721" [1] "2014-10-02 00:00:00 IBM 100 @ 178.690247" [1] "2014-11-17 00:00:00 IBM -200 @ 156.94072" [1] "2014-11-21 00:00:00 IBM 100 @ 153.843216" [1] "2014-11-25 00:00:00 IBM -100 @ 154.646271" [1] "2014-12-04 00:00:00 IBM -100 @ 156.835571" [1] "2014-12-09 00:00:00 IBM 100 @ 155.822174" [1] "2014-12-11 00:00:00 IBM 100 @ 153.986618" [1] "2014-12-15 00:00:00 IBM 100 @ 146.328873" [1] "2014-12-22 00:00:00 IBM -200 @ 154.340347" [1] "2015-01-22 00:00:00 IBM 100 @ 148.556412" [1] "2015-01-27 00:00:00 IBM -100 @ 146.912048" [1] "2015-01-29 00:00:00 IBM 100 @ 148.642441" [1] "2015-02-04 00:00:00 IBM -100 @ 150.057358" [1] "2015-02-17 00:00:00 IBM -100 @ 153.881454" [1] "2015-03-03 00:00:00 IBM 100 @ 153.94838" [1] "2015-03-12 00:00:00 IBM 100 @ 151.032501" [1] "2015-03-16 00:00:00 IBM 100 @ 150.172089" [1] "2015-03-19 00:00:00 IBM -200 @ 152.782028" [1] "2015-04-21 00:00:00 IBM -100 @ 157.036331" [1] "2015-04-24 00:00:00 IBM -100 @ 162.313583" [1] "2015-05-13 00:00:00 IBM 200 @ 164.703629" [1] "2015-05-27 00:00:00 IBM 100 @ 164.435944" [1] "2015-06-01 00:00:00 IBM 100 @ 162.695984" [1] "2015-06-24 00:00:00 IBM -200 @ 159.627151" [1] "2015-06-30 00:00:00 IBM 100 @ 155.506699" [1] "2015-07-13 00:00:00 IBM -100 @ 161.931168" [1] "2015-07-17 00:00:00 IBM -100 @ 164.923523" [1] "2015-07-22 00:00:00 IBM 100 @ 153.298279" [1] "2015-08-24 00:00:00 IBM 100 @ 137.160614" [1] "2015-09-16 00:00:00 IBM -100 @ 141.883362" [1] "2015-09-29 00:00:00 IBM 100 @ 136.20459" [1] "2015-10-01 00:00:00 IBM -100 @ 137.27533" [1] "2015-10-08 00:00:00 IBM -100 @ 145.583176" [1] "2015-10-21 00:00:00 IBM 100 @ 134.722748" [1] "2015-10-28 00:00:00 IBM 100 @ 134.636703" [1] "2015-11-16 00:00:00 IBM 100 @ 127.829826" [1] "2015-11-23 00:00:00 IBM -200 @ 132.370941" [1] "2015-12-21 00:00:00 IBM 100 @ 129.541107" [1] "2015-12-23 00:00:00 IBM -100 @ 132.447418" [1] "2016-01-08 00:00:00 IBM 100 @ 125.841301" [1] "2016-01-14 00:00:00 IBM 100 @ 127.06501" [1] "2016-02-05 00:00:00 IBM -200 @ 122.915871" [1] "2016-02-19 00:00:00 IBM -100 @ 127.227531" [1] "2016-03-18 00:00:00 IBM -100 @ 140.621414" [1] "2016-04-20 00:00:00 IBM 100 @ 139.684509" [1] "2016-04-22 00:00:00 IBM 100 @ 141.969406" [1] "2016-05-26 00:00:00 IBM -100 @ 145.736145" [1] "2016-06-14 00:00:00 IBM 100 @ 144.416824" [1] "2016-06-24 00:00:00 IBM -100 @ 140.143402" [1] "2016-06-27 00:00:00 IBM 100 @ 137.189301" [1] "2016-07-15 00:00:00 IBM -100 @ 152.753342" [1] "2016-08-12 00:00:00 IBM -100 @ 154.827911" [1] "2016-08-17 00:00:00 IBM 200 @ 153.384323" [1] "2016-08-25 00:00:00 IBM 100 @ 151.653915" [1] "2016-09-07 00:00:00 IBM -100 @ 154.531555" [1] "2016-09-12 00:00:00 IBM 100 @ 151.328873" [1] "2016-09-14 00:00:00 IBM 100 @ 147.27533" [1] "2016-09-29 00:00:00 IBM -200 @ 151.156784" [1] "2016-10-19 00:00:00 IBM 100 @ 144.608032" [1] "2016-10-24 00:00:00 IBM 100 @ 143.94838" [1] "2016-10-31 00:00:00 IBM -200 @ 146.931168" [1] "2016-11-11 00:00:00 IBM -100 @ 154.177826" [1] "2016-12-02 00:00:00 IBM 100 @ 152.982788" [1] "2016-12-09 00:00:00 IBM -100 @ 159.196945" [1] "2016-12-14 00:00:00 IBM -100 @ 161.099426" [1] "2017-01-03 00:00:00 IBM 200 @ 159.837479" [1] "2017-01-09 00:00:00 IBM -100 @ 160.277252" [1] "2017-01-11 00:00:00 IBM 100 @ 160.372849" [1] "2017-01-23 00:00:00 IBM -100 @ 163.508606" [1] "2017-03-07 00:00:00 IBM 100 @ 172.447418" [1] "2017-03-10 00:00:00 IBM 100 @ 170.009567" [1] "2017-03-22 00:00:00 IBM 100 @ 167.093689" [1] "2017-04-06 00:00:00 IBM -200 @ 164.86615" [1] "2017-04-11 00:00:00 IBM 100 @ 163.0784" [1] "2017-04-17 00:00:00 IBM 100 @ 163.575531" [1] "2017-06-02 00:00:00 IBM -200 @ 145.363297" [1] "2017-06-12 00:00:00 IBM -100 @ 148.355637" [1] "2017-06-19 00:00:00 IBM -100 @ 148.030594" [1] "2017-06-30 00:00:00 IBM 200 @ 147.065002" [1] "2017-07-07 00:00:00 IBM 100 @ 146.214142" [1] "2017-07-13 00:00:00 IBM -100 @ 146.87381" [1] "2017-07-20 00:00:00 IBM 100 @ 141.166351" [1] "2017-08-21 00:00:00 IBM 100 @ 134.158707" [1] "2017-08-24 00:00:00 IBM -200 @ 136.653915" [1] "2017-09-13 00:00:00 IBM -100 @ 139.569794" [1] "2017-09-29 00:00:00 IBM 100 @ 138.699814" [1] "2017-10-10 00:00:00 IBM -100 @ 141.969406" [1] "2017-10-18 00:00:00 IBM 100 @ 152.514343" [1] "2017-10-19 00:00:00 IBM -100 @ 153.824097" [1] "2017-11-06 00:00:00 IBM 100 @ 144.206497" [1] "2017-12-04 00:00:00 IBM -100 @ 149.579346" [1] "2017-12-18 00:00:00 IBM 100 @ 146.587006" [1] "2018-01-04 00:00:00 IBM -100 @ 154.588913" [1] "2018-01-31 00:00:00 IBM 100 @ 156.500961" [1] "2018-02-05 00:00:00 IBM 100 @ 145.822174" [1] "2018-02-27 00:00:00 IBM -100 @ 149.66539" [1] "2018-03-13 00:00:00 IBM -100 @ 152.313583" [1] "2018-03-20 00:00:00 IBM 100 @ 149.33078" [1] "2018-03-23 00:00:00 IBM 100 @ 142.342255" [1] "2018-04-11 00:00:00 IBM -100 @ 148.527725" [1] "2018-04-18 00:00:00 IBM -100 @ 142.246658" [1] "2018-04-19 00:00:00 IBM 100 @ 141.20459" [1] "2018-04-23 00:00:00 IBM 100 @ 139.445511" [1] "2018-05-17 00:00:00 IBM -100 @ 138.145309" [1] "2018-05-30 00:00:00 IBM 100 @ 136.347992" [1] "2018-06-06 00:00:00 IBM -100 @ 138.346085" [1] "2018-06-26 00:00:00 IBM 100 @ 132.963669" [1] "2018-06-28 00:00:00 IBM 100 @ 133.881454" [1] "2018-07-09 00:00:00 IBM -200 @ 138.040146" [1] "2018-07-20 00:00:00 IBM -100 @ 139.913956" [1] "2018-07-31 00:00:00 IBM 100 @ 138.556412" [1] "2018-09-14 00:00:00 IBM -100 @ 141.806885" [1] "2018-09-20 00:00:00 IBM -100 @ 144.502869" [1] "2018-10-08 00:00:00 IBM 200 @ 141.864243" [1] "2018-10-11 00:00:00 IBM 100 @ 132.906311" [1] "2018-10-18 00:00:00 IBM 100 @ 124.808792" [1] "2018-11-20 00:00:00 IBM -200 @ 112.045891" [1] "2018-12-18 00:00:00 IBM 100 @ 111.520073" [1] "2018-12-21 00:00:00 IBM 100 @ 106.061188" [1] "2019-01-07 00:00:00 IBM -200 @ 112.954109" [1] "2019-01-24 00:00:00 IBM -100 @ 126.701721" [1] "2019-03-07 00:00:00 IBM 100 @ 129.407272" [1] "2019-04-02 00:00:00 IBM -100 @ 136.711288" [1] "2019-04-18 00:00:00 IBM 100 @ 134.158707" [1] "2019-05-10 00:00:00 IBM 100 @ 129.369019" [1] "2019-05-14 00:00:00 IBM 100 @ 127.447418" [1] "2019-06-06 00:00:00 IBM -200 @ 126.405357" [1] "2019-07-16 00:00:00 IBM -100 @ 137.217972" [1] "2019-07-19 00:00:00 IBM -100 @ 143.097519" [1] "2019-08-05 00:00:00 IBM 200 @ 134.569794" [1] "2019-08-12 00:00:00 IBM 100 @ 127.791588" [1] "2019-08-15 00:00:00 IBM 100 @ 126.118546" [1] "2019-08-30 00:00:00 IBM -200 @ 129.569794" [1] "2019-09-06 00:00:00 IBM -100 @ 134.388138" [1] "2019-10-03 00:00:00 IBM 100 @ 135.774384" [1] "2019-10-09 00:00:00 IBM 100 @ 133.527725" [1] "2019-10-14 00:00:00 IBM -100 @ 135.793503" [1] "2019-10-18 00:00:00 IBM 100 @ 128.193115" [1] "2019-11-05 00:00:00 IBM -100 @ 131.826004" [1] "2020-01-10 00:00:00 IBM -100 @ 130.678772" [1] "2020-01-17 00:00:00 IBM -100 @ 132.227539" [1] "2020-01-31 00:00:00 IBM 200 @ 137.40918" [1] "2020-02-04 00:00:00 IBM -100 @ 142.552582" [1] "2020-02-25 00:00:00 IBM 100 @ 135.478012" [1] "2020-02-28 00:00:00 IBM 100 @ 124.426384" [1] "2020-03-04 00:00:00 IBM 100 @ 128.317398" [1] "2020-03-31 00:00:00 IBM -200 @ 106.051628" [1] "2020-04-09 00:00:00 IBM -100 @ 116.156792" [1] "2020-04-22 00:00:00 IBM 100 @ 114.063095" [1] "2020-06-04 00:00:00 IBM -100 @ 123.221794" [1] "2020-06-08 00:00:00 IBM -100 @ 129.780121" [1] "2020-06-12 00:00:00 IBM 200 @ 116.548759" [1] "2020-07-20 00:00:00 IBM -100 @ 120.812622" [1] "2020-07-23 00:00:00 IBM -100 @ 121.7304" [1] "2020-07-31 00:00:00 IBM 200 @ 117.533463" [1] "2020-09-03 00:00:00 IBM -100 @ 118.977058" [1] "2020-09-09 00:00:00 IBM 100 @ 116.883362" [1] "2020-09-11 00:00:00 IBM 100 @ 116.118546" [1] "2020-09-17 00:00:00 IBM -100 @ 119.426384" [1] "2020-09-24 00:00:00 IBM 100 @ 112.896751" [1] "2020-09-29 00:00:00 IBM -100 @ 115.621414" [1] "2020-10-09 00:00:00 IBM -100 @ 122.170174" [1] "2020-10-21 00:00:00 IBM 100 @ 110" [1] "2020-10-22 00:00:00 IBM 100 @ 110.669212" [1] "2020-10-27 00:00:00 IBM 100 @ 105.697899" [1] "2020-11-10 00:00:00 IBM -200 @ 112.724663" [1] "2020-11-25 00:00:00 IBM -100 @ 118.738052" [1] "2020-12-22 00:00:00 IBM 100 @ 118.173996" [1] "2021-01-07 00:00:00 IBM -100 @ 123.317398" [1] "2021-01-25 00:00:00 IBM 100 @ 113.365204" [1] "2021-02-25 00:00:00 IBM -100 @ 117.084129" [1] "2021-03-01 00:00:00 IBM 100 @ 115.430206" [1] "2021-03-09 00:00:00 IBM -100 @ 118.718925" [1] "2021-03-11 00:00:00 IBM -100 @ 121.548759" [1] "2021-04-14 00:00:00 IBM 200 @ 126.797325" [1] "2021-04-21 00:00:00 IBM -100 @ 137.237091" [1] "2021-05-13 00:00:00 IBM 100 @ 137.829834" [1] "2021-06-07 00:00:00 IBM -100 @ 141.510513" [1] "2021-06-18 00:00:00 IBM 100 @ 136.826004" [1] "2021-07-06 00:00:00 IBM 100 @ 132.676865" [1] "2021-07-21 00:00:00 IBM -100 @ 135.086044" [1] "2021-08-04 00:00:00 IBM -100 @ 136.481842" [1] "2021-08-10 00:00:00 IBM 100 @ 135.162521" [1] "2021-08-19 00:00:00 IBM 100 @ 131.950287" [1] "2021-09-15 00:00:00 IBM 100 @ 131.166351" [1] "2021-09-27 00:00:00 IBM -200 @ 132.466537" [1] "2021-10-04 00:00:00 IBM -100 @ 137.772461" [1] "2021-10-20 00:00:00 IBM 100 @ 135.659653" [1] "2021-10-22 00:00:00 IBM 100 @ 122.25621" [1] "2021-11-19 00:00:00 IBM 100 @ 116.050003" [1] "2021-11-30 00:00:00 IBM -200 @ 117.099998" [1] "2021-12-09 00:00:00 IBM -100 @ 123.57" [1] "2021-12-20 00:00:00 IBM -100 @ 127.059998" [1] "2022-01-12 00:00:00 IBM 200 @ 133.589996" [1] "2022-02-18 00:00:00 IBM 100 @ 124.349998" [1] "2022-03-08 00:00:00 IBM -100 @ 125.68" [1] "2022-03-21 00:00:00 IBM -100 @ 128.100006" [1] "2022-03-28 00:00:00 IBM -100 @ 131.470001" [1] "2022-04-07 00:00:00 IBM 200 @ 128.550003" [1] "strat execution time:" Time difference of 7.539834 secs
Warning message in .updatePosPL(Portfolio = pname, Symbol = as.character(symbol), : “Could not parse ::2022-04-11 as ISO8601 string, or one/bothends of the range were outside the available prices: 2007-01-03/2022-04-08. Using all data instead.”
[1] "bbands"
[1] "updatePortf execution time:" Time difference of 0.09082675 secs
Image in a Jupyter notebookImage in a Jupyter notebook