Skip to main content

Enhanced Order Book Order Processing Details

Maintenance

Note

Treat all unknown Order Actions as UNDEFINED for compatibility, i.e. derive processing logic from other fields.

To determine orders' matching and execution priority, sort them by Price, Time, and Sequence on each Enhanced Order Book side separately. To maintain the Enhanced Order Book, check Order Action types and process with the Order Books' Order event for compatibility.Enhanced Order Book Description

The Order Action state machine diagram:

scheme_2_new.png

Ignore TRADE and BUST Order Actions since they do not refer to existing orders in the Enhanced Order Book.

Order executions

Whenever a new order execution occurs, the new trade-related event disseminates (either PARTIAL, EXECUTE, or TRADE).

Each Order Book execution (a book trade) has an order size value equal to the actual size of the order resting in the Order Book after the execution.

  • For regular orders (with no hidden volume), calculate the new size value as non-negative: new Size = old Size - new TradeSize.

  • Since a part of the order volume is hidden for iceberg orders, the exchange may update corresponding fields differently: the TradeSize may be larger than the order's size before the execution and the resulting size (after the execution) may even increase. Note that an iceberg order may change its position in the Enhanced Order Book (its Time field may change). For example, see CME documentation and the example below.

For user convenience, the ExecutedSize accumulates all known executed order volume. Calculate the ExecutedSize as a sum of all known TradeSize. Don't clear this field on DELETE or REPLACE actions.

BUST action processing depends on exchange regulations (if day volume, high/low prices need adjustments, etc).

Snapshot retrieval

With the Extended Order Book, you receive some extra events. It happens due to non-conflated dissemination when retrieving an initial Order Book snapshot. The Order Book has these events but with Size=0 not to break backward compatibility.

Note that the Order Book snapshot disseminates with events containing Action Types corresponding to the last action for each Order Book entry.

It is possible to receive the Order Book snapshot not only at the start. Process it like an initial snapshot and discard the previous Order Book state to receive a snapshot at any time during normal work. Usually, such snapshots occur due to reconnections in the uplink chain or global synchronization/reset distributed by the exchange feed.

Initial snapshot sample

Consider the Order Book for some symbol , e.g. IBM:

Bid Order ID

Bid Price

Bid Size

Priority

Ask Size

Ask Price

Ask Order ID

1001

100.0

10

1

20

105.0

1020

1050

100.0

20

2

10

110.0

1005

2009

95.0

50

3

-

-

-

The following Order event's snapshot from dxFeed API represents the above book state:

Index

Action

Order ID

Symbol

Side

Price

Size

Executed Size

Trade ID

Trade Price

Trade Size

Comment

0

UNDEFINED

-

IBM

-

-

0

-

-

-

-

EVENT_REMOVE

1

TRADE

-

IBM

-

-

0

0

30240

105.5

50

"Old" Non-Book Trade

2

PARTIAL

1001

IBM

Buy

100.0

10

10

30300

100.0

10

Partially-filled Order

3

NEW

1050

IBM

Buy

100.0

20

0

-

-

-

New Order

4

MODIFY

2009

IBM

Buy

95.0

50

0

-

-

-

New Order

5

NEW

1020

IBM

Sell

105.0

20

0

-

-

-

New Order

6

NEW

1005

IBM

Sell

110.0

10

0

-

-

-

New Order

7

EXECUTE

1010

IBM

Buy

100.0

0

20

30280

100.0

10

"Old" Fully-executed Order

8

DELETE

1060

IBM

Sell

115.0

0

-

-

-

-

"Old" Cancelled Order

Note

You may still receive old events due to non-conflated order dissemination.

Aggressor order processing

Usually, aggressor order is not manifest itself in the stream of Order events. All induced trades disseminate as events for their passive order counterparts. Most exchange protocols don't provide information about aggressive orders, but if they do (for example, CME), the new data model provides:

  • Trade action events for passive order contain the aggressor's Order ID in AuxOrderID field

  • No dissemination for the Order event if the aggressor order is fully executed. The new data model publishes trade-related Order event for passive order

  • The trade size for the ExecutedSize field if the aggressor order isn't fully executed and enters the Order Book