Note that there are some explanatory texts on larger screens.

plurals
  1. POPerformance of C++ vs Virtual Machine languages in high frequency finance
    primarykey
    data
    text
    <p>I thought the C/C++ vs C#/Java performance question was well trodden, meaning that I'd read enough evidence to suggest that the VM languages are not necessarily any slower than the "close-to-silicon" languages. Mostly because the JIT compiler can do optimizations that the statically compiled languages cannot.</p> <p>However, I recently received a CV from a guy who claims that Java-based high frequency trading is always beaten by C++, and that he'd been in a situation where this was the case.</p> <p>A quick browse on job sites indeed shows that HFT applicants need knowledge of C++, and a look at <a href="http://www.wilmott.com" rel="noreferrer">Wilmott</a> forum shows all the practitioners talking about C++.</p> <p>Is there any particular reason why this is the case? I would have thought that with modern financial business being somewhat complex, a VM language with type safety, managed memory, and a rich library would be preferred. Productivity is higher that way. Plus, JIT compilers are getting better and better. They can do optimizations as the program is running, so you'd think they's use that run-time info to beat the performance of the unmanaged program. </p> <p><strong>Perhaps these guys are writing the critical bits in C++ and and calling them from a managed environment (P/Invoke etc)? Is that possible?</strong></p> <p><strong>Finally, does anyone have experience with the central question in this, which is why in this domain unmanaged code is without doubt preferred over managed?</strong></p> <p>As far as I can tell, the HFT guys need to react as fast as possible to incoming market data, but this is not necessarily a <a href="http://en.wikipedia.org/wiki/Real-time_computing" rel="noreferrer">hard realtime</a> requirement. You're worse off if you're slow, that's for sure, but you don't need to guarantee a certain speed on each response, you just need a fast average.</p> <p><strong>EDIT</strong></p> <p>Right, a couple of good answers thus far, but pretty general (well-trodden ground). Let me specify what kind of program HFT guys would be running.</p> <p>The main criterion is responsiveness. When an order hits the market, you want to be the first to be able to react to it. If you're late, someone else might take it before you, but each firm has a slightly different strategy, so you might be OK if one iteration is a bit slow.</p> <p>The program runs all day long, with almost no user intervention. Whatever function is handling each new piece of market data is run dozens (even hundreds) of times a second.</p> <p>These firms generally have no limit as to how expensive the hardware is.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. COWhat purpose does your edit serve? It's not like the C++ compiler enables the secret "run 20% faster" optimization for HFT software specifically. You got general answers because it *is* a general question. HFT has certain requirements, and I think my answer touched on those requirements. But the same requirements exist in many other fields, so I didn't explicitly mention HFT anywhere.
      singulars
    2. COAnd saying "it might be ok if one iteration is a bit slow" seems like wishful thinking, tbh. It sounds like "I REEEEALLY want to use C#, are you sure it won't be ok?" One iteration being slow means one iteration in which you're less profitable. That might be "ok", but you want to avoid it if at all possible. A HFT developer I was talking to a few days ago was pretty clear on emphasizing "if an operation takes 1ms, it is too slow". They did use a mix of C# and C++, but good luck selling a GC'ed language for the time critical components to someone who considers 1ms an unacceptable delay.
      singulars
    3. CODon't you think 1 slow iteration is okay, given that the thing is gonna run millions of times? Sure, if you're slower than everyone all the time, that won't fly. But if you're grabbing some shares millions of times a day, being faster on average is what counts? I suppose I'm wondering whether the need for C++ is historical (established code base) or whether it really is a performance advantage.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload