API documentation

Custom indicators, trading strategies, data export and recording and more...
Serg
Posts: 113
Joined: Mon Jun 11, 2018 12:40 pm
Has thanked: 15 times
Been thanked: 35 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

    api.registerIndicator(...)
There are a couple of most simplest examples:

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

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

Best,
Bookmap team

Tags:

kahwai
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:

java.lang.NullPointerException
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)

Serg
Posts: 113
Joined: Mon Jun 11, 2018 12:40 pm
Has thanked: 15 times
Been thanked: 35 times

Re: API documentation

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

Hi,

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

@Layer1SimpleAttachable
@Layer1StrategyName("Simple Raw Data Listener")
@Layer1ApiVersion(Layer1ApiVersionValue.VERSION1)
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();

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

    @Override
    public void onDepth(boolean isBid, int price, int size) {
        Map<Integer, Integer> book = isBid ? bids : asks;
        @SuppressWarnings("unused")
        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.

birdienumnum68cr
Posts: 6
Joined: Thu Dec 16, 2021 1:56 am

Re: API documentation

Post by birdienumnum68cr » Sat Dec 18, 2021 1:05 am

Hi,

I have read through the available API docs including the Java Docs and want to confirm my understanding (or not! ) :-

I am looking to build an 'add on' that would look to pick up orders in the order book at the MBO level plus each actual trade and then periodically (based on an interval) write this out to a text file. Yes this could be large depending on the instrument, so a realistic interval would be important.

Some questions and answer would be most appreciated :-

Question 1, I can see there is interface "MarketByOrderDepthDataListener" which will give me the MBO level for Bids and Asks. I can also see the interface "OrdersListener" which gives an event for each order update (placed/cancelled/updated/filled/partially filled). Can you explain what the difference use case for either interface?

Question 2, Would I use "TradeDataListener" interface to get each individual trade events?

Question 3, Would I use "IntervalListener" interface to control the time interval that my 'add on' executes?

Question 4, What exchanges provide MBO level data? I read it is only CME Rithmic data?

Thanks,
Warren.


 

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

Re: API documentation

Post by Andry API support » Mon Dec 20, 2021 8:05 am

Hi Warren
1) OrdersListener refers only to orders placed by a user. If you want to keep track of your orders you will need OrdersListener. It will work either with MBP or MBO data.
MarketByOrderDepthDataListener will give MBO data (if ist is supported by the exchange) for all orders available at the market.
2) Right. With MBP data, there will be no order ids in the TradeInfo tradeInfo object (an argument for TradeDataListener#onTrade).
3) IntervalListener#onInterval is called referring to the value returned by IntervalListener#getInterval method.
4) updated also IQFeed v6.2(CME), Quote Media, CoinbasePro

birdienumnum68cr
Posts: 6
Joined: Thu Dec 16, 2021 1:56 am

Re: API documentation

Post by birdienumnum68cr » Tue Dec 21, 2021 8:40 am

Thank you Andrey.

I am sure there will be further questions!

birdienumnum68cr
Posts: 6
Joined: Thu Dec 16, 2021 1:56 am

Re: API documentation

Post by birdienumnum68cr » Wed Dec 29, 2021 5:44 am

Hi Audrey,

I have managed to setup Bookmap in Ubuntu Linux and the Eclipse IDE and run Bookmap via the debugger.

My question is;

If I now add an 'add on' into Bookmap by the using API Plug in option in Bookmap, Will this 'add on' stop in the debugger by setting a break point somewhere in its code in the Eclipse IDE debugger?

There doesn't seem to an explanation of how this works? How does the 'add on' execute with the same process created by the Eclipse IDE debugger?

Thanks,

Warren.

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

Re: API documentation

Post by Andry API support » Wed Dec 29, 2021 8:28 am

For debugging you need Eclipse to have :
1. a Run Configuration for Bookmap
2. a project with you addon
Then, all you need to make is an empty jar file (you may create a text file and just rename it)
bm-strategy-package-fs-root.jar
Put it into the project's ...\bin\main\ folder then run Bookmap from the Run Configuration and open this jar as an addon.
Eclipse should use the debugger over your project's code and stop at all your breakpoints.

birdienumnum68cr
Posts: 6
Joined: Thu Dec 16, 2021 1:56 am

Re: API documentation

Post by birdienumnum68cr » Thu Dec 30, 2021 12:39 am

Hi Andrey,
This worked!
Thank you for the quick and helpful responses.
Warren.

birdienumnum68cr
Posts: 6
Joined: Thu Dec 16, 2021 1:56 am

Re: API documentation

Post by birdienumnum68cr » Mon Jan 10, 2022 9:47 am

Hi Andrey,

I downloaded the DemoStrategies sample add on and am inspecting the code.

I noticed API Version is "2" and not "1".

A snipet of code :-
@Layer1Attachable
@Layer1StrategyName("FeedRecorder demo")
@Layer1ApiVersion(Layer1ApiVersionValue.VERSION2)
public class FeedRecorder implements Layer1CustomPanelsGetter, Layer1ApiDataAdapter, Layer1ApiFinishable,
        Layer1ApiInstrumentAdapter, Layer1ApiTradingAdapter {
        etc....
}


Q. I have extracted the JavaDocs from the install tarball and this looks like this is current to Version 1 only?

Q. I cannot see the above interfaces mentioned in the method definition above i.e Layer1ApiDataAdapter, Layer1ApiFinishable, Layer1ApiInstrumentAdapter and Layer1ApiTradingAdapter?

Is the JavaDoc lagging behind or am I missing something here. I downloaded the linux install as I am on Ubuntu.

Thanks,
Warren.




Warren.

Post Reply