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.

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

Net Account Value (NAV) is the net value of your account quoted by DAI. It is calculated as follows:

NAV=DAIBalance+โˆ‘AllPerpsNotionalValue+โˆ‘AllPerpsAccruedFunding\mathsf{ {\small NAV = DAI Balance + \sum_{All Perps} Notional Value + \sum_{All Perps} Accrued Funding } }

Where for each perpetual contract (perp) in an account:

NotionalValue=PositionSizeโˆ—MarkPrice\mathsf{ {\small Notional Value = Position Size * Mark Price} }

AccruedFunding=โˆ’PositionSizeโˆ—(FundingLevelโˆ’EntryFundingLevel)\mathsf{ {\small Accrued Funding = - Position Size * ( Funding Level - Entry Funding Level ) } }

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

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:

Initial Margin Requirement by Size = Max(Abs(Position Size + Total Buy Order Size), Abs(Position Size โ€“ Total Sell Order Size))* Initial Margin per Size

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:

Totalย Buyย Orderย Size=โˆ‘Allย buyย ordersย ofย theย prepOrderย Size\mathsf { {\small Total \ Buy \ Order \ Size = \sum_{All \ buy \ orders \ of \ the \ prep} Order \ Size} } Totalย Sellย Orderย Size=โˆ‘Allย sellย ordersย ofย theย prepOrderย Size\mathsf { {\small Total \ Sell \ Order \ Size = \sum_{All \ sell \ orders \ of \ the \ prep} Order \ 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

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:

Totalย Buyย Orderย Value=โˆ‘Allย buyย ordersย ofย theย prepOrderย Sizeโˆ—Orderย Price\mathsf{ {\small Total \ Buy \ Order \ Value = \sum_{All \ buy \ orders \ of \ the \ prep} Order \ Size * Order \ Price} } Totalย Sellย Orderย Value=โˆ‘Allย sellย ordersย ofย theย prepOrderย Sizeโˆ—Orderย Price\mathsf { {\small Total \ Sell \ Order \ Value = \sum_{All \ sell \ orders \ of \ the \ prep} Order \ Size * Order \ Price} }

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:

Accountย Initialย Marginย Requirement=โˆ‘Allย PrepsInitialย Marginย Requirement\mathsf{ {\small Account \ Initial \ Margin \ Requirement = \sum_{All \ Preps} Initial \ Margin \ Requirement} }

For existing position only:

Accountย Initialย Marginย Requirement_Positionย Only=โˆ‘Allย PrepsInitialย Marginย Requirement_Positionย Only\mathsf{ {\small Account \ Initial \ Margin \ Requirement \_ Position \ Only = \sum_{All \ Preps} Initial \ Margin \ Requirement \_ 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))

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.

    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)

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:

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

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

Last updated