[R-SIG-Finance] Custom Indicator and apply.paramset problem

Atakan Okan atakanokan at outlook.com
Sun Feb 26 09:05:22 CET 2017


Firstly, I tried to pass the .exports argument in apply.paramset, but produced an error like "formal argument ".exports" matched by multiple actual arguments"

So tried changing the code of apply.paramset using trace("apply.paramset",edit=TRUE) where I added my custom indicator MACD_W1 to the .exports arguments so that it looks like this:
.export = c(env.functions,  symbols, "MACD_W1")

When I run the code now I get a different error:

error calling combine function:
<simpleError in results[[r$portfolio.st]] <- r: attempt to select less than one element in OneIndex>




From: Atakan Okan <atakanokan at outlook.com>
Sent: Saturday, February 25, 2017 11:47 PM
To: r-sig-finance at r-project.org
Subject: Custom Indicator and apply.paramset problem
    
Thanks for the quick reply Brian,

The error reads as follows:

error calling combine function:
<simpleError in fun(result.1, result.2, result.3, result.4, result.5, result.6,     result.7, result.8, result.9, result.10, result.11, result.12,     result.13, result.14, result.15, result.16, result.17, result.18,     result.19, result.20, result.21, result.22,  result.23, result.24): attempt to select less than one element in OneIndex>


After switching to doParallel, the error message stays the same. How should I export my custom function to the cluster workers using .exports though? Just add it as an argument to apply.paramset()? Took a quick look at the apply.paramset() source code but couldn't  figure out how to pass the .exports argument to it.

Thanks,

Atakan

The new parallel code (all other bits are the same):

#DoParallel on Windows - Does Not Work 
library(doParallel)
library(parallel)
paramsetenv <- new.env()
cl <- makeCluster(detectCores())
registerDoParallel(cl, cores=detectCores())                                      
results <- apply.paramset(strategy.st,
                          paramset.label=paramset.label.name,
                          portfolio=strategy.st, 
                          account=strategy.st,
                          nsamples=0,
                          verbose = TRUE,
                          audit=paramsetenv,
                          calc = "slave")
stopCluster(cl) 



More information about the R-SIG-Finance mailing list