We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chart_Series() gives error running the basic example in quantstrat under R 4.3. Works ok in 4.2.
chart_Series()
Run error free in R 4.3
#From the example in https://github.com/braverock/quantstrat#readme library(FinancialInstrument) library(PerformanceAnalytics) library(quantstrat) stock.str='AAPL' # what are we trying it on currency('USD') stock(stock.str,currency='USD',multiplier=1) # startDate="1999-12-31" initEq=1000000 portfolio.st='macross' account.st='macross' initPortf(portfolio.st,symbols=stock.str) initAcct(account.st,portfolios=portfolio.st, initEq=initEq) initOrders(portfolio=portfolio.st) stratMACROSS<- strategy(portfolio.st) stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)), n=50),label= "ma50" ) stratMACROSS <- add.indicator(strategy = stratMACROSS, name = "SMA", arguments = list(x=quote(Cl(mktdata)[,1]), n=200),label= "ma200") stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(columns=c("ma50","ma200"), relationship="gte"),label="ma50.gt.ma200") stratMACROSS <- add.signal(strategy = stratMACROSS,name="sigCrossover",arguments = list(column=c("ma50","ma200"),relationship="lt"),label="ma50.lt.ma200") stratMACROSS <- add.rule(strategy = stratMACROSS,name='ruleSignal', arguments = list(sigcol="ma50.gt.ma200",sigval=TRUE, orderqty=100, ordertype='market', orderside='long'),type='enter') stratMACROSS <- add.rule(strategy = stratMACROSS,name='ruleSignal', arguments = list(sigcol="ma50.lt.ma200",sigval=TRUE, orderqty='all', ordertype='market', orderside='long'),type='exit') getSymbols(stock.str,from=startDate) for(i in stock.str) assign(i, adjustOHLC(get(i),use.Adjusted=TRUE)) start_t<-Sys.time() out<-applyStrategy(strategy=stratMACROSS , portfolios=portfolio.st) end_t<-Sys.time() print(end_t-start_t) start_t<-Sys.time() updatePortf(Portfolio='macross',Dates=paste('::',as.Date(Sys.time()),sep='')) end_t<-Sys.time() print("trade blotter portfolio update:") print(end_t-start_t) chart.Posn(Portfolio='macross',Symbol=stock.str, TA=c("add_SMA(n=50,col='red')","add_SMA(n=200,col='blue')"))
The line that gives the error is
chart.Posn(Portfolio='macross',Symbol=stock.str, TA = c("add_SMA(n=50,col='red')", "add_SMA(n=200,col='blue')")) ## "Error in !is.null(TA) && nchar(TA) > 0 : 'length = 2' in coercion to 'logical(1)' " traceback() ## 2: chart_Series(Prices, name = Symbol, TA = TA, ...) at chart.Posn.R#82 ## 1: chart.Posn(Portfolio = "macross", Symbol = stock.str, TA = c("add_SMA(n=50,col='red')", ## "add_SMA(n=200,col='blue')"))
It occurs because TA has 2 elements
The text was updated successfully, but these errors were encountered:
f8e11fc
Thanks for the report and reproducible example!
Sorry, something went wrong.
joshuaulrich
No branches or pull requests
Description
chart_Series()
gives error running the basic example in quantstrat under R 4.3. Works ok in 4.2.Expected behavior
Run error free in R 4.3
Minimal, reproducible example
The line that gives the error is
It occurs because TA has 2 elements
The text was updated successfully, but these errors were encountered: