Page 1 of 1

Accessing the Order-book at indicator initialisation

Posted: Thu Jan 31, 2019 12:26 pm
by TraderCG
I would like to access the total Order-book without waiting for onDepth() to update each level as done in the OrderBookBase class. My question: is there a way of doing this with the layer1 API? My goal is to be able to detect all of the high-volume nodes within a certain percentile (such as shown by the heatmap) at the time of indicator initialization. Any help will be much appreciated.

Re: Accessing the Order-book at indicator initialisation

Posted: Thu Jan 31, 2019 2:19 pm
by Svyatoslav
Hi,
While current simplified API doesn't provide a ready OrderBook inside initialize it allows you to implement SnapshotEndListener interface. The state of the order book at that point (assuming you apply all onDepth calls to it) will be exactly what you would get inside initialize if it would be there (at least that's how it should work in theory). There will be no significant delay, as snapshot should be passed immediately after loading your module.

Re: Accessing the Order-book at indicator initialisation

Posted: Fri Feb 01, 2019 4:08 am
by TraderCG
@Svyatoslav thank you for your answer. Having the snapshot passed immediately after loading the module will work just as good. Sorry for my misunderstanding of the SnapshotEndListener interface (the Javadoc I have does not have any description for this - do I need to update?). I had experimented with it previously, but now that you have given your answer I think I better understand its function. Could you confirm that I have understood correctly that on loading the module, the SnaphotEndListener interface will iterate through each level in the Order Book with the onDepth() being called for each iteration, which means that the OrderBookBase class updates both bid and ask TreeMaps for this class so as to give the full Order Book. After all of the iterations, then onSnapshotEnd() -> snapshotCompleted = true and onDepth() continues to keep the TreeMaps in sync with the Order Book. Thanks again for your help.

Re: Accessing the Order-book at indicator initialisation

Posted: Fri Feb 01, 2019 9:26 am
by Svyatoslav
Hi,
The only thing I'd like to correct in what you said is that after module is loaded you get current order book stats via onDepth calls anyway - regardless of if you have SnapshotEndListener - the only thing this listener does is telling you "hey, this is the end of a snapshot, everything past this point will be realtime data".

Re: Accessing the Order-book at indicator initialisation

Posted: Sun Feb 03, 2019 5:30 am
by TraderCG
@Svyatoslav. Thanks for your help with this. With your explanation, I fully understand now.
Great work by the Bookmap team with this API.