Search code examples
rparallel-processingapplylapplysnow

Using fOptions' EuropeanOption function under ClusterEvalQ


The following is giving me an error. The function evaluated is from the example subsection of the fOptions package pdf (I'm sure it's correct). What am I doing wrong in the parallel processing?

require(parallel)    
cl <- makeCluster(6)
registerDoParallel(cl)
clusterEvalQ(cl,require(fOptions)) 
clusterEvalQ(cl,EuropeanOption("call", 100, 100, 0.01, 0.03, 0.5, 0.4))

Result:

Error in checkForRemoteErrors(lapply(cl, recvResult)) : 6 nodes produced errors; first error: no applicable method for 'EuropeanOption' applied to an object of class "character"


Solution

  • I believe the function "EuropeanOption" is defined in the "RQuantLib" package, so you should load it on the workers:

    clusterEvalQ(cl, require(RQuantLib)) 
    

    But you should have gotten an "EuropeanOption not defined" error, so something else may be happening. I suggest that you use the makeCluster outfile='' option so that you see any error messages generated on the workers.