API documentation

Custom indicators, trading strategies, data export and recording and more...
Posts: 106
Joined: Mon Jun 11, 2018 12:40 pm
Has thanked: 15 times
Been thanked: 28 times

API documentation

Post by Serg » Tue Dec 11, 2018 11:18 am

The documentation for the Bookmap API is included in Bookmap installer. Click here to download the installer. After installation copy the documentation jar file "C:\Program Files\Bookmap\lib\bm-simplified-api-wrapper-javadoc.jar" to somewhere and extract it like a zip file (for instance, with 7z). Then double click on index.html to open it in a browser.

The most important items in the list on the left are the first two: AllDataModule and Api.
  • AllDataModule. This page lists all interfaces that your custom module may implement. For instance, if it needs to receive trades in the form of Times&Sales, it needs to implement TradeDataListener interface and will receive the trades via

    Code: Select all

    onTrade(double price, int size, TradeInfo tradeInfo)
  • Api. This page describes how your custom module can call the Api, for instance, if it needs to draw lines/indicators it needs to register the line:

    Code: Select all

There are a couple of most simplest examples:

Raw data listener
example2.jpg (102.52 KiB) Viewed 14279 times
Even simpler
example1.jpg (55.61 KiB) Viewed 14279 times
You can find more examples on Bookmap GitHub page in projects called DemoStrategies and simple-demo.

For getting started quickly, please review Bookmap API highlights and Developing with Bookmap API (step-by-step).

Bookmap team


Posts: 9
Joined: Fri Dec 07, 2018 12:55 am
Been thanked: 1 time

Re: API documentation

Post by kahwai » Tue Dec 11, 2018 4:05 pm

example2.jpg throws error when loaded the strategy:

Full report content:

at velox.api.layer1.simplified.SimplifiedL1ApiLoader.lambda$onStrategyCheckboxEnabled$4(SimplifiedL1ApiLoader.java:1147)
at velox.api.layer1.layers.Layer1ApiInjectorRelay.lambda$inject$0(SourceFile:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Posts: 106
Joined: Mon Jun 11, 2018 12:40 pm
Has thanked: 15 times
Been thanked: 28 times

Re: API documentation

Post by Serg » Wed Dec 12, 2018 12:11 pm


It wasn't supposed to be taken as is, but here is a fix. The code on the image is missing implementation of CustomModuleListener interface, which has methods initialize() and stop(). If you don't need these methods, you can implement CustomModuleAdapter instead as shown here:

Code: Select all

@Layer1StrategyName("Simple Raw Data Listener")
public class SimpleRawMbpDataListener implements CustomModuleAdapter, DepthDataListener, TradeDataListener {

    protected final TreeMap<Integer, Integer> bids = new TreeMap<>(Collections.reverseOrder());
    protected final TreeMap<Integer, Integer> asks = new TreeMap<>();
    Bar bar = new Bar();

    public void onTrade(double price, int size, TradeInfo tradeInfo) {
        bar.addTrade(tradeInfo.isBidAggressor, size, price);

    public void onDepth(boolean isBid, int price, int size) {
        Map<Integer, Integer> book = isBid ? bids : asks;
        Integer previousSize = size == 0 ? book.remove(price) : book.put(price, size);
Also, note that market data isn't available via API for dxFeed data, click here for more details.

Post Reply