Drag-Mode and historical data

Market data, Trading, Technical support, Features requests, etc
bronko
Posts: 13
Joined: Tue Dec 22, 2020 2:22 pm

Drag-Mode and historical data

Post by bronko » Mon Dec 20, 2021 7:51 am

Hi,

when I'am in "drag mode" on the heatmap chart and moving the chart, then I can see the historical data of the orderbook. That's a nice feature.

I've an addon that displays some data in the heartmap based on orderbook data. Is there any bookmap-api support to use this historical data feature for my addon?

Thanks,
bronko

 

Andry API support
Posts: 548
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 25 times
Been thanked: 85 times

Re: Drag-Mode and historical data

Post by Andry API support » Mon Dec 20, 2021 12:55 pm

Hi bronko,
you'll need to modify the addon to receive the historical data. Can you modify your addon? Sorry for any misunderstanding, I need to figure out if the addon you have can be modified or not.

bronko
Posts: 13
Joined: Tue Dec 22, 2020 2:22 pm

Re: Drag-Mode and historical data

Post by bronko » Mon Dec 20, 2021 1:03 pm

Yes, I can modify my addon. 
Are you talking about the interfaces "HistoricalDataListener/HistoricalModeAdapter" when you say "receive the historical data"?

How I can use them?

Thanks,
bronko 

Andry API support
Posts: 548
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 25 times
Been thanked: 85 times

Re: Drag-Mode and historical data

Post by Andry API support » Mon Dec 20, 2021 4:17 pm

Hi,
HistoricalDataListener/HistoricalModeAdapter are interfaces for Simplified API which make your addon receive historical data (data starting from the moment Bookmap was loaded to the point the addon was loaded).

Code: Select all

(a moment in the past)----BackfilledDataListener--->(Bookmap started)---->HistoricalDataListener--->(Addon started)
when I'am in "drag mode" on the heatmap chart and moving the chart, then I can see the historical data of the orderbook.
...
I've an addon that displays some data in the heartmap based on orderbook data.
Do you mean you need your addon to react to the data shown on the chart while dragging the chart (or reacting to the historical orderbook changing its state while dragging the chart)?

bronko
Posts: 13
Joined: Tue Dec 22, 2020 2:22 pm

Re: Drag-Mode and historical data

Post by bronko » Tue Dec 21, 2021 12:00 pm

Hi,
I mean reacting to the historical orderbook changing its state while dragging the chart.

Thanks.
bronko

Andry API support
Posts: 548
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 25 times
Been thanked: 85 times

Re: Drag-Mode and historical data

Post by Andry API support » Thu Dec 23, 2021 3:25 pm

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.

Post Reply