ConPA uses as calculation backend

November 25, 2011

(This article was first published on » R-project, and kindly contributed to R-bloggers)

ConPA is an asset allocation application using the classic Markowitz approach. For the calculations the open-source statistical programming language R is used. R scripts are executed on’s computer clusters in the Cloud and the results are displayed by ConPA frontend.

ConPA allows to set the investment date of the portfolio, the target return and the constraints for each asset. The result are the optimal weights of the assets and the portfolio performance, if the investment date is in the past. Furthermore, ConPA can retrieve the key statistics and calculate the implied volatility of the stocks.

Imitating a well-known concept of the open source model, ConPA makes a transparent process: the user can reproduce the results by himself. To check the figures, the user can click on the script icon, close to the help icon, and an R script, corresponding to the optimal portfolio calculated, is displayed. It is the same script executed on with the results displayed by ConPA frontend. The user can compare those results with the output of the script, running it, for instance, on a local R installation. De facto, an “Open Finance” paradigm. fits perfectly to ConPA, because it cuts the backend complexity and the development time.

Technical details:
At the beginning the asset allocation algorithm was ported to JavaScript from Fortran. Executing directly the same R script used to develop the algorithm is simpler: it avoids the porting mistakes and it reduces the development lifecycle.

The key component between and Node.js instance, the backend framework ConPA is based on, is the module node-rio: it is an R serve adapter. It injects the R code in a remote instance of Rserve, running on session. The session is configured with the following packages: RJSONIO, tseries, Rserve. The package tseries contains the implementation of mean-variance algorithm. The package RJSONIO serializes the inputs and the outputs of the script to a JSON format, a data format easy to handle for the JavaScript backend of ConPA. The package Rserve is configured to enable authenticated remote connections.

The roundtrip between ConPA frontend and is straightforward: the frontend collects the user choices, the backend dispatches the request to, retrieving the historical asset prices, calculating the optimal portfolio, finally the performance and returning the results.

To leave a comment for the author, please follow the link and comment on their blog: » R-project. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)