Cross-Margin Trading
Last updated
Last updated
OpenWorld applies cross-margin mode for trading. In this mode, your entire net account value (calculated by all your position balances) is used as the margin to trade, and the margin is shared by all your positions. Cross-margin trading provides the maximum cash efficiency and trading flexibility when establishing multiple positions.
Note:
If you need isolated-margin mode, in which each trading pair has an independent isolated margin account, you could create separate accounts to trade.
In cross margin mode:
You can use the free collateral as the initial margin to open/add new positions with leverage.
The free collateral equals to your net account value minus initial margin requirement by your opening positions and orders.
The detailed calculation method is as follows:
Net Account Value (NAV) is the net value of your account quoted by DAI. It is calculated as follows:
Where for each perpetual contract (perp) in an account:
Note:
Position size is positive if you're long the asset, negative if you're short the asset.
Funding Level is the current value of this market applicable to all users, while Entry Fund Level is the Funding Level when you trade this market last time.
Initial Margin Requirement is the margin required for taking risks. Initial Margin Requirement is charged by each market’s Position Size (amount) and Position Value in an account. Both open orders and existing positions requires initial margin. When there’re both buy and sell orders, initial margin requirement is decided by the maximum value of one side risk.
Note:
To mitigate the tail risk of crash to zero or negative price, we charge Initial Margin Requirement by Size in addition to Initial Margin Requirement by Value used by typical perpetual contracts to set a floor of margin requirement. For most assets without that risk, Initial Margin per Size is zero so that Initial Margin Requirement by Size is zero, and we only need to calculate Initial Margin Requirement by Value as typical perpetual contracts as follows.
For each perpetual contract in an account, the initial margin required in terms of size is:
For both open orders and existing position:
Note:
Total Buy Order Size is the sum of all buy order sizes, and Total Sell Order Size is the sum of all sell order sizes:
For existing position only:
For each perpetual contract in an account, the initial margin required in terms of position value is:
For both open orders and existing position:
Note:
Total Buy Order Value is the sum of all buy order values, and Total Sell Order Value is the sum of all sell order values:
For existing position only:
The Initial Margin Requirement for this perpetual contract is the sum of margin required by size and by value:
For both open orders and existing position:
For existing position only:
At the account level, the Account Initial Margin Requirement is the sum of all perpetual contracts’ Initial Margin Requirement:
For both open orders and existing position:
For existing position only:
The difference between Account Initial Margin Requirement and Account Initial Margin Requirement_Position Only is the Value Locked for all open orders.
You can withdraw Account Free Collateral that is unoccupied by Account Initial Margin Requirement (for both open orders and existing positions):
In ensure an account is well collateralized, new orders can be opened to build or increase positions only if the Account Initial Margin Requirement does not exceed NAV after the new order is placed.
We provide the following algo for users to check how much an order can be placed based on the order direction and order price.
First, we calculate the margin required for open each one position of a perpetual contract:
Note:
New Order Side is 1 for buy order, -1 for sell order.
Open Loss Per New Position is the cost to trade assuming market impact.
To open a buy order of a perpetual contract, we firstly calculate the Free to Buy Collateral by the adding back this perpetual contract’s Initial Margin Requirement on Account Free Collateral to get the free collateral not occupied by other perpetual contracts:
After that, we need to subtract this value by the margin required for existing open buy orders and long positions:
Therefore, the formula to calculate Free to Buy Collateral is:
Note: Except for Account Free Collateral, other parameters in the above equations are the value for that specific perpetual contract.
The position size could be bought by Free to Buy Collateral is:
In addition to that, a user can buy positions to reduce existing short position by (-Min(0, Position Size)). Therefore, the Max Buy Size for Open can be can calculated as:
In the case of reducing a position, users are not constraint by margin requirement. A user can reduce all positions net of all existing buy orders:
Therefore, the Max Buy Size is:
By the same principle, for open a sell order of a perpetual contract, we can calculate:
All orders opened will go to the order book of each perpetual contract. The match engine will determine how two orders should be matched by the priority of price and time. After two orders are matched, one trade will be formed with the trade price. The account balances of the two users in this trade will change as follows:
Note:
Transaction Fee = Fee Rate*Abs(Filled Amount*Trade Price)+0.1
Transaction Fee could be negative if the buyer serves as maker and gains fee rebate