Post
Topic
Board Exchanges
Topic OP
Stoplimit orders priority
by
coolbits
on 29/05/2022, 19:40:45 UTC
Mods: please move it somewhere if it does not belong here. Couldn't find a better suited subforum.

I'm writing a trading engine and am right now at the point where I am implementing Stop-limit order logic.

I have a simple question:

Let L1 be a taker limit order that a customer just submitted, and it matches a maker book order.
Let SL1 and SL2 stop-limit orders with a stop price that will be triggered by the execution of L1.
Let SL3 a stop-limit order with a stop price that will be triggered by the execution of SL1

SL3 has been created BEFORE SL2.


The cascade of stop price triggering would look like that.

Code:
                       L1
                       |
                  SL1--|--SL2
                   |
                  SL3

Question 1: Which one should be executed first, SL2 or SL3 ?  (remember, SL3 is an older order than SL2)

Question 2: If we do not take into account the date of order creation at all, should I execute vertically down first, or fill the orders horizontally first, then go down a level?

Question 3: Forget SL3. Generally speaking, how do we pick the first order to be executed between SL1 and SL2? Creation time, stop price, or a combination of both? Or some other factor?


Thanks!