I am looking for a C# .Net library that provides trade performance analytics similar to R-PerformanceAnalytics. Basic return statistics, draw-downs, risk-adjusted returns, risk (variations), distributional analytics,...

I checked all the general Math/Stats C# libraries and I can certainly whip up analytics from several such libraries but something that covers more specific financial asset return analysis did not come across my search.

Even basic trade analytics such as risk/reward, MAR, MAE/MFE, drawdowns would be helpful, just to generate some quick stats for a side-project.

Edit: I am not interested in a R solution as I am already aware of the R PerformanceAnalytics package. I am looking for a C# library, commercial or open-source.


  • 2
    $\begingroup$ Have you considered R.NET? I don't know anything about it, other than it exists... $\endgroup$ May 6, 2014 at 13:09
  • $\begingroup$ @Joshua Ulrich, I am familiar with the library and have coded against it but at this point I rather like to perform all computations natively in C# or else export the dataset (most likely through Redis) and run the analytics in R. At the moment I prefer to run within C# only. R.NET is good at running a couple commands but shipping larger datasets through the API seems very slow. $\endgroup$
    – Matt
    May 6, 2014 at 15:08
  • 1
    $\begingroup$ You can offer as much of a bounty as you want; the fact remains is that the code you want is there in R so if I were you I'd look into RServe or other means to accessing R remotely if you really insist on sticking to C#/CLR/Windoze. $\endgroup$ May 9, 2014 at 12:53
  • 1
    $\begingroup$ @DirkEddelbuettel, nobody disputed that a package for R exists and I acknowledge your expertise on the R side (among most likely other, to me unknown, areas) . But I think I made clear that I look for a C# library, not an R package. I am a bit irritated why the condescending tone, if you do not know of such library or dislike Windows or .Net for that matter, why having to comment? $\endgroup$
    – Matt
    May 9, 2014 at 17:35
  • 1
    $\begingroup$ I can't stop giggling about your claim that everybody uses C# now. Everywhere I look C# has been abandoned for anything but GUIs, but beauty is as always in eye of the beholder. $\endgroup$ May 13, 2014 at 14:02

2 Answers 2


The PerformanceAnalytics library reflects several years worth of development by Brian Peterson and Peter Carl, as well as multiple collaborators. It is fairly widely used, tested and debugged.

Basic software engineering practices suggest that you should strive to re-use it if possible. Options for that include

  • accessing a remote R instance via RServe (though you may be unhappy with the state of RServe clients on Windows / C# as per your comments)

  • accessing a remote R instance via a RESTful service such as OpenCPU

  • placing your jobs on a queue (for which I like Redis) and having the R worker pick'em up from the queue via rredis

The last option is the loosest coupling and may be easiest to test. I would rather go down any of these routes than trying to rewrite PerformanceAnalytics. Don't forget that the package itself has dependencies you may have to port as well.

  • $\begingroup$ I did not say that I intend to rewrite any library, I only plan to peruse a fraction of the functionality that PerformanceAnalytics offers. I like your last bullet point suggestion, because I heavily use Redis as key/value store and for pub/sub though I have never worked with rredis. I assume rredis is some sort of workload forwarder or would I need to write the workload client myself in R? +voted $\endgroup$
    – Matt
    May 14, 2014 at 16:37
  • $\begingroup$ You probably should just read the documentation of the rredis package but the "tl;dr" version is that it is the main Redis package for R. $\endgroup$ May 14, 2014 at 16:51
  • $\begingroup$ And as you asked: we also just released the RcppRedis package which should have Windows binaries in a few days, hopefully. But it has a much narrower scope. $\endgroup$ May 14, 2014 at 16:57
  • $\begingroup$ I posted a question on stackoverflow (stackoverflow.com/questions/23672491/…) because I am getting errors when executing a simple example regarding doRedis. Is doRedis even the right package to use if I just want to have a single worker that picks up commands from the redis queue and stores the results back on redis? I am asking because doRedis seems to really zero in on distributed workload processing through foreach loops. Any hints? Thanks $\endgroup$
    – Matt
    May 15, 2014 at 8:06
  • $\begingroup$ No, doRedis is particular to the foreach parallel framework. I would use rredis as I had suggested earlier. $\endgroup$ May 15, 2014 at 11:03

Long story short, thanks to Dirk Eddelbuettel's suggestion I played a bit with rredis and indeed it offers quite a number interesting solutions.

However, I still decided to start to write my own performance analytics library (albeit obviously smaller and more specific to my use case) in combination with an established Math/Stats library because I need more fine-grained performance attribution metrics, such as sliding lookback windows, custom distributional assumptions, different formulaic approach to measuring risk-adjusted returns for trades of extremely short holding periods...

Having delved a bit more into parallel execution in R and understanding how to run several R sessions on a single machine or in distributed fashion explains why there is no real need/demand to equip a single R session with multithreaded capabilities. Credits to Dirk and his pointing me into the rredis and indirectly to the distributed workload processing direction in R. I so far heavily rely on a fully customized research platform and Matlab and thus have not done a whole lot with R. I left when R still could not handle larger datasets and when there was no 64-bit version available (at least not for Windows), which kind of defeated the whole purpose to peruse a statistical computing platform from the start (at least for someone working with larger time series data). Obviously, quite a number of things have changed and it is interesting to see the explosion in growth of use cases and packages such as adapters that connect R with various data stores, other libraries, languages, ...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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