Reconstructing OHLC and Volume from an order book (BATS PITCH data)

Discussion in 'Data Sets and Feeds' started by Iggy_Type_R, Apr 6, 2011.

  1. Hi,

    This may be a really noob question, but I am having a bit of trouble figuring out how to code a script to convert a full order book (from BATS trading PITCH data set) to a traditional 1 minute OHLC/V data set...
    has anyone come across this? thank you in advance!
  2. mickmak


    has anyone come across what? the same issues - you didn't say what trouble you are having.
  3. The good news is I think you only need to look at the Trades and can avoid doing all the parsing that would be needed to reconstruct the book. So, you can just step through ticks and track open (last trade of previous bar), high, low, and a running sum of the volume, rinse and repeat.

    If you needed Level 1 ticks, for example, you would have to track each order in the book, determine what comprises the BBO, etc. I wrote C++ code to do that for a job interview. It's similar to the programming problem for the quant cup:

    (The code I wrote isn't optimized).
  4. Thank you very much for the reply! :)

    BATS PITCH data has a long list of Add orders and then a load of Cancel orders too... 30-40 million records per day... and actual EXECUTED trades are intermittent in those.

    So lines go like this:

    Add Order
    Add Order
    Cancel Order
    Add Order
    Cancel Order
    Executed Order
    Trade Order
    etc etc

    An executed order is always tied to an Add order (through an ID), so I have to keep track of all Add/Cancels. Trade orders are non-displayed orders... BATS say that to build your book you need to combine traded and executed orders.

    My question/confusion is then building the Open price... is that the first EXECUTED order or is it either TRADE OR EXECUTED order type message?
  5. Ah, I see. I think it's the first of either trade or executed. They both have timestamps for when it's happening - though maybe you'll want to compare the timestamp on trades to see if there is some lag. Trades come with price information and executions I guess you'll have to keep a hash of orders with prices around to lookup from.

    Interesting stuff.