I'm looking for documentation on how trade execution is ordered on exchanges with non standard order types. Especially linked/contingent/stop type orders. Any exchange that implements these with continuous auction trading would be good as i'm just trying to get the general idea. I've been searching for terms like "order matching rules" "trade priority rules" etc., but all that comes up are the exchange xxx rules, which deals with trading regulations and not the intricacies of the matching algorithm. Probably i'm just searching for the wrong term.
I do get the general idea of price/time and price/pro-rate priority, but this only extends to the basic limit/market orders. As far as i know any special order is added to the book as a basic order whenever it's condition is met, timestamped at the time it was triggered. This however still leads to ambiguity. An example of such a situation is this.
The buy side of the books is this: size / price 100 @ 100 100 @ 98 200 @ 96
Also these stop loss orders are placed. size / Stop price / time / od 10 / 100 / 12:00 / s1 10 / 100 / 12:01 / s2 10 / 98 / 11:59 / s3
Assume there are no hidden orders. Now a market sell is placed for a size of 300. This raises multiple questions: - Is the adding+matching routine of a single order atomic? I.e. the market orders first matches 100 lots @ 100,-. Will any triggered stop orders be added to the book or will the order first be matched with the book as-is? Same goes for the case where the 100 @ 100 bid was actually an iceberg order - Say the entire market sell was matched setting the last price at 96. All stop order are now triggered. Stop s1 was placed before s2, yet they were triggered at the same time. s3 was placed even earlier but, triggered later and has a worse price trigger price. So how does the exchange determine the order in which the generated market orders are matched?