Page 1 of 4

Developing with Bookmap API (step-by-step)

Posted: Tue Oct 30, 2018 5:21 pm
by Serg
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 40267 times
02.png
02.png (17.35 KiB) Viewed 40267 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 40267 times
Once Eclipse opened, close the "Welcome" tab

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

Click on empty space under Project Explorer and select Import:

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

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

09.png
09.png (72.87 KiB) Viewed 40267 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 40267 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 40267 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>\...

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

Posted: Tue Dec 11, 2018 11:32 am
by Serg
Main post updated with a link to API documentation (javadoc)

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

Posted: Fri Feb 01, 2019 10:34 am
by Sire
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,

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

Posted: Tue Oct 15, 2019 1:41 pm
by Andry API support
Hi Sire,
is it still an issue?

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

Posted: Tue Oct 22, 2019 7:19 pm
by akuush
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.

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

Posted: Wed Oct 23, 2019 9:37 am
by Andry API support
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.

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

Posted: Sat May 23, 2020 11:19 pm
by agan1337
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
 

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

Posted: Mon May 25, 2020 11:15 am
by Andry API support
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.

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

Posted: Fri May 29, 2020 9:01 pm
by agan1337
hi AndreyR

Thank you very much
Everything is works now

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

Posted: Mon Jul 13, 2020 4:27 pm
by dm08
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