Trading and the GPU: The super power that almost no one uses

During recent years there have been gigantic advances in the field of parallel processing, particularly related to graphic processing. The GPU – short for Graphics Processing Unit – is a type of card that has been created specifically to perform very highly parallelizable tasks that are common in tasks like 3D rendering. Now a days you can buy a very high powered card that has dozens of processors for just a few hundred dollars. These cards therefore provide a ton more processing power for a fraction of the cost of your traditional CPU. If this is the case then it begs the question, if these cards are so awesome then why aren’t they used commonly in trading? Why is it that almost no one performs back-testing using a GPU if tasks like trading system optimizations are so obviously parallelizable? On today’s post I am going to talk a bit about GPU technology, why it is difficult to perform back-testing using a GPU, what the advantages of actually doing it are and why almost no one ever does it.


If you search for “GPU back-testing software” you will find almost nothing (well, you will find pKantu). Almost all the pages you will find are either academic articles/slides or forums where a few users who have heard the great advantages of GPU technology ask developers if they could implement GPU usage within their software. There are some good reasons why most developers out there will shy away from using GPU cards within their programs and this is because – as cool as it may sound – the technology is very difficult to use and implement across something like a general back-testing engine like Metatrader, Tradestation, Ninjatrader, etc. But what are these problems and isn’t it a fact that if you had enough money you could simply hire coders to implement this if you’re gonna get a huge performance boost?

The problem is the way in which a GPU works and the way in which general purpose back-testing works. Most of these back-testing programs have a language like MQL4, Ninjascript, Easy language, etc and these languages are used to construct trading systems that the simulator executes by performing some sort of parsing of the scripted code. This approach gives you a ton of flexibility because you can code whichever strategy you can think of with whatever logic you can think of and the simulator will be able to handle it. It’s a simple function handling problem. You code a strategy that is in essence a function that the simulator then uses to execute code within its back-testing engine. When you try to move this type of thinking to the GPU you go into lots of problems.


To begin with the GPU is a very limited machine in terms of programming flexibility. You cannot just code your system within a script and send it to a GPU back-tester and have it spit out and answer. If you want the GPU to perform a trading system simulation you’ll need to code the entire system and simulator within the same function and have the GPU run that in a batch process. You will also have serious limitations in what this simulator can do, especially in terms of how and when you perform certain operations. The GPU technology was created to be very efficient at things like vector and matrix operations but this makes them very inefficient in terms of other things like conditional operations and random memory access operations. Introducing things like double loops and random access patterns is hell for the GPU. Say you want to evaluate a system where you want to use a moving average with a period of 20, doing a constant recalculation of an average using the past 20 bars is very bad for the GPU and if you do this you’re bound to have code that is just as slow as the code on your CPU.

If you really want to write simulations for a GPU you therefore must ensure that everything that is random access intensive or conditional intensive is pre-calculated and passed to the GPU. You can start to see how if you want to have something that is “general purpose” it starts to become very hard to pre-calculate and pass stuff plus interactively build the entire simulator-plus-system code to load it into the GPU and perform the simulations. If your user decides to code a system that does something slightly convoluted then everything goes down the drain because your GPU will face a tremendous struggle to run anything but the most optimized code. This is the main reason why I would seriously doubt that we will ever see a program like MT4, Amibroker, NinjaTrader or TradeStation use something like a GPU for back-testing. Their scope is simply too general to take advantage of this technology because – by its very nature – the GPU requires things to be very narrow and well defined. As others have put it it is simply very hard to get a back-testing process to work on a GPU and the cost of doing so is often too great, even more if the programmers don’t even know if the end goal will be achievable.


What can you do with a GPU in trading then? There are many ways in which GPU technology is currently being used in trading. Traditionally they have been used to execute simulations that are very specific and parallelizable – such as pricing simulations, machine learning training and high frequency trading algorithms – but they can be used to perform specific yet very intensive tasks such as the price action based system mining we perform using pKantu. When we moved our simulations from openKantu to pKantu we had a performance increase near 1000x which enabled a whole new way to look at the market and generate trading strategies. The technology leap that you get when you can make your problem fit within the scope of what a GPU can do is huge since you suddenly have access to what in practice is a super computer level of performance at a minute fraction of the cost. If you look at the first graph within this post you’ll see how much you’re getting, it’s really not peanuts.

The above shows you how if you’re looking for something very general the GPU tends to be a bad solution but if you’re interested in some particular trading problem then there’s a big change that you would be able to hugely benefit from it if you are willing to spend the time, energy and money necessary to create a custom GPU implementation. If you would like to learn more about GPU technology and how we use graphics processing units to mine massive amounts of price action based strategies please consider joining, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading.

Print Friendly, PDF & Email
You can leave a response, or trackback from your own site.

2 Responses to “Trading and the GPU: The super power that almost no one uses”

  1. Chris Rebisz says:

    Hi Daniel,

    This is brilliant! Just the fact that you are able to recognize this opportunity and write a code to use it for mining pkantu, gives you and the community leap jump forward. Can’t believe how much more power this technology offers! Congrats. Can this technology be used as well in running pkantu in the practical manner for trading with the increasing amount of algorithms? Thank you.


    • admin says:

      Hi Chris,

      As always thanks for writing and for your kind words. Expanding on execution using GPUs is probably not something within our problem domain since we are not trading at high frequencies. The transfer of data between the GPU and the CPU is also expensive and can eliminate any advantage if it’s not done very carefully. Due to these reasons we are so far not considering doing this type of thing but perhaps it might be something we will consider in the future if the need arises. Thanks again for writing Chris,

      Best Regards,


Leave a Reply

WordPress › Error

The site is experiencing technical difficulties.