Page 1 of 1

Java Simplified API: Question regarding accessing Orderbook data

Posted: Tue Apr 02, 2024 5:46 pm
by wavezerollc
Hello all, 

I am currently trying to figure out how I can access orderbook data from within the Java API. Here's what I have so far:

If you see in my debugger, I can view the orderbook object if I insert a breakpoint in my overridden onBar function. I can view Bar data with the built in Bar object no problem. For example:
bar.getClose(); if I want to access the last closing price of said bar.

However, anytime I try to access any kind of orderbook information, for instance:orderBook.getBestAskPriceOrNone();I get the following error in my Bookmap.jar instance when I reload my addon:

java.lang.NullPointerException: Cannot invoke "velox.api.layer1.layers.utils.OrderBook.getBestAskPriceOrNone()" because "orderBook" is null


Obviously, as you can see from the screenshot included, that orderBook is not null. I am assuming this is because I am using the free version of Bookmap for development right now and I have not purchased an MBO data package. 

I would like to know if this is something I need to do, and if so, is there anyway to access COB data without having an MBO data subscription?

Thank you for your help in advance. Have a good day!

Re: Java Simplified API: Question regarding accessing Orderbook data

Posted: Wed Apr 03, 2024 6:29 am
by Andry API support
Thx for your question, we will figure that out. API should work correctly for any Bookmap package.

Re: Java Simplified API: Question regarding accessing Orderbook data

Posted: Wed Apr 03, 2024 10:39 am
by Andry API support
Order book can be null if depth data starts a bit late which may be at the very beginning of data feed. Please check if it is null before accessing it.

Code: Select all

    @Override
    public void onBar(OrderBook ob, Bar bar) {
        if (ob != null) {
            //your code here

Re: Java Simplified API: Question regarding accessing Orderbook data

Posted: Fri Apr 05, 2024 11:39 pm
by wavezerollc
Hi Andry,

Thank you so much that worked perfectly! That probably saved me a whole day or two of going on wild goose chases😂