Snapshot of Market Depth

Custom indicators, trading strategies, data export and recording and more...
phil83
Posts: 5
Joined: Wed Jul 22, 2020 5:29 pm

Snapshot of Market Depth

Post by phil83 » Wed Jul 22, 2020 5:38 pm

Hi everyone,

I couldnt find anything in the documentation or online. So hopefully you can help

Id like to create a snapshot of the market depth in the method initialize of the data recorder. So going through all available price levels and get price level and corresponding limit order volume in the order book and save it as an array, once at initialization.

My approach was to use the onDepth method and the OrderBookSum class but of course this just works only onDepth event (the Treemap is only filled incrementally at onDepth and empty on initialize). Id like the snapshot of the order book once on initialize. 

How could I do that?

Thank you
Best
Philipp

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

Re: Snapshot of Market Depth

Post by Andry API support » Thu Jul 23, 2020 8:38 am

Hi Philipp,
By snapshot of depth I mean a filled OrderBook here.
You can implement SnapshotEndListener interface. Create an OrderBook object and call onUpdate method for every onDepth event. You will know where snapthot ends as soon as onSnapshotEnd() method is called.
If you need to get snapshots regularly you can implement BarDataListener interface. Return the interval you need in getInterval() method and you will receive snapthots every [interval] in onBar method.
There is javadoc in Bookmap folder. For SimplifiedAPI:
C:\Program Files\Bookmap\lib\bm-simplified-api-wrapper-javadoc.jar
Just rename .jar to .zip so you can unzip it and open the index.html with your browser.

phil83
Posts: 5
Joined: Wed Jul 22, 2020 5:29 pm

Re: Snapshot of Market Depth

Post by phil83 » Fri Jul 24, 2020 2:03 pm

Hi Andrey, 

yes that worked fine. 
Thanks for the help!!

Best
Philipp

Post Reply