I am developing an order matching system and I have a few scenarios that I would like to confirm my understanding of.
From my understanding, a stop order will be activated when the last traded price reaches the stop price of the order. Does a stop order activate if there exists an order in the book that satisfies the stop price of the order but the last traded price does not? For example, suppose the book is initially empty, the last bid price is 80, and a bid limit order is placed with a price of 100. Now, suppose that a stop market order on the ask side is placed with a stop price of 90. Would the stop order be activated? I would assume not, because the last traded price is still 80 - some trade would need to occur such that the last bid price became 90 or greater even though there exists a suitable offer.
My next question concerns volume. What happens if stop market orders are activated and there is zero volume in the book? Suppose that there are no orders in the book and the last ask price is 100. Now, suppose that a stop market order on the bid side is placed with a stop price of 100. Will that stop order be activated but not filled? Or will it not be activated since there is zero volume?
Apologies if this question has been asked before and thanks for any input in advance.