Cross-Margin Trading
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.
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
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:
Initial margin requirement
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.
For each perpetual contract in an account, the initial margin required in terms of size is:
For both open orders and existing position:
Initial Margin Requirement by Size = Max(Abs(Position Size + Total Buy Order Size), Abs(Position Size – Total Sell Order Size))* Initial Margin per Size
For existing position only:
Initial Margin Requirement by Size_ Position Only= Abs(Position Size)* Initial Margin per Size
For each perpetual contract in an account, the initial margin required in terms of position value is:
For both open orders and existing position:
Initial Margin Requirement by Value= Max(Abs(Notional Value + Total Buy Order Value), Abs(Notional Value – Total Sell Order Value)) * Initial Margin Ratio
For existing position only:
Initial Margin Requirement by Value_Position Only= Abs(Notional Value)* Initial Margin Ratio
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:
Initial Margin Requirement=Initial Margin Requirement by Size + Initial Margin Requirement by Value
For existing position only:
Initial Margin Requirement_ Position Only = Initial Margin Requirement by Size_ Position Only + Initial Margin Requirement by Value_ 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.
Value Locked= Account Initial Margin Requirement- Account Initial Margin Requirement_Position Only
You can withdraw Account Free Collateral that is unoccupied by Account Initial Margin Requirement (for both open orders and existing positions):
Account Free Collateral= NAV - Account Initial Margin Requirement
Open an order——Constraint by margin requirement
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:
Margin requirement Per New Position=Initial Margin Per New Position by Value + Initial Margin Per New Position by Size + Open loss per new position
Where:
For limit order:
Initial Margin Per New Position By Value= abs(New Order Price)* Initial Margin Ratio
Initial Margin Per New Position By Size= Initial Margin per position
Open Loss Per New Position = max (0, New Order Side*(New order price-mark price))
For market order:
Initial Margin Per New Position By Value= abs(Mark Price)* Initial Margin Ratio
Initial Margin Per New Position By Size= Initial Margin per position
Open Loss Per New Position = mark price*0.5%
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:
Account Free Collateral + Initial Margin Requirement
After that, we need to subtract this value by the margin required for existing open buy orders and long positions:
-max (0, Notional Value) * Initial Margin Ratio - Total Buy Order Value* Initial Margin Ratio- max (0, Position Size) * Initial Margin per Size - Total Buy Order Size * Initial Margin per Position
Therefore, the formula to calculate Free to Buy Collateral is:
Free to Buy Collateral =Max (0, Account Free Collateral + Initial Margin Requirement – max (0, Notional Value)* Initial Margin Ratio - Total Buy Order Value* Initial Margin Ratio- max (0, Position Size) * Initial Margin per Size - Total Buy Order Size * Initial Margin per Position)
The position size could be bought by Free to Buy Collateral is:
Free to Buy Collateral / Margin requirement Per New Position
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:
Max Buy Size for Open= Free to Buy Collateral / Margin requirement Per New Position - Min(0, Position Size)
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:
Max Buy Size For Reduce =Max(0, -Position Size- Total Buy Order Size)
Therefore, the Max Buy Size is:
Max Buy Size=Max(Max Buy Size For Reduce, Max Buy Size For Open)
By the same principle, for open a sell order of a perpetual contract, we can calculate:
Free to Sell Collateral =Max(0, Account Free Collateral + Initial Margin Requirement + min(0, Notional Value)* Initial Margin Ratio - Total Sell Order Value* Initial Margin Ratio + min (0, Position Size) * Initial Margin per Size - Total Sell Order Size * Initial Margin per Position)
Max Sell Size For Open= Free to Sell Collateral / Margin requirement Per New Position + Max(0, Position Size)
Max Sell Size For Reduce =Max(0, Position Size- Total Sell Order Size)
Max Sell Size=Max(Max Sell Size For Reduce, Max Sell Size For Open)
Trade matching and balance change
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:
Position Size=Position Size + Order Side*Filled Amount
DAI Balance=DAI Balance – Order Side*Filled Amount*Trade Price – Transaction Fee + Accrued Funding
If Position Size<>0 after the trade, record the new Entry Funding Level of the account for the buyer
Last updated