Tag Archives: high frequency trading

Best high frequency trading HFT performance: Linux open source with C++ v Java with R, RJava,RCaller, RCPP,RInside

Best high frequency trading HFT performance: Linux open source  with C++ v Java with R, RJava,RCaller, RCPP,RInside

This has been a struggle for me for a while. It seems that I always struggle between Java and C++ regarding HFT. As I want to implement R into it vs my usual struggle between R and Matlab, this is easily the best development stack to go with. Watch this video at


I also did some metric research of calling R from both Java and C++. It seems without a doubt, calling R from C++ is definitely the way as it is half the time vs Java.I need to thank any person developing these highly important R packages. They know who they are.



Please do not engage me on this debate but I don’t have the time for it. I also will be moving on with a very primitive C++ open source trading platform for Linux. It is a rather complicated library stack but when you research the above links, it should be no reason not to. I don’t want to face a rewrite down the line. Also, I can confirm that is the best way forward on development on some kind of trading platform using R with RCPP. You can only do this in Linux as RCPP only support GCC. There is no option in using Visual C++ with Visual Studio so sorry there.

I will present my next set of steps on how I proceed with this. I do think this will be the most time consuming step I have been involved especially the amount of debugging time on this platform. Let me be as straight as possible, I will not be releasing the code to no one on my hacked version of this platform. You will need to note that this stage is becoming a very proprietary stage of QuantLabs.net development. As a result, only my Premium member will get this access through my unrecorded live webinar and  live demos. There be no track record of these steps as I am not redistributing this code to no one other than demoing it to certain people. This platform will be worth a lot of money to people so  this will really only include those who can afford it, Institutional or high  net worth. Problem with it? Move on to Google for a new search.

My time is getting highly crunched and I do not have the time to hand hold people any more. This will only be given to those who pay for my time. That is all.

I will continue to provide pointers for you but don’t expect this operation to give you an out of box overnight kit to being a millionaire by following green arrows. It does not work like that. Use the scammers known as Vector Vest for that.

QuantLabs.net now is following the footsteps of the most secretive institutional trading operations in the world. This is an expensive endeavour and I would expect only those that can afford to enter it, otherwise go to a casino to spend your money. You have better chances that way or continue losing money with your favourite corrupt trading broker. Have fun.

Get access to this membership now before these rate skyrocket. 

Video of R, RCPP, RInside makes use of C++ so much easier than Matlab Builder NE for high frequency trading aka HFT potential

Video of R, RCPP, RInside makes use of C++ so much easier than Matlab Builder NE for high frequency trading aka HFT potential

So I am going from trying out an open source C# application trading platform to an open source C++ ‘platform’ using Interactive Brokers. I also switched from Matlab to R. Lastly; I am looking at more open source projects including Linux where Ubuntu is becoming my preferred distribution. As you can tell, I am straying away from expensive options like Matlab. Being a developer, I can quickly debug most applications if need be.

