efficient structure for aggregated nbbo in C++

Joined
10/23/11
Messages
63
Points
118
Lets say we have a large file (~1Gig) full of quotes on 1 symbol (yes only 1 symbol). The quotes come from say 10 different exchanges.

Now imagine creating an aggregated best bid and offer as each quote comes in. So lets say the symbol is MSFT and there are 3 exchnages quoting MSFT as per the below.....


Code:
//Quotes
Exch    Symbol    bid    bidSize    ask    askSize   
A       MSFT      29.79    100    29.82    50   
B       MSFT      29.78    200    29.82    150   
C       MSFT      29.79    150    29.83    200   
 
//Desired output                   
Symbol   bestbid  bestbidSize  bidExchs  bestask bestaskSize  askExch
MSFT     29.79    250          A_C       29.82   200          A_B


In order to achieve the desired output I must use some kind of data structure to store the latest Quotes from each of the 10 exchanges. As a new quote comes in, I replace/add the prevailing quote to the structure and then extract the max bid and it's corresponding size/exchanges. I do the same for the min ask.


This process is repeated millions of times and so my question is, what would be the most efficient data structure for this type of processing in C++? The 2 that I am looking at so far are a STL map and a Boost Multi-Index.

Do they seem like reasonable option? Any other suggestions? Speed is the only consideration.
 
Lets say we have a large file (~1Gig) full of quotes on 1 symbol (yes only 1 symbol). The quotes come from say 10 different exchanges.

Now imagine creating an aggregated best bid and offer as each quote comes in. So lets say the symbol is MSFT and there are 3 exchnages quoting MSFT as per the below.....


Code:
//Quotes
Exch    Symbol    bid    bidSize    ask    askSize 
A      MSFT      29.79    100    29.82    50 
B      MSFT      29.78    200    29.82    150 
C      MSFT      29.79    150    29.83    200 
 
//Desired output                 
Symbol  bestbid  bestbidSize  bidExchs  bestask bestaskSize  askExch
MSFT    29.79    250          A_C      29.82  200          A_B


In order to achieve the desired output I must use some kind of data structure to store the latest Quotes from each of the 10 exchanges. As a new quote comes in, I replace/add the prevailing quote to the structure and then extract the max bid and it's corresponding size/exchanges. I do the same for the min ask.


This process is repeated millions of times and so my question is, what would be the most efficient data structure for this type of processing in C++? The 2 that I am looking at so far are a STL map and a Boost Multi-Index.

Do they seem like reasonable option? Any other suggestions? Speed is the only consideration.

Hi dillshau, you could you use a map from order_id to price and another map from price to another map/object (a container that represents a book_level). So on order arrival you use the price to book_level map to push that order to its corresponding level, and on order cancel you use the order_id to price_level to know which book level to update.
 
Back
Top Bottom