FastPrepExchange BBO and Market-Wide NBBO

Exchange BBO and Market-Wide NBBO

Citadel logoCitadel● HardNEW GRADPHONE SCREEN
Learn

Problem statement

Process order-book commands. ADD exchange side price quantity adds positive quantity at an integer price on side BID or ASK. Quantities at an identical exchange, side, and price aggregate.

BBO exchange emits that exchange's best bid and best ask as price@quantity,price@quantity. NBBO emits the exchange and level for the market's highest bid and lowest ask as exchange:price@quantity,exchange:price@quantity. Use NA for a missing side. On a tied market price, choose the lexicographically smallest exchange. Return all query outputs in order.

Function

orderBookQuotes(operations: String[]) → String[]

Examples

Example 1

operations = ["ADD X BID 100 3","ADD X ASK 105 2","BBO X","NBBO"]return = ["100@3,105@2","X:100@3,X:105@2"]

X supplies both local and national best quotes.

Example 2

operations = ["ADD X BID 99 2","ADD Y BID 101 4","ADD X ASK 106 1","ADD Y ASK 104 5","NBBO"]return = ["Y:101@4,Y:104@5"]

Y has both the highest bid and lowest ask.

Example 3

operations = ["ADD X BID 100 2","ADD X BID 100 7","BBO X","BBO Z"]return = ["100@9,NA","NA,NA"]

Same-price quantity aggregates; Z has no orders.

Constraints

  • 1 <= operations.length <= 10^5.
  • Exchange names contain no spaces; prices and quantities are positive integers.
  • Commands are valid and only ADD, BBO, and NBBO occur.

More Citadel problems

See Citadel hiring insights
public String[] orderBookQuotes(String[] operations) {
    // Write your solution here.
}
operations["ADD X BID 100 3","ADD X ASK 105 2","BBO X","NBBO"]
expected["100@3,105@2", "X:100@3,X:105@2"]
Checking account…