SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
SWilson
Topic Author
Posts: 48
Joined: February 13th, 2018, 5:27 pm

RTOOLS and C# Visual Studio

April 18th, 2018, 6:24 pm

Anyone using Rtools/R.NET engine in their C# code.  As in, there are some packages that let you source the script vs just using the Rtools functions within the C# code.  Just wanted to know if anyone has experience in this and share some best practice.  Thanks.  
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Re: RTOOLS and C# Visual Studio

April 18th, 2018, 8:59 pm

Yes, R.NET is a buggy, barely supported thing that doesn't lend itself well to multiple R processes on the same machine. If you only need one R process and use it serially then it's fine.

RTools is a very specific thing, I don't think that's what you are talking about: https://cran.r-project.org/bin/windows/Rtools/

Not used http://bluemountaincapital.github.io/FSharpRProvider/ but it looks okay for serial things.

https://github.com/Microsoft/R-Host from MS is decent and used in RTVS

What we wound up using was creating our own engine in C# that spins up N R processes on the machines and binds functions to WebAPI and use that.

If not bounded by deploying to Windows https://www.opencpu.org/ is good.
 
User avatar
SWilson
Topic Author
Posts: 48
Joined: February 13th, 2018, 5:27 pm

Re: RTOOLS and C# Visual Studio

April 19th, 2018, 12:54 pm

Thank you.  This helps, especially with the serial issue.  We'll have to work around that. I actually was using the stand alone R GUI to validate functions and then as you say, spun up the engine in VS and worked the code once I had what I wanted.  I don't think the RHost will help us much but your feedback did help nonetheless.  
 
User avatar
Cuchulainn
Posts: 60444
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: RTOOLS and C# Visual Studio

April 19th, 2018, 3:08 pm

I haven't used this but here's a convoluted answer. Use bilingual C++/CLI (a .NET language) that interfaces with both C# and native C++. (we did its using a front-end Excel-DNA application to Quantlib code). You do have to write some wrapper classes but it's very easy. We (DD/MK) have two planned Wilmott articles on this approach. 
So its like C# -> C++/CLI -> Natives.

Just an idea.

Rcpp could be the native in this case.

https://cran.r-project.org/web/packages/Rcpp/index.html
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
SWilson
Topic Author
Posts: 48
Joined: February 13th, 2018, 5:27 pm

Re: RTOOLS and C# Visual Studio

April 23rd, 2018, 5:47 pm

Thanks for the insight.  This look practical using multiple R functions but for now R.NET seems to be holding up fine.  Hoping there will be something standardized in the future.  Looking forward to the articles, love leveraging the speed of C++.
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Re: RTOOLS and C# Visual Studio

April 24th, 2018, 9:27 am

I haven't used this but here's a convoluted answer. Use bilingual C++/CLI (a .NET language) that interfaces with both C# and native C++. (we did its using a front-end Excel-DNA application to Quantlib code). You do have to write some wrapper classes but it's very easy. We (DD/MK) have two planned Wilmott articles on this approach. 
So its like C# -> C++/CLI -> Natives.

Just an idea.

Rcpp could be the native in this case.

https://cran.r-project.org/web/packages/Rcpp/index.html
Rcpp -> Run C++ code in R.
 
User avatar
Cuchulainn
Posts: 60444
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: RTOOLS and C# Visual Studio

April 24th, 2018, 1:30 pm

I haven't used this but here's a convoluted answer. Use bilingual C++/CLI (a .NET language) that interfaces with both C# and native C++. (we did its using a front-end Excel-DNA application to Quantlib code). You do have to write some wrapper classes but it's very easy. We (DD/MK) have two planned Wilmott articles on this approach. 
So its like C# -> C++/CLI -> Natives.

Just an idea.

Rcpp could be the native in this case.

https://cran.r-project.org/web/packages/Rcpp/index.html
Rcpp -> Run C++ code in R.
I see. I was a bit quick of the mark in this case. 
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
 
User avatar
Cuchulainn
Posts: 60444
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Re: RTOOLS and C# Visual Studio

April 24th, 2018, 2:21 pm

Thanks for the insight.  This look practical using multiple R functions but for now R.NET seems to be holding up fine.  Hoping there will be something standardized in the future.  Looking forward to the articles, love leveraging the speed of C++.
You're welcome.
The 2 articles with Mikael Katamajaeki are planned for July and September in the Wilmott journal.
All this multi-language approach has benefits, e.g. calling F# DiffSharp from C# or C++/CLI is easy and transparent.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On