Hello, I have 250 R scripts. *Input* Each of them needs a real time data feed from a C# interface. The real time datafeed updates at a speed of approx 3 times a second. Also the data array size is increasing every minute. (1 minute time frame) *Output* I want to output say 4 variables from each of the R codes back to C# execution engine I wish to know the complete process. Can I get some references for the same? Since R cannot be multi threaded, can this be done easily? What is the best possible way? Regards
Talking to C# API (Any reference to learn the same)
5 messages · Kunal Shah, Mark Knecht, Joshua Ulrich +1 more
On Sat, Oct 11, 2014 at 8:13 AM, Kunal Shah <kunalshah305 at gmail.com> wrote:
Hello, I have 250 R scripts. *Input* Each of them needs a real time data feed from a C# interface. The real time datafeed updates at a speed of approx 3 times a second. Also the data array size is increasing every minute. (1 minute time frame) *Output* I want to output say 4 variables from each of the R codes back to C# execution engine I wish to know the complete process. Can I get some references for the same? Since R cannot be multi threaded, can this be done easily? What is the best possible way?
I think you want to look at the Rcpp package. I've not used it myself but it seems to address your interface issue. As for 'multi-threading' I think in a very specific way you might look at the foreach package and then the multi-processing packages like doMC and doParallel. I'm using doMC & doParallel on Linux and have as many as 12 identical processes (parameter exploration ala the quantstratIII demo) running at the same time. If you need more than the number of cores on your machine then I think you want ReDis but I've never used it. There's web pages out there talking about it though. HTH, Mark
On Sat, Oct 11, 2014 at 12:04 PM, Mark Knecht <markknecht at gmail.com> wrote:
On Sat, Oct 11, 2014 at 8:13 AM, Kunal Shah <kunalshah305 at gmail.com> wrote:
Hello, I have 250 R scripts. *Input* Each of them needs a real time data feed from a C# interface. The real time datafeed updates at a speed of approx 3 times a second. Also the data array size is increasing every minute. (1 minute time frame) *Output* I want to output say 4 variables from each of the R codes back to C# execution engine I wish to know the complete process. Can I get some references for the same? Since R cannot be multi threaded, can this be done easily? What is the best possible way?
While you may be working on a financial application, your question has nothing to do with finance, and is therefore off-topic for this list.
I think you want to look at the Rcpp package. I've not used it myself but it seems to address your interface issue.
No, it doesn't. C++ != C# (they're not even close; C# is closer to Java).
As for 'multi-threading' I think in a very specific way you might look at the foreach package and then the multi-processing packages like doMC and doParallel. I'm using doMC & doParallel on Linux and have as many as 12 identical processes (parameter exploration ala the quantstratIII demo) running at the same time. If you need more than the number of cores on your machine then I think you want ReDis but I've never used it. There's web pages out there talking about it though. HTH, Mark
-- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com
<SNIP>
I want to output say 4 variables from each of the R codes back to C# execution engine
<SNIP>
I think you want to look at the Rcpp package. I've not used it myself but it seems to address your interface issue.
No, it doesn't. C++ != C# (they're not even close; C# is closer to Java).
How right you are! That's what I get for trying to help in an area I know less than zero about. Sorry. - Mark
1 day later
Kunal - Your basic problem is around options for high performance inter-process communications. Since you mention C#, I'm going to assume your target applications are all running on Windows. So you have several options under Windows including shared memory, pipes, queues, DMA etc.
From what I've seen, named pipes are the fastest way to do any kind of IPC on Windows. On a single core, individual pipe data xfer can take less than 4 ms. On multiple cores, this can degrade to 25ms, but still far faster than your 333 ms (1000 ms / 3) requirement.
Start with figuring out how to make DLL calls within R. Then configure your R programs as Named Pipe clients i.e. get them to make those calls.
Named Pipes (Windows)
Named Pipes (Windows)
A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients.
View on msdn.microsoft.com Preview by Yahoo
Hope this helps.
Cheers
Suresh
________________________________ From: Kunal Shah <kunalshah305 at gmail.com> To: r-sig-finance at r-project.org Sent: Saturday, October 11, 2014 11:13 AM Subject: [R-SIG-Finance] Talking to C# API (Any reference to learn the same) Hello, I have 250 R scripts. *Input* Each of them needs a real time data feed from a C# interface. The real time datafeed updates at a speed of approx 3 times a second. Also the data array size is increasing every minute. (1 minute time frame) *Output* I want to output say 4 variables from each of the R codes back to C# execution engine I wish to know the complete process. Can I get some references for the same? Since R cannot be multi threaded, can this be done easily? What is the best possible way? Regards [[alternative HTML version deleted]] _______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.