Java or C++ for HFT?

Discussion in 'Automated Trading' started by ppy93, Oct 29, 2021.

  1. ppy93

    ppy93

  2. rkr

    rkr

    If you already have experience in either language, pick whatever you're most familiar with. Iterate fast and build something that works first, then optimize for latency later.

    All else equal, and you're starting on a blank slate (I hope not), I generally recommend going with C++ for this. The reason is that there's a lot more ancillary benefits rather than language-specific benefits:
    - Many decently written, open source examples of data structures that you'll need.
    - More relevant vendors have C/C++ client libraries or tools than Java client libraries, e.g. VHDL transpilers.
    - The C/C++ client libraries tend to be better maintained than Java client libraries for such vendors, e.g. Alphaflash, Quincy, Celoxica.
    - Easier to apply your knowledge towards C drivers or devices with lower level APIs, e.g. ef_vi, onload.
     
    jtrader33 likes this.
  3. traider

    traider

    Rust is the new kid in town.
     
    cruisecontrol, d08 and kmiklas like this.
  4. kmiklas

    kmiklas

    HobbyTrading and dholliday like this.
  5. ppy93

    ppy93

    Thank you for sharing your insights. I have a follow-up question:

    Besides, my current code is written in Python. Before I am able rewrite everything in C++, what is a good way of coupling my current Python algorithm code with the future C++ code that communicates with the broker, e.g. placing/cancelling orders and getting account status.

    For example, if my python code decides to purchase 1 share of stock AAPL, it sends the command the C++ daemon. What is a good way of doing this? I can think of redis or rabitmq.
     
    Last edited: Oct 29, 2021
  6. sandy_s

    sandy_s

    C++ and python is interoperable. If you have done commercial level c++ programming in this domain, most likely you will be famiiar with boost. Use boost.python for this.
     
  7. kmiklas

    kmiklas

    This is called "Binding." [1]

    In my last job we used Boost.python [2]. I haven't personally used them, but other options for static binding include SWIG [3] and SIP [4]. Dynamic binding, there's cppyy [5].

    The annual C++ "Cppcon" conference is just finishing up; I've been soaking up talks all week as an online attendee. there was a talk that touched on this. I can forward if you like. [6]

    1. https://en.wikipedia.org/wiki/Language_binding
    2. https://www.boost.org/doc/libs/1_75_0/libs/python/doc/html/index.html
    3. http://www.swig.org/
    4. https://en.wikipedia.org/wiki/SIP_(software)
    5. https://cppyy.readthedocs.io/en/latest/
    6. https://cppcon.org/program2021/
     
  8. ppy93

    ppy93

    Thank you :)
     
  9. ppy93

    ppy93

    This is really helpful. Please forward it to me and I really appreciate it.
     
  10. kmiklas

    kmiklas

    See attached for a few key slides. The presentation did not focus on bindings; it was about interactive compilation (compiled C++ as you type) as a tool for Data Science, but static and dynamic binding were needed and explored as a subset of the presentation.

    Credit: Vassil Vassilev, Princeton University, New Jersey, USA. Cppcon 2021.
     
    #10     Oct 29, 2021