<blockquote>
  <p>"so in this case he may have a deal with trader1 and partial deal
  with trader2."</p>
</blockquote>

<p>This happens all the time in the markets. Majority of the people don't really notice this happen because the size of the trades are small enough relative to the liquidity of the market and get they get complete fills.  </p>

<p>If you tried selling a huge amount, lets say, 1000000 XRP at a particular BTC price, you're likely not going to get a complete fill right away.</p>

<p>Another way to get a 100% fill is when some other trader places a market order bigger than the size of your limit order. In that case, the exchange will "eat through" your limit order and move on to the next best available order in the orderbook. Or may be there are multiple market orders that can be filled against your limit order, so your limit order gets filled as more and more market orders come through.</p>

<p>There's a lot to read about similar topics, search for order matching algorithms: <a href="https://stackoverflow.com/questions/13112062/which-are-the-order-matching-algorithms-most-commonly-used-by-electronic-financi">https://stackoverflow.com/questions/13112062/which-are-the-order-matching-algorithms-most-commonly-used-by-electronic-financi</a></p>

CC BY-SA 3.0
2018-01-13T04:16:22.160Z
2018-01-13T04:16:22.160Z
Tanmay
<p>I'm trying to understand how order fulfillment algorithm works from technical point of view.</p>

<p>Let's say I created an order to sell 0.8 BTC and buy 5400 XRP along with other orders to sell 0.35 BTC, 2.7 BTC, etc. On the other side, there are some traders who sell different amount of XRP to but BTC.</p>

<p>To be more specific, imagine:</p>

<p>trader1 wants to sell 0.8 BTC,</p>

<p>trader2 wants to sell 2.7 BTC
...</p>

<p>But there are no traders that are willing to sell exactly the same amount of XRP. There is a traderX who wants to sell 7000 XRP so in this case he may have a deal with trader1 and partial deal with trader2. However, this is not how all exchangers work, right? Usually all orders processed as a single transaction.</p>

<p>So how all these orders match to have a trading? 
Any algorithm or code in any programming language would be very helpful. Thank you!</p>

<exchanges><development><trading><algorithms><exchange-order>
How an order fulfillment works
eugene
# How an order fulfillment works

(Asked by: username_0 on 2018-01-13)

I'm trying to understand how order fulfillment algorithm works from technical point of view.

Let's say I created an order to sell 0.8 BTC and buy 5400 XRP along with other orders to sell 0.35 BTC, 2.7 BTC, etc. On the other side, there are some traders who sell different amount of XRP to but BTC.

To be more specific, imagine:

trader1 wants to sell 0.8 BTC,

trader2 wants to sell 2.7 BTC
...

But there are no traders that are willing to sell exactly the same amount of XRP. There is a traderX who wants to sell 7000 XRP so in this case he may have a deal with trader1 and partial deal with trader2. However, this is not how all exchangers work, right? Usually all orders processed as a single transaction.

So how all these orders match to have a trading?
Any algorithm or code in any programming language would be very helpful. Thank you!

**Tags:** exchanges, development, trading, algorithms, exchange-order


---

## 1 answers

### Answer by username_1 on 2018-01-13. Score: 0 | Accepted answer

> "so in this case he may have a deal with trader1 and partial deal
> with trader2."

This happens all the time in the markets. Majority of the people don't really notice this happen because the size of the trades are small enough relative to the liquidity of the market and get they get complete fills.

If you tried selling a huge amount, lets say, 1000000 XRP at a particular BTC price, you're likely not going to get a complete fill right away.

Another way to get a 100% fill is when some other trader places a market order bigger than the size of your limit order. In that case, the exchange will "eat through" your limit order and move on to the next best available order in the orderbook. Or may be there are multiple market orders that can be filled against your limit order, so your limit order gets filled as more and more market orders come through.

There's a lot to read about similar topics, search for order matching algorithms: <https://stackoverflow.com/questions/13112062/which-are-the-order-matching-algorithms-most-commonly-used-by-electronic-financi>


---

