Implement a class structure to manage a stream of incoming market data.
Treat each row in market_data as an incoming event. A usable event has non-null, positive bid and ask prices, with the bid no greater than the ask. Return the latest usable event for every known instrument.
instrument_id, symbol, received_at, bid_price, ask_price, bid_size, ask_size.symbol ascending; for equal timestamps, use the highest event_id.| Column | Type | Description |
|---|---|---|
| instrument_idPK | INT | Unique instrument identifier |
| symbol | VARCHAR(20) | Tradable instrument symbol |
| asset_class | VARCHAR(20) | Instrument asset class |
| Column | Type | Description |
|---|---|---|
| event_idPK | BIGINT | Unique incoming market-data event |
| instrument_id | INT | Referenced instrument identifier |
| received_at | TIMESTAMPTZ | Time the event was received |
| bid_price | NUMERIC(14,4) | Best bid price |
| ask_price | NUMERIC(14,4) | Best ask price |
| bid_size | INT | Quantity available at the bid |
| ask_size | INT | Quantity available at the ask |