<p>New offers and orders are matched respectively with the best order and offer available until they are fulfilled. If there is more than one entry at the same price, the oldest entry will be matched first. If a new entry cannot be matched completely, it will remain in the order book until the remainder is matched or it expires.</p>

<p>See an example below:</p>

<h2>The initial order book</h2>

<p><strong>Offers</strong>:</p>

<pre><code>[Bob] sell 1 BTC at $1000
[Charlie] sell 2 BTC at $1001, [Dolph] sell 1 BTC at $1001
[Emilio] sell 1 BTC at $1002
</code></pre>

<p><strong>Orders</strong>:</p>

<pre><code>[Fabienne] buy 1 BTC at $999
[George] buy 1 BTC at $998
[Harry] buy 1 BTC at $996, [Ivan] buy 5 BTC at $996
</code></pre>

<h2>Alice wants to buy some Bitcoins.</h2>

<p>Alice wants to buy 2 BTC and is willing to pay up to $2020. She adds an <strong>order</strong> for 2 BTC at $1010. </p>

<p>The system will now try to match her order to offers already in the system, of course matching the best offer first.</p>

<p>As seen above, Bob is offering to sell at $1000 and Charlie offers to sell at $1001, her order matches with Bob's offer using it up completely. Her order has a second BTC though, which will be matched against Charlie's offer next, because Charlie entered his offer before Dolph, who is offering the same price.</p>

<p>After Alice's order was matched there are the following <strong>offers</strong>:</p>

<pre><code>[Charlie] sell 1 BTC at $1001, [Dolph] sell 1 BTC at $1001
[Emilio] sell 1 BTC at $1002
</code></pre>

<p>and the following <strong>orders</strong>:</p>

<pre><code>[Fabienne] buy 1 BTC at $999
[George] buy 1 BTC at $998
[Harry] buy 1 BTC at $996, [Ivan] buy 5 BTC at $996
</code></pre>

<p>Note that Alice's order and Bob's offer are gone, and Charlie's offer is reduced by 1 BTC.</p>

<h2>Afterwards, Jeremy wants to sell some Bitcoins</h2>

<p>Now Jeremy wants $9,970 and has 10 BTC for sale. He creates an offer for 10 BTC at $997. Currently there are only two orders that will buy at or over that price: His offer matches the orders of Fabienne and George. He gains $999 and $998 for two of his BTC, the remaining 8 BTC will stay as an offer.</p>

<p>After Jeremy's offer was partially matched there are the following <strong>offers</strong>:</p>

<pre><code>[Jeremy] sell 8 BTC at $997
[Charlie] sell 1 BTC at $1001, [Dolph] sell 1 BTC at $1001
[Emilio] sell 1 BTC at $1002
</code></pre>

<p>and the following <strong>orders</strong>:</p>

<pre><code>[Harry] buy 1 BTC at $996, [Ivan] buy 5 BTC at $996
</code></pre>

CC BY-SA 3.0
2014-01-19T03:00:18.420Z
Excellent! Just one quick question: Cryptsy applies a fee of 0.2% when buying, and 0.3% when selling. Who pays that fee? In your sample, Alice ended up paying $2001 for the coins. Is her account charged $2005.002 , or does Bob receive only $998 for his sale?
Joe Pineda
CC BY-SA 3.0
2014-01-19T16:02:43.543Z
I think it is the easiest when the fee is applied after the order and offer have been matched. I.e. Alice's $1000 are matched to Bob's 1 BTC, but Alice ends up receiving `1 BTC * 99.8%  = 0.998 BTC`, meanwhile Bob receives `$1000 * 99.7% = $997`.
Murch
CC BY-SA 3.0
2014-01-18T16:30:02.877Z
2014-01-18T16:39:49.403Z
2014-01-18T16:39:49.403Z
Murch
<p>How does buying and selling bitcoins work once the order is placed?</p>

<p>I just know that the order-matching engine is used for this purpose, but more information regarding this will be helpful.</p>

<exchanges><trading><exchange-order>
How do buy and sell orders work?
sarah
# How do buy and sell orders work?

(Asked by: username_0 on 2014-01-18)

How does buying and selling bitcoins work once the order is placed?

I just know that the order-matching engine is used for this purpose, but more information regarding this will be helpful.

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


---

## 1 answers

### Answer by username_1 on 2014-01-18. Score: 12 | Accepted answer

New offers and orders are matched respectively with the best order and offer available until they are fulfilled. If there is more than one entry at the same price, the oldest entry will be matched first. If a new entry cannot be matched completely, it will remain in the order book until the remainder is matched or it expires.

See an example below:

## The initial order book

**Offers**:

```
[Bob] sell 1 BTC at $1000
[Charlie] sell 2 BTC at $1001, [Dolph] sell 1 BTC at $1001
[Emilio] sell 1 BTC at $1002

```

**Orders**:

```
[Fabienne] buy 1 BTC at $999
[George] buy 1 BTC at $998
[Harry] buy 1 BTC at $996, [Ivan] buy 5 BTC at $996

```

## Alice wants to buy some Bitcoins.

Alice wants to buy 2 BTC and is willing to pay up to $2020. She adds an **order** for 2 BTC at $1010.

The system will now try to match her order to offers already in the system, of course matching the best offer first.

As seen above, Bob is offering to sell at $1000 and Charlie offers to sell at $1001, her order matches with Bob's offer using it up completely. Her order has a second BTC though, which will be matched against Charlie's offer next, because Charlie entered his offer before Dolph, who is offering the same price.

After Alice's order was matched there are the following **offers**:

```
[Charlie] sell 1 BTC at $1001, [Dolph] sell 1 BTC at $1001
[Emilio] sell 1 BTC at $1002

```

and the following **orders**:

```
[Fabienne] buy 1 BTC at $999
[George] buy 1 BTC at $998
[Harry] buy 1 BTC at $996, [Ivan] buy 5 BTC at $996

```

Note that Alice's order and Bob's offer are gone, and Charlie's offer is reduced by 1 BTC.

## Afterwards, Jeremy wants to sell some Bitcoins

Now Jeremy wants $9,970 and has 10 BTC for sale. He creates an offer for 10 BTC at $997. Currently there are only two orders that will buy at or over that price: His offer matches the orders of Fabienne and George. He gains $999 and $998 for two of his BTC, the remaining 8 BTC will stay as an offer.

After Jeremy's offer was partially matched there are the following **offers**:

```
[Jeremy] sell 8 BTC at $997
[Charlie] sell 1 BTC at $1001, [Dolph] sell 1 BTC at $1001
[Emilio] sell 1 BTC at $1002

```

and the following **orders**:

```
[Harry] buy 1 BTC at $996, [Ivan] buy 5 BTC at $996

```

> **Comments:**
> **username_2**: Excellent! Just one quick question: Cryptsy applies a fee of 0.2% when buying, and 0.3% when selling. Who pays that fee? In your sample, Alice ended up paying $2001 for the coins. Is her account charged $2005.002 , or does Bob receive only $998 for his sale?  
> **username_1**: I think it is the easiest when the fee is applied after the order and offer have been matched. I.e. Alice's $1000 are matched to Bob's 1 BTC, but Alice ends up receiving `1 BTC * 99.8%  = 0.998 BTC`, meanwhile Bob receives `$1000 * 99.7% = $997`.  

---

