MBO Order Book Management Questions

Custom indicators, trading strategies, data export and recording and more...
rickbarlow
Posts: 43
Joined: Mon Feb 08, 2021 5:37 pm
Been thanked: 1 time

MBO Order Book Management Questions

Post by rickbarlow » Sat Feb 13, 2021 10:17 pm

I have the ability thru using some of the sample demos, to be able to receive and print out every trade, and every order book change via the api's onTrade(), send(), cancel(), and replace(). Along with getAllIds(), I assume I should be able to maintain my own copy of the orderbyorder book, knowing when orders come in and when they are completed and need to be removed from the order book. 

However, I've run into some issues.

#1) Unexpected Trade messages - I receive many trade messages that have no size, and have a null tradeInfo structure. Why am I receiving these (from within the onTrade() call) ? Are they signifying something else that I should be recognizing?

#2) Unexpected "missing?" MBO records - I record all of the send, replace, and cancel records, but I don't see the correlation between the number of contracts in the trades vs. the MBO records. I'm aware of icebergs, etc. But I don't see any way to determine whether each/every orderId which is on the book is completed, or still open. For example, I would expect to see a match between the consolidated size of trades adding up to MBO record size, or some Cancel() or completion record to let me know when the Order is finished/removed.
Am I missing some other record types to listen for? Is there any further documentation I can review?

I'm familiar with, and basing my expectations on documentation of the data feed such as the following:
https://www.cmegroup.com/confluence/dis ... cification

Thanks

Svyatoslav
Site Admin
Posts: 278
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 31 times

Re: MBO Order Book Management Questions

Post by Svyatoslav » Mon Feb 15, 2021 9:27 am

Hi.
Re 1: trades with size=0 should come with TradeInfo#isExecutionEnd==true. Those are markers for the end of reconstructed trade. However I'm not sure how you get tradeInfo==null as I'd expect bookmap to crash before it delivers such tradeInfo to you. If you could attach a short example that demonstrates the issue - that would help.

Re 2: #cancel means that order is no longer in the book for some reason. You can compare TradeInfo#passiveOrderId with an order id in cancel to know if that's because it was just canceled or because it was executed.
If you have doubts about MBO data being valid (i.e. corresponding to MBP data) - try this demo: https://github.com/BookmapAPI/DemoStrat ... story.java - under normal conditions it should show an order book that matches what you see in bookmap. So it will either point you in a right direction or will prove that there is a bug, in which case let's start with a screenshot and a log file.

rickbarlow
Posts: 43
Joined: Mon Feb 08, 2021 5:37 pm
Been thanked: 1 time

Re: MBO Order Book Management Questions

Post by rickbarlow » Mon Feb 15, 2021 2:42 pm

I misspoke, the tradeInfo is not null, the aggressorOrderId and passiveOrderId are null.

Code snippet within onTrade():

            String.format("%d,",size) +
            Boolean.toString(tradeInfo.isBidAggressor) + "," + 
            Boolean.toString(tradeInfo.isExecutionStart) + "," +
            Boolean.toString(tradeInfo.isExecutionEnd) + "," + 
            tradeInfo.aggressorOrderId + "," +
            tradeInfo.passiveOrderId +  "," + 

Responses when size == 0: 

0,false,false,true,null,null,
0,true,false,true,null,null,

But based on what you are saying about the rows where size=0, it now makes more sense.  I now need to differentiate and handle them.
Thank you.

Post Reply