QWFIX C++ Equities, Trading, Research and Management

QWFIX C++ Equities is the latest development of the QWFIX product line that targets the US domestic equities trading. Initially we will support five exchanges (NYSE, ARCA, NASDAQ, BATS and Direct Edge).

The Challenge

Equities trading faces a few challenges compared to futures trading. First of all, the algorithm may have to keep track of every market data message, filter out the ones it is not interested in and track the books of the “watch list” and the queue position of its own orders all the time.

Considering the amount of data involved (5-10GB per exchange per day), and the trading pattern (portfolio of tens or even hundreds of stocks), the key is to build a low latency feed handler that can reduce the tick-to-trade latency.

Feed handler also has to interact with the order management system, because it needs to keep track of order queue positions as well.

The Philosophy

The key is efficiency. Building efficient trading system will improve operation efficiency (less machines and lower co-location and connectivity cost) and trading profit (being ahead of others to grab the liquidity). Doing so will require efficient management of design and implementation.

The Speed War

In a top options market making firm, they use one machine to only trade one symbol, basically trying their best to reduce any possible latency.

In our research, we can see occasionally a possible miss-priced liquidity is taken within less than 100 microsecond round trip, immediately after it was posted. The market data won’t lie, one can not hide his/her trade.

Assuming your trading system is 200 nanosecond slower than the competitor’s system per stock in term of market data handling. Assuming your algorithm has to keep track of 100 stocks. So your system is on average 10 microsecond slower than competitor’s system, which is enough to make a difference when competing on same or similar signals.

Usually a top high frequency trading firm uses one machine only to trade about 20-30 stocks, with many outgoing order entry connectivity to send orders in round robin.

The Product – True Lock Free System

The QWFIX C++ Equities system is true lock free. Apart from optimizing our system for cache locality and pipeline friendly, we made it almost completely lock-free.

The only place we use lock is to lock guard sending portfolio of orders from several threads, and we used a spin lock to do it. Apart from that single lock, the entire system is completely lock-free, even free from atomic instructions.

The result is amazing, the system can run through a whole day’s worth of historical data (about 10GB), while keeping track of the book of top 600 active stocks and simulate order queue position, within about a minute.

Our design gives user to ability to explore maximum parallelism. Usually one core is dedicated to one thread for one algorithm. Market data update and retrieval can be done in parallel within difference threads and the system won’t be slowed down at any rate no matter how many threads are simultaneously retrieving the market data.

The only place that requires the spin lock is the order management part. However that effect is minimum. First of all, the API is designed to take a portfolio of orders at a time. Secondly, the latency introduced by that single lock is just about 100-200 nanoseconds if there is no contention.


The QWFIX C++ Equities system shares the same management console with our futures product. More UI widgets are added for equities trading management.


The API is carefully designed to unify the research and production environment. The same algorithm implementation can be directly used to simulate trading with historical market data. That method is used as a final step of the strategy development.

In another word, developer use our API to develop algorithms. Before using real money to trade, we can run the algorithm in “simulator mode” with historical data. It will accurately simulate the algorithm. It will be the same API and same code for both production and simulation. Cost and risk will be significantly reduced in this way.

For the development in early stages, we use HDF5 to store the market data with different levels of details. For example, top of book, top n levels of book, etc. The data set will be used by languages such as Python, C++, Java or .Net etc for research purposes.

Development Status

QWFIX Equities is expected to be in production within two months. We are working on development, testing and research in parallel.


About weiqj

High Frequency Trader; Hardcore Programmer; CME Individual Member
This entry was posted in High Frequency Trading. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s