I'm working on a coding problem that I was given for simulating a stock market simulator. I don't really know anything about the stock market, but the instructions state that stock market domain knowledge isn't necessary to complete this coding problem. I'm still a bit confused however, and was hoping someone here could help interpret this for me.
The problem is as follows:
You're given a list of buy and sell orders represented as [buy or sell, quantity that is for sell or for buy, price]. e.g., [sell, 50, 4.50]. The order in which these orders are given is in chronological order. You're also told that a buyer has a maximum price in which they will pay for the item, and correspondingly, the seller has a minimum price in which they will sell their order. As long as there is a set of buy and sell orders that match this criteria, a transaction will occur. The cost of the transaction is in accordance with whichever order appeared first. Simulate this with code.
There's a lot of ambiguities, and unfortunately, I wasn't given more information, but I'm not sure if these are actually ambiguities, or if it's just my ignorance due to lack of experience in this area.
Some things that I think are ambiguous are:
(1) Is the given price, a price per unit quantity, or for the entirety of the quantity? e.g., is 4.50 for the entire 50 units, or is it $4.50 per unit (so 4.50*50 for the entire order)? Is there some kind of industry standard for this?
(2) We are told that the seller and buyers have their minimum and maximum bounds for selling and buying their desired item. Is this bound the price that is given? e.g., [sell, 50, 4.50] means that that specific seller will not go below 4.50? If so, that's kind of confusing to me? Why would they broadcast their lowest price instead of marking it up? On the other hand, if that's not their lowest price, then I assume that the given price is just their asking price, but then I guess we would need to be provided with their lowest price somehow?
(3) Can you partially fulfill an order? e.g., say the first order is [sell, 10, 5.50] and the second order is [buy, 8, 6.00]. Can the buyer simply get 8 units from the seller (i.e., fulfill his buy order entirely and then leave that sell order with 2 units?), or do they have to buy all 10 orders?
This isn't "supposed" to be a difficult problem, and I don't think it would be algorithmically. I just don't understand the question's parameters.
I tagged "orderbook" but I don't think this problem is the classical order book problem?