The benefit I am finding switching to R as compared to using Matlab with something like Matlab’s Builder JA (for Java) or Builder NE (for .NET languages like C#) toolboxes. When I tried out the combination of R packages RCpp and RInside, I was pleasantly surprised for a number of things. Installing any R package is quite easy. Building or ‘making’ the provided C++ examples for RInside was flawless and easy to execute. The most impressive were samples of parallelization of C++ which was jaw dropping.

Now I am hoping I can see my newer open source C++ trading solution Trading Shim (http://www.tradingshim.org/) will work at some point as well.   Hey…it is C++ so leave it alone. But the speed and scalability of it should be impressive. I just wish there was a complete open source trading platform in Java that could connect to my chosen broker Interactive Brokers.

Anyhow, back to the R packages of RCpp and Rinside. I need to give a shout out to the contributors for making these packages happen in a quick and easy way. The provided C++ examples really do make a difference to showcase how a C++ application can call the R shell processor and execute individual R functions directly. You could not do that with the Matlab NE Builder as you could only call M scripts with their archaic programming structure. The C++ code within RInside as compared to Matlab NE is much simpler, tighter, and smaller. The Matlab NE Builder is really meant for C# so trying it in Visual C++ would have been ‘interesting.’ I am just glad I found this deadly combination of R, RCpp/Rinside, with C++. It may work well for my hopeful high frequency trading platform with R for prototyping and analytics.

[youtube_sc url=”http://www.youtube.com/watch?v=wIzrJFy-VCA” playlist=”Calling R from a C application for HFT development with MPI parallelzation ” title=”Calling%20R%20from%20a%20C%20application%20for%20HFT%20development%20with%20MPI%20parallelzation%20″]

The mother load of R packages for financial trading, quant, and potential high frequency trading (HFT) needs

The mother load of R packages for financial trading, quant, and potential high frequency trading (HFT) needs

So there seems to be this endless supply of what look to be a decent list of R finance packages. Some of these include quant based ones. This is my first day researching so I cannot vouch for any of these yet. I do know some R packages can be duds but I am not sure if these ones will be either but are part of CRAN which says positive things. Here we go:

Extreme value analysis:


Refer to p 39 for parameter use in Gvt:




Potential fat tail analysis which lead to the ones below:


PerformanceAnalytics package is quite amazing and easy to use for the amount of analysis it has: i.e. VaR


Overview and demo of PerformanceAnalytics (PA):



How read profitable data and convert to PA package


How to back test strategies with PA:


A technical package:


TradeAnalytics packages which includes quantstrat:




Intro to quantstrat:


General list of R packages for quant trading:


The motherload of all financial trading packages in CRAN:


I feel like a kid a candy factory with all this. Makes me wonder how Matlab is going to keep up. Wow! Thanks to all contributors above for all these. Now I have to start digging and play with everything. I will also keep reporting through this blog for those interested.


Advantages of R in high frequency trading with Redis NOSQL, doRedis, dot NET C# HFT on Linux and Windows

Advantages of R in high frequency trading with Redis NOSQL, doRedis, dot NET C# HFT on Linux and Windows

I talk about the advantages of this stack for an High Frequency Trading environment. This of couse includes the advantages of R over something like Matlab.

[youtube_sc url=”9QsWeqwyxa0″ playlist=”HFT with Redis NOSQL, R doRedis dot NET C Sharp trading platform on Linux and Windows ” title=”HFT%20with%20Redis%20NOSQL,%20R%20doRedis%20dot%20NET%20C%20Sharp%20trading%20platform%20on%20Linux%20and%20Windows%20″]

Here is an example doRedis R interation in RStudio with a remote Redis server:

> library(‘doRedis’)
Loading required package: rredis
Loading required package: foreach
foreach: simple, scalable parallel programming from Revolution Analytics
Use Revolution R for scalability, fault tolerance and more.
Loading required package: iterators
> registerDoRedis(‘jobs’)

> registerDoRedis(‘jobs’,’′,’6379′)

> registerDoRedis(queue=’jobs’,host=’′,port=’6379′)

> registerDoRedis(queue=’jobs’,host=’′,port=’6379′)
> startLocalWorkers(n=2,queue=’jobs’,host=’′,port=’6379′)
> removeQueue(‘jobs’)
[1] TRUE
> startLocalWorkers(n=2,queue=’jobs’,host=’′,port=’6379′)
> startLocalWorkers(n=2,queue=’jobs’,host=’′,port=’6379′)
> removeQueue(‘jobs’)
[1] TRUE
> startLocalWorkers(n=2,queue=’jobs’,host=’′,port=’6379′)
> foreach(icount(10),.combine=sum,.multicombine=TRUE,.inorder=FALSE) %dopar% 4*sum((runif(1000000)^2 + runif(1000000)^2)<1)/10000000
[1] 3.141388

From http://cran.r-project.org/web/packages/doRedis/vignettes/doRedis.pdf