Skip to content

Quotes On Primary Exchange

Query Source: adopted from here

Introduction

The U.S. Equities market has 13 lit exchanges and each exchange reports its top of book information to SIP (Securities Information Processor), which then publishes the NBBO (National Best Bid and Offer) to the public to consume. Many institutional users can also subscribe the direct feed from each exchange and build their own limit order book. The advantages of this approach are:

  • it has smaller latency
  • direct feed contains multiple price levels of the limit order book
  • it includes odd-lot quotes

Question

To make the illustration easier, an excerpt of the consolidated limit order book is simulated as follows:

simQuote:{[venueList;nRow]
    priceList:30+0.01*til 10;
    prices:asc -3?priceList;
    venues:3?venueList;
    bidPrices:(count each venues)#'prices;
    bidExchanges:raze venues;
    (bidPrices;bidExchanges)
  };

simLob:{
    nRows:20;
    seed:-314159;
    openTime:`time$09:30;
    closeTime:`time$16:00;
    litVenues:`XNYS`ARCX`XCHI`XASE`XCIS`XNAS`XBOS`XPHL`BATS`BATY`EDGA`EDGX`IEXG;

    system "S ",string seed;
    times:asc closeTime&openTime+nRows?390*60*1000;
    nExchanges:2+nRows?(count litVenues)-8;
    bidVenues:{y?x}[litVenues;] each nExchanges;
    quotes:simQuote[bidVenues;] each til nRows;

    :([]time:times;bidPrices:raze each quotes[;0];bidExchanges:quotes[;1]);
  };
lob:simLob[];

The simulated data has three columns:

  • time: This is the timestamp of the limit order book snapshot.
  • bidPrices: It presents the multiple price levels on the buy side of the limit order book. Note that multiple exchange might quote at the same price level. The bid prices is already sorted descendingly.
  • bidExchanges: This columns corresponds to each values from bidPrices and show which exchange each bid price comes from. So bidExchanges and bidPrices have the same length element wise.

Find bid book on XNYS, i.e. New York Stock Exchange.

Answer

The first line finds the location where XNYS is present and the second line for the corresponding bid prices for XNYS. Note the use of each both in this question and the same technique is used in the question from the previous week.

lob:update nyseLoc:(where') `XNYS=bidExchanges from lob;
select time, bidPrices:bidPrices@' nyseLoc from lob

If you are a one liner, you can also do the following:

select time, bidPrices:bidPrices@' (where') `XNYS=bidExchanges from lob