Java Simplified API: Question regarding accessing Orderbook data

Market data, Trading, Technical support, Features requests, etc
wavezerollc
Posts: 2
Joined: Tue Apr 02, 2024 5:30 pm
Has thanked: 1 time
Been thanked: 2 times

Java Simplified API: Question regarding accessing Orderbook data

Post by wavezerollc » Tue Apr 02, 2024 5:46 pm

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!
Attachments
OrderbookQuestion2.png
OrderbookQuestion2.png (44.46 KiB) Viewed 313 times
OrderbookQuestion.png
OrderbookQuestion.png (322.99 KiB) Viewed 313 times

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

Re: Java Simplified API: Question regarding accessing Orderbook data

Post by Andry API support » Wed Apr 03, 2024 6:29 am

Thx for your question, we will figure that out. API should work correctly for any Bookmap package.

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

Re: Java Simplified API: Question regarding accessing Orderbook data

Post by Andry API support » Wed Apr 03, 2024 10:39 am

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

wavezerollc
Posts: 2
Joined: Tue Apr 02, 2024 5:30 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Java Simplified API: Question regarding accessing Orderbook data

Post by wavezerollc » Fri Apr 05, 2024 11:39 pm

Hi Andry,

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

Post Reply