You are given a list data of order records. Each record is a 4-tuple:
(exchange_id, price, quantity, order_type)
exchange_id
: string/int identifying the exchange
price
: positive number
quantity
: positive integer
order_type
: either
"B"
(bid/buy) or
"A"
(ask/sell)
Implement a class QuoteBook initialized with data, supporting:
get_exchange_bbo(exchange_id) -> (best_bid, best_ask)
get_nbbo() -> (best_bid, best_ask)
Definitions:
None
for that side.
Return format:
best_bid
and
best_ask
should each be either
None
or a tuple
(price, total_quantity_at_price)
.
Constraints/expectations:
len(data)
can be large (e.g., up to 10^5 or more), so repeated calls to these methods should be efficient.