The Genesis “R” Adapter

The R language is increasingly used among statisticians and data miners for developing statistical software and data analysis. This is widely used for numerical analysis and machine learning. It is therefore suitable for a variety of functionality in the FinTech market such as transaction cost analysis, portfolio models, risk calculations, pre/intra/post-trade analytics, etc… and its popularity is growing extremely quickly.

The Genesis framework offers two different ways of working with R (Renjin and rJava), each one of them having different strengths, detailed below:

Renjin is a full implementation of the R language inside the Java Virtual Machine, therefore it is possible to interact directly with Java libraries without the need for expensive data transfer or brittle inter-process communication. It also enjoys offers performance improvements using techniques such as deferred computation, implicit paralellism, and just-in-time compilation. The Renjin Genesis Adapter allows developers to create fully featured Genesis microservices written in R and integrates seamlessly into the Genesis ecosystem as a first-class citizen. Therefore this implementation is best suited for new R development in Genesis.

rJava is another R-to-Java implementation. It provides a bidirectional low-level bridge between both languages using the JNI (Java Native Interface). This allows users to create objects, call methods and access fields of Java objects from R and vice-versa using the JRI (Java to R Interface). This implementation is best suited for legacy R codebases, as it allows the developer to use any existing R packages in conjunction with the Genesis framework. It involves a higher degree of customisation, but in exchange it can be carefully handcrafted to solve problems in the most efficient way.