Post
Topic
Board Exchanges
Re: Stoplimit orders priority
by
coolbits
on 30/05/2022, 14:47:47 UTC
Thanks for your reply.

When I say X has been created before Y, it doesn't mean Y isn't created yet. It's just "younger".

I think you might have missed my actual question. In my scenario, a Limit order L1 is created and happens to match something in the order book. It could have been a Market order, doesn't really matter.

A trade happens, the mark price changes, and it triggers two SL orders (SL1 and SL2).

SL1 gets priority as it is older than SL2.
SL1 gets matched, it again happens to produce a trade, further changing the mark price.
That second mark price change triggers SL3.

Now I have SL2 and SL3 that need to be matched. My question is, which of them should be matched first?

SL3 is an older order than SL2, but SL2 has been triggered before SL3 (by the very first trade).

Obviously they don't have the same stop price (or both would have been triggered by the first trade).

So should I match SL3 first (it's older than SL2), or should I match SL2 first (it has been triggered first)?


I have a gut feeling that there's no dogmatic wisdom there and an exchange may do it one way or the other, but thought I'd ask.
Never thought writing a trading engine would be so freaking hard :p