I need to run lengthy and computationally intensive backtests in parallel. My backtests take an average of 8 hours to run and I need to run 30 of them. They all call the same function with different inputs. What I was able to find so far is the below piece of code that uses the foreach package.
require(foreach)
require(parallel)
require(doParallel)
cores = detectCores() #32
cl<-makeCluster(cores) #register cores
registerDoParallel(cl, cores = cores)
foreach (j=1:2) %dopar% {
if(j == 1)
{
get_backtestRUN(inputA)
}
if(j == 2)
{
get_backtestRUN(inputB)
}
}
My first question is more generic and I would like to know if the package above is the best way to solve my issue.
My second question relates to the use of additional computing power as I can only run 8 backtest in parallel on my local machine, there are plenty of options online and would like to have recommendations concerning the most R friendly way to proceed.
Thanks for your help and time,