I obtained the returns of the RUT index running a backtest in R in Quantstrat. Now I would like to create a bootstrap of the returns but I do not know how to do it. I know that the boot() function needs data, statistic, and number of bootstrap repetitions. In data I think I can add "returns" ( see code below ) But I do not know how to compute "statistic". Can someone help?
Please refer to the code below:
library(devtools) library(quantmod) library(quantstrat) library(TTR) library(png) library(IKTrading) install_github("braverock/blotter") install_github("braverock/quantstrat") install_github('IlyaKipnis/IKTrading') initdate <- "2010-01-01" from <- "2012-01-01" #start of backtest to <- "2017-31-12" #end of backtest n<- 30 Sys.setenv(TZ= "GMT") #Set up environment for timestamps currency("USD") #Set up environment for currency to be used symbols <- c("RUT") #symbols used in our backtest getSymbols("^RUT",src="yahoo", from="2012-01-01", to="2017-12-31", periodicity="daily") wma <- WMA(Cl(RUT), n=4, wts=c(1:4)) wmamaxt <- rollmaxr(wma, n, fill = NA) wmamint <- - rollmaxr(- wma, n, fill = NA) CNOwma <- function (RUT) {(wma - wmamint) / (wmamaxt - wmamint)} stock(symbols, currency = "USD", multiplier = 1) #tells quanstrat what instruments present and what currency to use tradesize <-10000 #default trade size initeq <- 100000 #default initial equity in our portfolio strategy.st <- portfolio.st <- account.st <- "firststrat" #naming strategy, portfolio and account #removes old portfolio and strategy from environment rm.strat(portfolio.st) rm.strat(strategy.st) #initialize portfolio, account, orders and strategy objects initPortf(portfolio.st, symbols = symbols, initDate = initdate, currency = "USD") initAcct(account.st, portfolios = portfolio.st, initDate = initdate, currency = "USD", initEq = initeq) initOrders(portfolio.st, initDate = initdate) strategy(strategy.st, store=TRUE) add.indicator(strategy = strategy.st, name = 'SMA', arguments = list(x = quote(Cl(mktdata)), n=100), label = 'SMA100') add.indicator(strategy = strategy.st, name = 'SMA', arguments = list(x = quote(Cl(mktdata)), n=30), label = 'SMA30') add.indicator(strategy = strategy.st, name = 'SMA', arguments = list(x = quote(Cl(mktdata)), n=15), label = 'SMA15') add.signal(strategy.st, name = "sigCrossover", arguments = list(columns=c("SMA15", "SMA30")), relationship = "lt", label = "Exitlong") add.signal(strategy.st, name = "sigCrossover", arguments = list(columns=c("SMA15", "SMA100")), relationship = "gt", label = "Enterlong") add.rule(strategy.st, name = "ruleSignal", arguments = list(sigcol = "Exitlong", sigval = TRUE, orderqty = "all", ordertype = "market", orderside = "long", replace = FALSE, prefer = "Open"), type = "exit") add.rule(strategy.st, name = "ruleSignal", arguments = list(sigcol = "Enterlong", sigval = TRUE, orderqty = 1, ordertype = "market", orderside = "long", replace = FALSE, prefer = "Open", osFUN = IKTrading::osMaxDollar, tradeSize = tradesize, maxSize = tradesize), type = "enter") out <- applyStrategy(strategy = strategy.st, portfolios = portfolio.st) updatePortf(portfolio.st) daterange <- time(getPortfolio(portfolio.st)$summary)[-1] updateAcct(account.st, daterange) updateEndEq(account.st) for(symbol in symbols){ chart.Posn(Portfolio = portfolio.st, Symbol = symbol, TA= c("add_SMA(n=15, col='blue')", "add_SMA(n=30, col='red')", "add_SMA(n=100, col='green')")) } # in “symbol” add “RUT” or “IXIC” final_acct <- getAccount(account.st) end_eq <- final_acct$summary$End.Eq returns <- Return.calculate(end_eq, method="log") library(boot) boot(returns, k=1, R=1000) Error in boot(returns, k = 1, R = 1000) : l'argomento "statistic" non è specificato e non ha un valore predefinito 
