Introducing Trading (1/4)
Introducing Trading with Virtual Accounts
Virtual Accounts allow your users to trade between themselves as a Custodial Exchange.
You can imagine the liquidity of the pair as how many open buy/sell trades are present on the Order book and how much volume is traded throughout the day. The higher the liquidity, the more precise the chart, and the higher the accuracy of the price of the asset.
How trading works
Every Virtual Account user can open an unlimited number of trades.
Trades can be either BUY or SELL and are connected to the specific trading pair. Trading pairs are created automatically with the first opened trade.
- The trading pair consists of 2 assets. Let's discuss the BTC/ETH pair. The first asset is Bitcoin, and the second is Ethereum. When you open a new BUY trade with the pair BTC/ETH, you want to buy Bitcoin for your Ethereum.
- Every trade must have a price and an amount of the asset you want to trade. In Tatum, every trade is a LIMIT trade by default, and you have to wait until the price hits your target.
Trade Example 1:
- Let's say you want to buy 1 Bitcoin for 40 Ethereum.
- You must open a BUY BTC/ETH trade with the price set to 40 and the amount set to 1.
- Your trade remains open until an opposite trade is opened.
- This opposite trade should be SELL BTC/ETH with the price set to 40 or below and the amount set to 1 or more.
MARKET trades can be executed by setting the price above or below the highest BUY or lowest SELL.
When you open a trade, there are two accounts you must enter:
- The ledger account with the currency of the first asset in the trading pair
- The ledger account with the currency of the second asset in the trading pair
The traded amount will be blocked and debited from one of these accounts based on the trade type, and the other account will be credited with the traded asset when the trade is fulfilled.
Trade Example 2:
- Let's say you want to buy 1 BTC for 40 ETH in BTC/ETH pair.
- Account 1 is BTC, and account 2 is ETH.
- 40 ETH will be blocked from the ETH account and then transferred to the ETH account of the opposite SELL trade.
- 1 BTC will be credited to the BTC account from the BTC account of the opposite SELL trade.
There might be a trade open for selling 1 BTC for 40 ETH, but an opposing trade was executed to buy only 0.5 BTC. Your actual trade will be partially filled for 0.5 BTC and stay open until the rest of the 0.5 BTC is closed.
Good to know
- Every trade must be filled and closed at some point.
- It is possible to fill only the part of the trade.
- It is your responsibility to ensure on-chain asset liquidity.
Updated 5 months ago