I am code reviewing my development on an upcoming NMC/BTC/Multi-currency exchange and trading platform (yes I know, another one, but this one will be offering more sophisticated trading possibilities: stop orders, OTO orders, loan your coins and earn interest, etc.).
I am trying to keep the interface as flexible as possible, not like some of the existing exchanges that only allow you to trade in predefined directions, e.g. only Sell NMC or Buy NMC but you cant enter Sell BTC or buy BTC.
Example: in the simple approach above, I'ld take the buy order with the highest unit price and compare that to the sell order that has the lowest unit price
Buy (BTC) Sell (BTC)
30 NMC/BTC 40NMC/BTC
25 NMC/BTC 45NMC/BTC
.....
Now with the more flexible approach that I am implementing I not only have "buy NMC for BTC", I also have "sell BTC for NMC". My current thoughts are that the sell order of the reversed order of currency is the same as a buy order with a unitprice of 1/unitprice.
Example
Buy (BTC) Sell-Side
30 NMC/BTC (buy BTC order)
0.04 BTC/NMC (sell NMC order => equivalent to 25 NMC/BTC buy order)
20 NMC/BTC (buy BTC order)
Question now is: is this logic correct? Can I mix in the sell orders with the buy orders as above or am I overseeing anything here
Order Matching Logic for a NMC/BTC Exchange
Order Matching Logic for a NMC/BTC Exchange
I trade my coins on https://vircurex.com
-
- Posts: 17
- Joined: Mon Jun 13, 2011 3:58 am
- os: linux
Re: Order Matching Logic for a NMC/BTC Exchange
Looks good. Remember to translate the amount. Example:Kumala wrote:Now with the more flexible approach that I am implementing I not only have "buy NMC for BTC", I also have "sell BTC for NMC". My current thoughts are that the sell order of the reversed order of currency is the same as a buy order with a unitprice of 1/unitprice.
Example
Buy (BTC) Sell-Side
30 NMC/BTC (buy BTC order)
0.04 BTC/NMC (sell NMC order => equivalent to 25 NMC/BTC buy order)
20 NMC/BTC (buy BTC order)
Question now is: is this logic correct? Can I mix in the sell orders with the buy orders as above or am I overseeing anything here
Buy 10 BTC @25 NMC == Sell 250 NMC @0.04 BTC