1
$\begingroup$

I am receiving the following error:

Exception in thread "main" rcaller.exception.RCallerExecutionException: RExecutable is not defined. Please set this variable to full path of R executable binary file.

This being said, I have tested RCaller separately and have had it work (basic 1+1 example).

The code I am trying to run in Java is the following:

        public void computeImpliedVol(siteCall.reqObj rO) {
            try {
                double price;
                String modCP=callPut.contains("P")?"put":"call";
                SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
                DecimalFormat df = new DecimalFormat("########");

                Date dMat = sf.parse(df.format(maturity));
                Date dt;
                double diff;
                caller.setRscriptExecutable("C:/Program Files/R/R-2.15.2/bin/Rscript");

                String command;


                for (Double d : hTimeSeries.keySet()) {
                    caller.addRCode("library(RQuantLib)");
                    dt = sf.parse(df.format(d));
                    diff=(dMat.getTime()-dt.getTime())/(60.0*60.0*1000.0*24.0)/365.0;
                    if (longShort > 0) {
                        price = hTimeSeries.get(minDate).ask;
                    } else {
                        price = hTimeSeries.get(minDate).bid;
                    }
                    command = "EOImpVol<-EuropeanOptionImpliedVolatility(\"" + modCP + "\"," 
                           + price + "," + rO.requestObject.get(d).hAClose + "," + strike + ",0,.03," + 
                             diff + ",.2)";
                     caller.addRCode(command);
                     caller.runAndReturnResultOnline("EOImpVol");
                     double rDbl[]=caller.getParser().getAsDoubleArray("EOImpVol");
                     rDbl=rDbl;
                }
            } catch (ParseException ex) {
                Logger.getLogger(optionDB.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

If I try to run the command in R I get:

        > EOImpVol<-EuropeanOptionImpliedVolatility("put",1.9,21.18,21.0,0,.03,0.10410958904109589,.2)
        > EOImpVol
        $impliedVol
        [1] 0.7518471

        $parameters
			$parameters$type
        [1] "put"

        $parameters$value
        [1] 1.9

        $parameters$underlying
        [1] 21.18

        $parameters$strike
        [1] 21

        $parameters$dividendYield
        [1] 0

        $parameters$riskFreeRate
        [1] 0.03

        $parameters$maturity
        [1] 0.1041096

        $parameters$volatility
        [1] 0.2


        attr(,"class")
        [1] "EuropeanOptionImpliedVolatility" "ImpliedVolatility" 

So I am assuming it works fine. Is something obvious occurring that I do not realize being new to this?

Thank you very much

$\endgroup$
2
  • $\begingroup$ This seems to be a programming only question. Consider moving to Stack Overflow. $\endgroup$
    – QuantIbex
    Jul 10, 2013 at 8:39
  • $\begingroup$ Already asked on Stack Overflow before cross-posting here. $\endgroup$
    – user508
    Jul 11, 2013 at 1:14

1 Answer 1

1
$\begingroup$

I'm not sure but I think this mistake. caller.setRscriptExecutable("C:/Program Files/R/R-2.15.2/bin/Rscript");

you try to use backslash between word. caller.setRscriptExecutable("C:\Program Files\R\R-3.3.1\bin\i386\Rscript");

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.