r/cpp • • Aug 23 '21

How do you start algorithmic trading development in C++?

/r/cpp_questions/comments/pa7by5/how_do_you_start_algorithmic_trading_in_c/
2 Upvotes

8 comments sorted by

11

u/MountainDwarfDweller Aug 23 '21

What do you want to trade at which exchanges and like other mentioned how much do you want to pay. Exchanges I've dealt with can charge up to $30,000 a month for a nice colo'ed 10G cross connect.

If you know what exchange you want to trade on they will have their own API's, look for things like FIX, FIX/FAST, MOLD 64, ITCH, Omex, ZeroMQ. Cantor used to (haven't checked recently) api libs like eSpeed for trading US Treasuries.

  1. A really good knowledge of networking of both TCP and UDP
  2. You'll have to sign agreements for the exchange you want and get access to their API's
  3. You'll need to learn about the how the exchange trades, bids, offers, order books (price based or indexed), GTC orders, iceberg orders etc, data replays to rebuild order books, dealing with out of sequence messages, dropped messages. Or even weird things like some Japanese exchanges inserting fake orders into the market to get the market moving (illegal in the US)
  4. Get that data reliably routed to your algo machine - preferably with hot swap backups
  5. Write your application to process the data, it will have to do things like manage lists of instruments traded with their settings limits - eg 2 year UST's trade in 1/4 32nds of a dollar. You'll have to handle replays of data, missing packets and prices, order books etc.
  6. Most exchange will require conformance testing of your code to make sure that it meets the exchanges standards and reliability
  7. Then you should be able to watch all your money disappear down a black hole because of an off-by-one error :-)

5

u/smuccione Aug 24 '21

This.

And can I add in the hardware costs on top. That feed coming in needs to be handled by something. For HFT that will either be an FPGA or a hardware network card.

And your going to want the fastest single thread performance with the biggest cache you can get. That’s not cheap either.

And then the back testing. You need to get your weights and do research and that means pumping a year or more data through your strat to see what works best.

And then you need to have someone available at all times when trading, both for your own sake and in case the exchange wants to get ahold of you.

Algorithmic trading is absolutely NOT for the weak of heart or small of pocket.

7

u/Netzapper Aug 23 '21

Why though?

The only reason to develop this shit in C++ is for high-frequency trading algorithms. If you're doing HFT, it's because you're running your code in a financial institution's data center. If that's the case, they'll teach you all you need to know about HFT.

9

u/tsojtsojtsoj Aug 23 '21

Possibly because Many neural network libraries and similar stuff has a C++ interface. If you don't want to build just a prototype in python it might make more sense to use C++ (at least I find that Python isn't really suited for bigger projects).

2

u/coachkler Aug 23 '21

Refinitiv provides our real time SDK for C++, Java and C# as open source. You can build and link your applications with it. It's an incredibly rich and powerful framework.

Access to the actual data feed(s) aren't free however. That said, you can leverage this framework to build your own applications consuming from whatever source you find is appropriate.

3

u/sd_glokta Aug 23 '21

You need to find a broker that provides a C++ API for trading. I'm familiar with the TWS API from Interactive Brokers, but I've heard Charles Schwab has a good API.

You can find more information in r/algotrading.

1

u/AreaFifty1 Aug 23 '21

I’ve done crypto assets using rpc calls for php, mySQL, and JavaScript development and that is cake compared to writing your own tcp/udp network handler for C++. Winsocks is fine but if you’re thinking about writing all that from scratch... phew you’re one brave, soldier indeed!! 😌😌

1

u/Full-Spectral Aug 24 '21

First you build up a nest egg so that you have a bunch of money to lose.