At the start of a margin trade, a trader borrows either fiat or BTC that they then use to buy or to sell, hoping for a price move in their direction. If the trader uses the borrowed fiat to buy the asset (BTC in our case), we call this a long trade and the trader has entered into a long position. An order is generated here by system to perform the buying act. In essence the trader has a loan. They owe fiat to the lender and are holding an asset (BTC) in their account, which shows as a long position on the trading dashboard under accounts.
- A trader borrows $30,000 to buy 10 BTC at $3,000 per bitcoin. They now hold 10 BTC in their account, which shows as an open position of 10 BTC. They are now said to be “long 10 BTC at open price of $3,000” -- If the price goes up to $3,500, the trader is sitting on a profit of $500 per bitcoin or $5,000 profit. They can then instruct the system to close their position and the profit is credited to their account balance. On the other hand, if the price goes down to $2,500, the trader is bearing a loss of $500 per bitcoin, or $5,000 loss.
If the trader uses the borrowed BTC to sell for fiat, we call this a short trade and the trader has entered into a short position. Similarly to the long trade, an order is also generated here by system to perform the selling act.
- A trader borrows 10 BTC to sell for $30,000 at $3,000 per bitcoin. They now hold $30,000 in their account, which shows as an open position of 10 BTC. They are now said to be “short 10 BTC at open price of $3,000” -- If the price goes down to $2,500, the trader is sitting on a profit of $500 per bitcoin or $5,000 profits. They can then instruct the system to close their position and the profit is credited to their account balance. On the other hand, if the price goes up to $3,500, the trader is bearing a loss of $500 per bitcoin, or $5,000 loss.
Margin traders can use leverage to open a larger position than what their own funds allow. For example, with a 2x leverage rate, they can borrow twice the amount they put aside as margin.
In both examples, BTC is the base currency and fiat is the quote currency. Base currency and quote currency can be applied to anything. For example, with ETHBTC, BTC is the quote currency and ETH is the base currency.
Underneath the hood, there are several things that the system is doing.
- The system is constantly monitoring the market price and trader’s profit or loss and it WILL take action such as closing the position if it detects the trader cannot pay his loan (due to a price downturn if long or a price appreciation if short).
- To achieve (1) above, the system must constantly recalculate profit & loss of each open position in the system.
- If traders have set take profit or stop loss orders for open positions (see following section), the system is also constantly monitoring these.
Positions can be closed as a result of directions given by the user, as a result of a loss cut executed automatically by the system, or as a result of a stop loss (SL) or a take profit (TP). Here is what happens when a position is closed assuming we are closing a long position as in the example above:
- The system will generate an order to sell the asset owed to the borrower. In the first example, the user has a long position of 10 BTC. In this case, the system will generate a market order to sell the 10 BTC. In the second example, as the user has a short position of 10 BTC, the system will also generate a market order to buy back the 10 BTC. Though this order in both examples is a market order, it is also known as a settlement order (in some cases, as in the case of a TP target reached, it is cleaner to use a limit order).
- Once the sell order is filled, the proceeds of the sell are used to pay back the loan. If the price of the asset was higher than the open price, the sell proceeds will suffice to cover the loan and what’s left (minus fees) is the user’s profit. If the price of the asset decreased below the open price, the proceeds plus a portion of existing user balance (usually reserved as margin) are used to pay back the loan. The portion of the balance used is the user’s loss.
The position is marked as closed by the system and P&L (profit & loss) is recorded accordingly.