Accessing the Order-book at indicator initialisation
Accessing the Order-book at indicator initialisation
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.
Tags:
-
- Site Admin
- Posts: 279
- Joined: Mon Jun 11, 2018 11:44 am
- Has thanked: 2 times
- Been thanked: 31 times
Re: Accessing the Order-book at indicator initialisation
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.
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
@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.
Chris G
-
- Site Admin
- Posts: 279
- Joined: Mon Jun 11, 2018 11:44 am
- Has thanked: 2 times
- Been thanked: 31 times
Re: Accessing the Order-book at indicator initialisation
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".
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
@Svyatoslav. Thanks for your help with this. With your explanation, I fully understand now.
Great work by the Bookmap team with this API.
Great work by the Bookmap team with this API.
Chris G