I'm looking for c/c++ implementation of OrderBook. I need implementation to reconstruct market data from FAST. I don't need to do "matching" because it already did by exchange, I only need to "aggregate" such structures:

struct OrderUpdate {
    int32_t instrumentId;
    uint32_t MDEntryID;
    uint32_t MDUpdateAction;      // 0 - New 1 - Change 2 -Delete
    int64_t MDEntryPx_Mantissa;
    int16_t MDEntryPx_Exponent;
    int64_t MDEntrySize_Mantissa;
    int16_t MDEntrySize_Exponent;
    uint32_t RptSeq;
    uint32_t MDEntryTime;
    uint32_t OrigTime;
    int32_t SecurityTradingStatus;
    char MDEntryType;    // 0 - buy; 1 - sell; other values in documentation
    char MsgType;

Main requirement is, of course, speed. I've found in internet several projects:

Unfortunately most of these implementations are "matching" engines and not exactly what I'm looking for.

What is better to use to reconstruct orderbook from FAST messages?

  • $\begingroup$ Each exchange may provide its own algorithm to manage order book. Please provide more info. I see that your struct does not contain Order ID, so it looks like fixed depth order book (e.g. CME). But there is also no NumberOfOrders field in your struct. Is this just a fixed depth order book where each level contains only <price,size> entry? In this case it's just 20 lines of code. $\endgroup$
    – Serg
    Commented Nov 30, 2013 at 2:12
  • $\begingroup$ this is for moex.com for this template ftp.micex.com/pub/FAST/ASTS/template/FIX50SP2-ALL.xml $\endgroup$ Commented Nov 30, 2013 at 2:59
  • $\begingroup$ MDEntryID is OrderId (not equal to real order id but this is not important). MDEntryPx is order price and MDEntrySize is order volume and MDUpdateAction is what happened with order (added, modified or removed) $\endgroup$ Commented Nov 30, 2013 at 3:02

1 Answer 1


You don't just simply grab some random open source order book implementation and expect it to work. Every market is different. For example, markets have different rules for how you should handle priority in the order book (some are price-time, some are price-size-time, etc). Grabbing Joe Blow's code and expecting it to just work is only going to lead to pain and failure.

You have two separate issues. First, you must decode the FAST messages, and second you must build a book from them based on the specifications from the exchange and market in question.

For your question to be even be well-formed you should indicate exactly where the data is coming from. Of course, there is probably a 0% chance that someone is going to be able to provide an affirmative reference for you where you can download a working order book for the data you have.

  • $\begingroup$ decoding FAST messages is separate task, let's assume I have decoded messages. in general FAST messages are all prety similar and looks something like my structure in question. I don't care about priority. Just give me good implementation of orderbook from FAST for SOME case and I think I will be able to adjust it for MY case. $\endgroup$ Commented Nov 29, 2013 at 17:58
  • 3
    $\begingroup$ Order books are all about priority. $\endgroup$ Commented Nov 29, 2013 at 18:00
  • 1
    $\begingroup$ in simplest case I just need best bid and best offer $\endgroup$ Commented Nov 29, 2013 at 18:14
  • $\begingroup$ If the data is message by message depth of book data you can't get the best bid/offer without building and maintaining a book. $\endgroup$ Commented Nov 29, 2013 at 18:40
  • 1
    $\begingroup$ @javapowered, with all due respect but it sounds like you are missing some crucial basics here. You can't derive your best bid/offer without building and maintaining the book and that is precisely what Louis has already told you $\endgroup$
    – Matt Wolf
    Commented Nov 30, 2013 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.