Hi. You will need to use Core API to request data for historical orderbooks.
We have no good single example that will fit your request so we will need to take a look at more than one module as examples.
https://github.com/BookmapAPI/DemoStrat ... sDemo.java
https://github.com/BookmapAPI/DemoStrat ... dDemo.java
1) acquire the link to the data tree (example Layer1ApiMarkersDemo#onUserMessage)
We can get the link to the data tree (DataStructureInterface dataStructureInterface) in the #onUserMessage method.
2) get the timestamp for the right edge of the chart(example Layer1ApiGridDemo)
The easiest way to get it you need your module implementing ScreenSpacePainterAdapter. See Layer1ApiGridDemo as an example.
You can get the left edge timestamp from #onHeatmapTimeLeft method and the chart time width from #heatmapActiveTimeWidth method. Adding those will get you the right edge value.
3) make request to the data tree(example Layer1ApiMarkersDemo#calculateValuesInRange)
Take a look at the Layer1ApiMarkersDemo and see the #calculateValuesInRange method for an example.
Code: Select all
ArrayList<TreeResponseInterval> intervalResponse = dataStructureInterface.get(t0, intervalWidth, intervalsNumber, alias,
new StandardEvents[] {StandardEvents.TRADE});
javadoc
DataStructureInterface.get(long t0, long intervalWidth, int intervalNumber, String alias, StandardEvents[] interestedEvents)
Query for standard events Returns list, containing aggregation from start time to t0 exclusive, followed by list of aggregations for the interval [t0, t0 + intervalWidth * intervalNumbers), divided by intervalNumber parts
To get a historical orderbook you need to get aggregated depth events (StandardEvents.DEPTH) to the right adge of the chart. In your case t0 must be the timestamp on the right edge of the chart and both intervalWidth and intervalNumbers can be ignored.
4) construct a historical orderbook(example Layer1ApiMarkersDemo#calculateValuesInRange)
Again, take a look at the Layer1ApiMarkersDemo and see the calculateValuesInRange method for an example.
Code: Select all
double lastPrice = ((TradeAggregationEvent) intervalResponse.get(0).events.get(StandardEvents.TRADE.toString())).lastPrice;
In your case this line will look like
Code: Select all
DepthAggregationEvent depthEvent = (DepthAggregationEvent) intervalResponse.get(0).events.get(StandardEvents.DEPTH.toString());
DepthAggregationEvent contains maps if bids and asks so you can construct your order book and visualize it with you tools.