question

Upvotes
Accepted
28 3 6 12

How to build and keep full order book snapshot using EMA MarketByPrice domain - C++

Hi,

We are using Elektron Message API C++ edition to receive level 1 and level 2 market data. In case of level 2 or order book retrieval, the call back messages contain a Map with which defines an action (Add, Update or Delete) for each map entry for an order book level. In case of Delete action there is no FieldList associated with the map and the corresponding MapEntry has only a Key which is not supposed to be parsed according to the documentation.

So, one question is whether we can make an assumption that map entries are sorted by map entry key and whether we can use this key to find which level is added, updated or deleted for each order side (Bid or Ask)?

Another question is, how do we know which order book level to delete when there is no price and order side information available? We have overcome this by keeping an internal map of MapEntry key (which is retrieved as EmaBuffer) and corresponding price\orderside combination as the value.

The Consumer220 sample is the only example using MarketByPrice domain, and there is not so much details about applying the Delete action.

Thanks.

elektronrefinitiv-realtimeelektron-sdkmarket-by-pricelevel-2order-bookmap-entry
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
4.4k 10 6 9

Hi @mojtaba.danai

Yes, map entries are sorted by keys and you should use it for Add, Update, and Delete.

EMA map work just like any map container. It is an associative containers formed by a combination of a key and value, where in MarketByPrice case value is a FieldList.

Every Add and Update action will give you a Key which is associate with the value in that action. In case of Delete, it will give you a Key only since value is not necessary because you are suppose to delete it. You should use the Key from Delete action to find the value you stored.

The guide says "a Key is not supposed to be parsed" because right now MarketByPrice Key is a combination of price and side which give a false sense that you can just use the Key and ignore the FieldList. This is NOT safe, as the Key may not represent the actual price (i.e. it might be truncated). So the guide must state it to avoid incorrect usage.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks @Warat

Upvote
20.3k 73 10 20

There is now an article related to Sorting / Ranking Order Books available at

Sorting/Ranking Level2 Order Books for Display purposes

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks Umer

Click below to post an Idea Post Idea