Developing with Bookmap API (step-by-step)

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

Developing with Bookmap API (step-by-step)

Post by Serg » Tue Oct 30, 2018 5:21 pm

A recommended background for this post is: Summary
This post provides a step-by-step instructions for how to import an example collection of custom modules into your Java development environment and how to export a Jar file that can be imported into Bookmap.

Step 1: Download the project

Download the Github project as a zip file and extract it:

01.png (76.42 KiB) Viewed 16939 times
02.png (17.35 KiB) Viewed 16939 times
Step 2: Prepare your Java development environment (IDE)
This is a Gradle project and can be imported into any Gradle supporting Java IDE. Here we use Eclipse Photon for demonstration. Make sure you have Java Development Kit (JDK) 8 installed. Launch Eclipse and create a workspace (not in the same folder where the project is):

03.png (17.68 KiB) Viewed 16939 times
Once Eclipse opened, close the "Welcome" tab

04.png (111.35 KiB) Viewed 16939 times
Step 3: Gradle

Make sure you have Gradle integrated into Eclipse. Go to Help->Eclipse marketplace..., search for "Buildship" and install if it wasn't installed already:

05.png (89.91 KiB) Viewed 16939 times
Step 4: Import the project

Click on empty space under Project Explorer and select Import:

06.png (76.22 KiB) Viewed 16939 times
Select Existing Gradle project, click Next and select the unzipped project folder, and click Finish:

07.png (74.71 KiB) Viewed 16939 times
08.png (76.01 KiB) Viewed 16939 times
Few seconds later you should see the project successfully loaded with all dependencies:

09.png (72.87 KiB) Viewed 16939 times
Step 5: Export the project as a Jar file

Before you start developing your own custom modules, let's export the existing project as a jar file and make sure it works with Bookmap. Right-click on the project, click Export, choose Jar file, and click Next:

10.png (90.19 KiB) Viewed 16939 times
In the next window you can uncheck the project and then select only "src/main/java" as shown below. Also, set a path and name for your Jar file and click Finish:

11.png (96.98 KiB) Viewed 16939 times
Congratulations! You have created a jar file with Bookmap API custom modules. Now import it into Bookmap and if everything works well, start developing your own custom modules.

Isolating your code from the demo project
At some point you'd probably wish to isolate your development from the demo project. Here are 2 simplest ways to do it while keeping the necessary API dependencies:
  • Create folders / packages of your own development somewhere inside the demo project (should be somewhere under \src\main\java\...) and then export into a jar just the package that you wish to export instead of the whole project.
  • Create a copy the entire demo project and then delete from it everything that you don't need. Note that eclipse still expects the top structure of the source code to be \src\main\java\, but what's inside it is up to you. If you wish to follow the java naming convention, create the structure to be like this: \src\main\java\com\bookmap\api\<your name>\<your indicator>\...


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

Re: Developing with Bookmap API (step-by-step)

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

Main post updated with a link to API documentation (javadoc)

Posts: 3
Joined: Fri Feb 01, 2019 12:04 am
Been thanked: 1 time

Re: Developing with Bookmap API (step-by-step)

Post by Sire » Fri Feb 01, 2019 10:34 am

Hi Serg,

Following the procedure with eclipse (IDE 2018) and Javasdk (including JRE) to import the simple demo master folder, several errors appears.

It seem dependencies are not appearing.

Any idea to solve this.

by advance,
Eclipse import - pb.png
Eclipse import - pb.png (361.56 KiB) Viewed 16360 times

Posts: 228
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 12 times
Been thanked: 43 times

Re: Developing with Bookmap API (step-by-step)

Post by AndreyR » Tue Oct 15, 2019 1:41 pm

Hi Sire,
is it still an issue?

Posts: 1
Joined: Tue Oct 22, 2019 7:15 pm

Re: Developing with Bookmap API (step-by-step)

Post by akuush » Tue Oct 22, 2019 7:19 pm

I'm using Eclipse 2019, Java 13 and BuildShip 3.0 and I'm having the same error. Looks like the dependencies are not appearing...Do you need to rebuild the 'simple-demo' project with BuildShip 3.0 to work?

I can't install BuildShip 2.0.

Please help.

Posts: 228
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 12 times
Been thanked: 43 times

Re: Developing with Bookmap API (step-by-step)

Post by AndreyR » Wed Oct 23, 2019 9:37 am

Hi akuush,
looks like dependencies are missing. Make a gradle refresh first (take a look at the screenshot attached).
If there's no Gradle in the context menu choose Configure -> add Gradle nature.
Although your issue may look exactly like Sire's issue we need your full-sized screenshot.
ak01.jpg (31.24 KiB) Viewed 13817 times

Posts: 1
Joined: Tue Dec 10, 2019 9:31 pm

Re: Developing with Bookmap API (step-by-step)

Post by agan1337 » Sat May 23, 2020 11:19 pm


I have multiple issues with modification of code
Every time when I modify any part of the code , after compiling when I try to insert it in BM -  I get error

Modification was just in GraphType:

    public void initialize(String alias, InstrumentInfo info, Api api, InitialState initialState) {
        indicator = api.registerIndicator("Moving Average", GraphType.BOTTOM);
        this.lastTradePrice = initialState.getLastTradePrice();

Does not matter what I change - same error

Could you please help

Thank you


java.lang.NoClassDefFoundError: Lcom/bookmap/api/simple/demo/utils/data/MovingAverage;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(
    at java.lang.Class.getDeclaredFields(
    at velox.api.layer1.simplified.InstanceUtils.isTypeAllowed(
    at velox.api.layer1.simplified.SimplifiedL1ApiLoader.onInstrumentAdded(
    at velox.bookmap.ev.onInstrumentAdded(SourceFile:156)
    at velox.bookmap.fO.a(SourceFile:135)
    at velox.bookmap.dx.a(SourceFile:61)
    at velox.bookmap.fO.onInstrumentAdded(SourceFile:135)
    at velox.bookmap.eF.a(SourceFile:67)
    at velox.bookmap.eF.a(SourceFile:48)
    at velox.bookmap.eF.b(SourceFile:248)
    at velox.api.layer1.layers.Layer1ApiInjectorRelay.lambda$inject$0(SourceFile:45)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.ClassNotFoundException:
    at velox.bookmap.uW.findClass(SourceFile:103)
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    ... 17 more

Posts: 228
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 12 times
Been thanked: 43 times

Re: Developing with Bookmap API (step-by-step)

Post by AndreyR » Mon May 25, 2020 11:15 am

Hi agan1337!
If you're compiling one indicator class you're likely to get errors like these.
Your class uses dependencies which cannot be found at runtime and that is what causes exceptions.
I would recommend compiling the whole project rather than one class.

Post Reply