C++ Trading Ecosystem

Note that the videos provided are very old and only show maybe 10%~ of the actual backend implementation. I have yet to touch-up on the user interface so most of the things are displayed in the console or .log files currently.

I am still working on finishing the user interface using Qt Creator on Linux

General Info

A multithreaded trading ecosystem that hosts an exchange that can support multiple clients. The system ensures that orders are fairly executed on a first-come-first-serve basis. The exchange also has basic market maker and liquidity taker algorithms running that run different trading strategies. 

The system also ensures that should any market data updates packet not make it to any client, they can rebuild the orderbook from an orderbook snapshot and previous incremental updates.


Learning outcomes

  • Minimizing latency utilizing data duplicates or lock-less queues to transfer data between threads
  • Profiling latencies, execution times with RDTSC, focusing on mean, range and spikes
  • Dealing with WinSock, handling loss recovery when using UDP via incremental and snapshot data streams
  • Compiler hinting and attributes to maximize performance
  • Learning good design and optimization techniques
  • Packing data structures
  • Qt usage


  • Matching engine, trading engine
  • Order gateway server
  • Market data publisher & consumer
  • Feature engine, position, order & risk manager
  • market making & liquidity taker algorithm
  • market order book using best bid and ask

Potential Improvements

  • Better scaling but sacrifice performance (using unordered_map instead of array) [DONE]
  • Setting thread affinity correctly and isolating CPU cores
  • Authentication and rejection messages
  • Support modifying orders
  • Enhancing risk metrics in RiskManager
  • Order Manager can handle more orders
  • Feature Engine can have more than 2 features
  • Liquidity Taker and Market Maker trading algorithms can be more complex
  • Avoid using std::function
  • Optimize snapshot instead of sending full snapshot for all tickers every minute
  • Disabling certain ASSERT or logging in release build by defining and checking NDEBUG