Support Board
Date/Time: Fri, 22 Nov 2024 10:03:26 +0000
[Programming Help] - Rebuilding LOB from MarketDepth file
View Count: 116
[2024-10-14 19:10:49] |
ThePeeKay - Posts: 7 |
Hello, I'm trying to rebuild LOB for the first 6 levels based on the .depth format. I have the parsing code and can look at all the commands available based on the documentation, but I need some help to be able to understand how these commands work to build the actual LOB myself. So can you please take a look below and correct me? I want to generate specific metrics based on bid/ask size etc. and running this on replay takes forever, as it's per tick and the study needs to run at per tick so I cannot increase the speed to more than 1X, because then it doesn't output my calculations from the study, as its not running per tick anymore. So I though I would just parse the .depth file directly to generate my metrics. I suppose that COMMAND_ADD_BID_LEVEL and COMMAND_DELETE_BID_LEVEL (same for ask) is interpreted as "Create this entry at Price XXXX on the bid or ask side so we can track orders" I use this format -> Record Timestamp Command Flags NumOrders Price Quantity So here 30 30:00.0 COMMAND_ADD_BID_LEVEL 0 1 20361 5, it says "Start 20361 level and add 1 order with 5 contracts"? Then this -> 3685 30:03.5 COMMAND_DELETE_BID_LEVEL 0 0 20361 0, it says "Delete the bid level at 20361 because the order was removed, so nothing there" 4243 30:03.5 COMMAND_ADD_BID_LEVEL 0 1 20361 5 -> Here we add it again And then this says 6593 30:05.0 COMMAND_MODIFY_BID_LEVEL 1 2 20361 7, Now we have 2 orders for a total quantity of 7 at 20361 on the BID. This basically means we added an order, but if we compare it to the previous one, we know we added one more, with a size of 2?, which is why we went from 1 order to 2 and quantity went from 5 to 7. But then this says 8301 30:06.9 COMMAND_MODIFY_BID_LEVEL 1 1 20361 5, Now we have 1 order for a total quantity of 5 at 20361 on the BID. Here is seems that the order added above, was removed. Do I understand this correctly? Each MODIFY is not "additive" to the previous one, but more like "Here is how many orders at that level, and there is the quantity aggregate for these orders". Full parsed depth below: E.g. Record Timestamp Command Flags NumOrders Price Quantity 30 30:00.0 COMMAND_ADD_BID_LEVEL 0 1 20361 5 3685 30:03.5 COMMAND_DELETE_BID_LEVEL 0 0 20361 0 4243 30:03.5 COMMAND_ADD_BID_LEVEL 0 1 20361 5 6593 30:05.0 COMMAND_MODIFY_BID_LEVEL 1 2 20361 7 8301 30:06.9 COMMAND_MODIFY_BID_LEVEL 1 1 20361 5 13942 30:14.4 COMMAND_MODIFY_BID_LEVEL 1 2 20361 6 18048 30:25.2 COMMAND_MODIFY_BID_LEVEL 1 1 20361 5 94823 37:23.7 COMMAND_MODIFY_BID_LEVEL 1 2 20361 6 97403 37:49.7 COMMAND_MODIFY_BID_LEVEL 1 3 20361 7 104703 38:30.5 COMMAND_MODIFY_BID_LEVEL 1 2 20361 2 108767 39:02.2 COMMAND_MODIFY_BID_LEVEL 1 3 20361 3 110099 39:07.9 COMMAND_MODIFY_BID_LEVEL 1 2 20361 2 110952 39:14.0 COMMAND_MODIFY_BID_LEVEL 1 3 20361 3 111807 39:19.7 COMMAND_MODIFY_BID_LEVEL 1 2 20361 2 114110 39:30.4 COMMAND_MODIFY_BID_LEVEL 1 3 20361 3 115482 39:44.2 COMMAND_MODIFY_BID_LEVEL 1 4 20361 4 116240 39:50.0 COMMAND_MODIFY_BID_LEVEL 1 5 20361 8 116494 39:51.0 COMMAND_MODIFY_BID_LEVEL 1 6 20361 23 116605 39:51.3 COMMAND_MODIFY_BID_LEVEL 1 5 20361 8 116666 39:51.6 COMMAND_MODIFY_BID_LEVEL 1 6 20361 9 116669 39:51.6 COMMAND_MODIFY_BID_LEVEL 1 7 20361 24 116670 39:51.6 COMMAND_MODIFY_BID_LEVEL 1 8 20361 26 Date Time Of Last Edit: 2024-10-14 19:12:14
|
To post a message in this thread, you need to log in with your Sierra Chart account: