I am building a cryptocurrency exchange, and having some trouble with the implementation details for a stop-limit order. I have a few scenarios I would like clarification on, along with any useful resources on the subject you guys may have.

For simplicity lets just deal with sell orders. According to CapitalOne Investing:

Sell Orders: The Stop Price must be entered at least $0.01 below the current Bid Price.

So starting with a blank slate (no sell orders), I cannot add a stop-limit order. Now someone adds a limit order to the book, I can now add my stop-limit order with a slightly higher price. But they then cancel their limit order:

1 - Should my stop order get triggered (turned into a limit order) or cancelled? I assume it should get triggered

Now imagine there is a limit order, followed by many stop orders all with the exact same stop price (sorted by timestamp), but differing limit prices. If someone makes a buy order, which consumes the first limit order, what should happen with the stop orders?

2 - Should I run through and execute all stop orders into limit orders before continuing with the current buy order?


Should I start from the first stop order, and keep executing until the buy order is filled and leave the rest? What if a later stop order had a better limit price? (Seems like it should be sorted by time)

1 Answer 1


A stop order should only be converted into an active (limit or market) order when there is a trade at or below the stop price. It has nothing to do with what sell or buy orders are in the book, nor what the limit prices of the active orders are.

This has the consequence that a buy order can never be matched to a stop-limit order, regardless of the bid and stop prices.

It also means that a stop order can be added even when no other orders are in the book.

When a trade occurs, all stop orders with stop price at or above the trade price must be converted to active orders.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .