# Need explanation - limit buy order (Cryptopia)

If there are sell orders like this:

selling 200 XXX - 100 satoshis per coin
selling 200 XXX - 101 satoshis per coin
selling 200 XXX - 102 satoshis per coin
selling 200 XXX - 103 satoshis per coin
selling 200 XXX - 104 satoshis per coin
selling 200 XXX - 105 satoshis per coin
...


If I put buy order like this: "Buying 600 XXX for price 105 satoshis per coin - total 63000 satoshis" (and let's assume that I have 1 BTC) - what will happen? Will I spent 63000 satoshis and get more than 600 XXX coins or I will buy exactly 600 XXX for less than 63000 satoshis and what will happen with remaining satoshis for that trade? To rephrase, will my order be filled after spent 63000 satoshis or after buying 600 XXX and what will happen with remaining satoshis for that trade?

When new orders are added to the orderbook, they are first matched against the most favorable existing orders. If the newly added order cannot be fully fulfilled, the remainder is put on the order book.

Your order would be limited to buying 600 coins and at a price of 105 satoshis. It would be filled after buying 600 coins. To have an order fulfill at a total amount to spend, you'd give a limit in the amount you want to spend rather than a number of coins you want to purchase. Defining all three, a number of coins to purchase, a maximum price you're willing to pay per unit and a maximum amount you're willing to pay is possible, but will not hit all three of your restrictions unless you get exactly the price you're aiming for.

In your example that would mean that your buy order would first match the sell order at 100 satoshis/coin, then match the 101 satoshis per coin and finally be exhausted by matching the 102 satoshis per coin. You'd have purchased 600 XXX at a total of 60600 satoshis.

If in your example the sell orders were each for 50 XXX, the resulting order book would look like this:

Before:
selling 50 XXX - 100 satoshis per coin
selling 50 XXX - 101 satoshis per coin
selling 50 XXX - 102 satoshis per coin
selling 50 XXX - 103 satoshis per coin
selling 50 XXX - 104 satoshis per coin
selling 50 XXX - 105 satoshis per coin
selling 50 XXX - 106 satoshis per coin
…

matching:
>selling 50 XXX - 100 satoshis per coin
>selling 50 XXX - 101 satoshis per coin
>selling 50 XXX - 102 satoshis per coin
>selling 50 XXX - 103 satoshis per coin
>selling 50 XXX - 104 satoshis per coin
>selling 50 XXX - 105 satoshis per coin
<buying 300 XXX - 105 satoshis per coin
buying 300 XXX - 105 satoshis per coin
selling 90 XXX - 106 satoshis per coin
…

After:
buying 300 XXX - 105 satoshis per coin
selling 90 XXX - 106 satoshis per coin
…


Also see: How do buy and sell orders work?

• Thanks! That's explain everything! But what if I want to spend 63000 satoshis paying no more then 105 satoshis per coin? Is it possible and what is the type of that sort of order? – mbackonja Apr 22 '18 at 15:08
• And what happens to remain 2400 satoshis? Will it be "refunded" to my BTC balance after filling trade? – mbackonja Apr 22 '18 at 15:12
• If Cryptopia require you to deposit before trading, the 2400 would still be in your BTC balance since you haven't spent them. --- If you just give an amount that you want to buy for and a maximum price, you'd purchase a variable amount of coins. In your 200s example, you'd purchase another 23.3 XXX from the 103 satoshis per coin sell order. – Murch Apr 22 '18 at 15:41
• Yeah, that's exactly what I want. Do You know if Cryptopia supports that type of order (to spend all amount and buy a variable amount of coin not spending more then specified price per one coin)? Is there any name for that type of trade? – mbackonja Apr 22 '18 at 16:17
• I'm not familiar with Cryptopia. Some exchanges have "limit orders" with defined price and volume, and "market orders" that only define volume. In a well-stocked order book, the latter would have a similar effect as what you look for. – Murch Apr 22 '18 at 16:28