The question was to take a stream of buy/sell requests for an asset and put together an order book.
The structure of the data was this:
{ "type": "buy", "price": 10.0, "quantity": 0.3 }
{ "type": "buy", "price": 9.5, "quantity": 2.9 }
{ "type": "buy", "price": 9.0, "quantity": 0.1 }
{ "type": "buy", "price": 8.5, "quantity": 1.2 }
{ "type": "sell", "price": 10.5, "quantity": 2.4 }
{ "type": "sell", "price": 11.0, "quantity": 1.4 }
{ "type": "sell", "price": 11.5, "quantity": 1.3 }
{ "type": "sell", "price": 12.0, "quantity": 0.9 }
The question was:
Write some code to operate a fake order book that accepts buy and sell orders. Populate the orderbook with some buy and sell orders using price increments of 0.5 and pseudo-random values for the quantity. The end result should look similar to the example(s) above.
It should:
1. Update the state of the orderbook as appropriate.
2. Produce trades as appropriate.