Developing with Bookmap API (step-by-step)

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

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
01.png (76.42 KiB) Viewed 40413 times
02.png
02.png (17.35 KiB) Viewed 40413 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
03.png (17.68 KiB) Viewed 40413 times
Once Eclipse opened, close the "Welcome" tab

04.png
04.png (111.35 KiB) Viewed 40413 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
05.png (89.91 KiB) Viewed 40413 times
Step 4: Import the project

Click on empty space under Project Explorer and select Import:

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

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

09.png
09.png (72.87 KiB) Viewed 40413 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
10.png (90.19 KiB) Viewed 40413 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
11.png (96.98 KiB) Viewed 40413 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>\...

Tags:

Serg
Posts: 113
Joined: Mon Jun 11, 2018 12:40 pm
Has thanked: 15 times
Been thanked: 35 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)

Sire
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,
Attachments
Eclipse import - pb.png
Eclipse import - pb.png (361.56 KiB) Viewed 39852 times

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

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

Post by Andry API support » Tue Oct 15, 2019 1:41 pm

Hi Sire,
is it still an issue?

akuush
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.

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

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

Post by Andry API support » 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.
Attachments
ak01.jpg
ak01.jpg (31.24 KiB) Viewed 37336 times

agan1337
Posts: 10
Joined: Tue Dec 10, 2019 9:31 pm
Been thanked: 1 time

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

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

Hi

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:

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

Does not matter what I change - same error

Could you please help

Thank you

AG


java.lang.NoClassDefFoundError: Lcom/bookmap/api/simple/demo/utils/data/MovingAverage;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at velox.api.layer1.simplified.InstanceUtils.isTypeAllowed(InstanceUtils.java:588)
    at velox.api.layer1.simplified.SimplifiedL1ApiLoader.onInstrumentAdded(SimplifiedL1ApiLoader.java:491)
    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.br.a(SourceFile:432)
    at velox.bookmap.eF.b(SourceFile:248)
    at velox.api.layer1.layers.Layer1ApiInjectorRelay.lambda$inject$0(SourceFile:45)
    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)
Caused by: java.lang.ClassNotFoundException: com.bookmap.api.simple.demo.utils.data.MovingAverage
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at velox.bookmap.uW.findClass(SourceFile:103)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more
 

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

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

Post by Andry API support » 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.

agan1337
Posts: 10
Joined: Tue Dec 10, 2019 9:31 pm
Been thanked: 1 time

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

Post by agan1337 » Fri May 29, 2020 9:01 pm

hi AndreyR

Thank you very much
Everything is works now

dm08
Posts: 1
Joined: Mon Jul 13, 2020 4:17 pm

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

Post by dm08 » Mon Jul 13, 2020 4:27 pm

pretty new to entire process..managed to import demo pro but exporting it presents an issue, don't really know if it is operator error or not but will attach eclipse screen shots so someone can enlighten me ... thanx
Attachments
Screen Shot 2020-07-13 at 9.09.59 AM.png
Screen Shot 2020-07-13 at 9.09.59 AM.png (406.3 KiB) Viewed 17353 times

Post Reply