Use OrderByOrderBook

Custom indicators, trading strategies, data export and recording and more...
rickbarlow
Posts: 43
Joined: Mon Feb 08, 2021 5:37 pm
Been thanked: 1 time

Use OrderByOrderBook

Post by rickbarlow » Mon Feb 08, 2021 5:53 pm

I've been able to modify some of the samples provided, such as the MBO Visualizer, etc.

What I would like to do is to capture the standing order id's on each side (Bid and Ask) at the beginning of the day, and track them throughout the day as more Depth is added/removed and Trades are occurring. It looked like I should be using the OrderByOrderBook class, but I am unable to get any records from it when I am iterating through the class. Here is the pseudocode workflow of what I would like to do. Do you have any sample code that would help me along?

1) During initialization :
     OpenStanding OrderBook. 
     For each standing order id, store current status (price, size, bid/ask) in an array.

2) During Runtime :
     a) Upon receipt of OrderBook call (Send, Replace, Cancel), modify my copy of OrderBook entries.
     b) Upon receipt of a Trade occurrence, note trade information order ids, and size, and update my copy of OrderBook entries.

I am using 7.1 version of bookmap.
 

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

Re: Use OrderByOrderBook

Post by Andry API support » Tue Feb 09, 2021 1:28 pm

hi rickbarlow,
1)
 It looked like I should be using the OrderByOrderBook class, but I am unable to get any records from it when I am iterating through the class
Can you pls clarify the kind of info you need. OrderByOrderBook has getAllIds() method which returns a collection of current orders ids.
Once you have ids you can extract any single order with getOrder(...) method.
2) 
During Runtime :
b) Upon receipt of a Trade occurrence, note trade information order ids, and size, and update my copy of OrderBook entries.
replace(...) method for MarketByOrderDepthDataListener already contains the changes caused by trades.
You don't need to update the orderbook from onTrade method.

Pls take a look at the source file attached. I used OrderByOrder book there. Please note it uses numerical ids so I had to keep a map to turn text ids to numerical ids. I used bidimap to be also able to get text ids from numerical ids. If you do so pls add to your build.gradle dependencies section

Code: Select all

        compileOnly 'org.apache.commons:commons-collections4:4.1'

 
Attachments
MboOrderByOrderBook.java
(2.59 KiB) Downloaded 176 times

Post Reply