Spot and futures mode: cross margin trading
Introduction
Spot and futures mode: In this mode, users can trade across all business lines simultaneously, including spot, margin, futures, perpetual swap, and options. Users only need to transfer assets into the cross margin account. In spot and futures cross margin, all trading products settled with the same crypto can share the same total margin, and the generated profits and losses can be offset.
In spot and futures cross margin, the risks of the positions settled with the same crypto will be measured in whole. When the equity of a certain crypto is insufficient, it may result in partial liquidation, full liquidation, or equity loss of all the positions settled with this crypto. If users want to segregate the risk of each position, isolated margin mode will be a good choice.
Asset fields
Term | Explanation | Parameter in Get balance |
---|---|---|
Equity | Your individual asset balance plus floating PnL from all positions in spot and futures mode. | eq in the details array |
Free margin | The margin amount of a certain crypto that can be used for trading margins, expiry futures, perpetual futures, and options (short positions) trading. Free margin = Max (0, Crypto balance in cross margin + Floating PnL in cross-margin positions – In use) | availEq in the details array |
Available balance | The amount of crypto that can be used for isolated positions, spot, and options (long positions) trading under spot and futures account mode. Note: This description is for order calculation only and will not be displayed as a field on the platform. | availBal in the details array |
In use | The amount of crypto in the spot and futures account that is in use, which includes cross open orders, positions, accrued interest, isolated open orders, and assets used in trading bots. | frozenBal in the details array |
Floating PnL | The sum of the floating PnL of all margin, futures, and options positions that are settled with a certain crypto, including positions under cross and isolated margin mode. Floating PnL = Floating PnL of cross-margin positions + Floating PnL of isolated margin positions Floating PnL of cross-margin positions = Floating PnL of cross-margin positions + Floating PnL of cross-margin expiry futures positions + Floating PnL of cross-margin perpetual futures positions + Floating PnL of cross-margin options positions Floating PnL of isolated margin positions = Floating PnL of isolated margin positions + Floating PnL of isolated expiry futures positions + Floating PnL of isolated perpetual futures positions + Floating PnL of isolated options positions. | upl in the details array |
Leverage | The leverage of a single crypto, leverage = position value/ (balance in cross positions + floating PnL in cross margin positions). Position value: the sum of position value of all positions that are settled in this crypto Expiry and perpetual futures Position value = face value * |number of contracts| * multiplier / mark price Position value = face value * |number of contracts| * multiplier * mark price Margin Position value = |liability + interest| / mark price Short positions with base crypto as margin and having base crypto as liability. Position value = |liability + interest| Short positions using quote crypto as margin and having base crypto as liability. Position value = |liability + interest| * mark price Long positions using quote crypto as margin and having quote crypto as liability. Position value = |liability + interest| Options | notionalLever in the details array |
Margin level | The index for measuring the risk of a certain asset in the account. | mgnRatio in the details array |
Total equity | The fiat value of all cryptocurrencies in the your account. Total equity = Sum (Crypto equity × Crypto price) The crypto price is based on the USD price of the crypto on OKX. If a crypto does not have a USD price, we will calculate using the spot price of the USDT pair of the crypto multiplied by the price of USDT/USD on OKX. If there is no USDT price, we’ll use the spot price of the USDC pair of the crypto multiplied by the price of USDC/USD on OKX. If there is no USDC price, we’ll calculate according to the spot price of the BTC pair of the crypto multiplied by the price of BTC/USD on OKX. | eqUsd in the details array |
Trading rules
In spot and futures mode, users can choose to trade in cross margin mode or isolated margin mode. In cross margin mode, all trading products settled with the same crypto can share the same total margin, and the generated profits and losses can be offset. In isolated margin mode, the risk of each position, as well as the profit and loss, are separated.
Trading rules for spot and futures cross margin mode
When users conduct futures, perpetual, options(short positions), and margin transactions in spot and futures cross margin mode, the available equity of the crypto in the account should be greater than or equal to the amount required for the order.
When users conduct spot or options(long positions) transactions in spot and futures cross margin mode, the available balance of the crypto in the account should be greater than or equal to the amount required for the order.
Note: Available balance refers to the amount of assets that can be used to open isolated positions and carry out spot and options (long positions) trading with the spot and futures account.
If a user's BTC holdings in spot and futures cross margin positions and open orders are as below:
Underlying | Position type | Direction | Leverage | Position margin (BTC) | Open order margin (BTC) | UPL (BTC) | MMR |
BTCUSDT Margin | Margin (Isolated) | Long | 5 | 100 | 200 | 10 | 1% |
BTCUSDT Margin | Margin (Cross) | Long | 5 | 100 | 200 | 10 | 1% |
BTCUSD Quarterly | Futures (Cross) | Long | 1 | 10 | 20 | 5 | 1% |
And if the user conducts margin trading in spot and futures cross margin mode with the holdings as above, the margin verification for placing an order will be as follows:
Then when the user opens a long position with 200 BTC and 5x leverage, the amount of required margin for this order will be 200 / 5 = 40 BTC;
In use = Margin required for futures open orders and positions in cross margin mode + Margin required for margin open orders and positions in cross margin mode + Margin required for open orders in isolated margin mode = 10 + 20 + 100 + 200 + 200 = 530 BTC;
Assuming the user's balance in the cross margin account is 700 BTC.
Free margin = Max (0, balance in cross margin account + floating PnL in cross margin positions - In use) = max(0, 700 + 10 + 5 - 530) = 185 BTC;
If the BTC free margin > the amount of BTC required for the order, it means the order is placed successfully.
If the user conducts the futures trading in spot and futures cross margin mode with the holdings as above, the order validation for placing an order will be as follows:
If the user longs 100,000 weekly futures contracts with 5x leverage at a price of 10,000 USDT/BTC, the required margin amount = face value * number of contracts * contract multiplier / order price / leverage multiplier = 100000 * 100 * 1 / 10000 / 5 = 200 BTC;
In use = Margin required for futures open orders and positions in cross margin mode + Margin required for margin open orders and positions in cross margin mode + Margin required for open orders in isolated margin mode = 10 + 20 +100 +200 + 200 = 530 BTC;
Free margin = Max (0, balance in cross margin account + floating PnL in cross margin positions - In use) = max(0, 700 + 10 + 5 - 530 ) = 185 BTC;
That is, the BTC free margin is less than the amount required for the order, so the order fails.
Margin positions in cross margin mode
Position fields
Term | Explanation | Parameter in Get position |
---|---|---|
Assets | The amount of positive assets in the position (does not include margin). | pos |
Available asset | The amount of positive assets to available to close a position. | availPos |
Liability | Initial liabilities + deducted interest | liab |
Interest | Interest that has been accrued but has not been deducted yet. | interest |
Avg. open price | (Existing positions * Entry Price of Existing Positions + New positions * Entry Price of New Positions) / (Quantity of Existing + New positions) Note: When calculating the avg. open price, the amount that was previously closed will not be deducted from the existing position size. This is the difference between futures and margin when calculating the avg. open price. Example: The user opened a 1 BTC long position when the price was 50000 USDT/BTC and partially closed 0.5 BTC. At this point, there is still 0.5 BTC in the position and the avg. open price remains 50000 USDT/BTC. Thereafter, the user increased the position size by 1 BTC when the price was 30000 USDT/BTC. Even though the position is now 1.5 BTC, the avg. open price = (1 * 50000 + 1 * 30000) / (1 + 1) = 40000 USDT/BTC, using 1 BTC as the existing position size instead of 0.5 BTC. | avgPx |
Est. liquidation price | The underlying price when the cross position of a spot and futures account meets the liquidation conditions. This price only serves as a reference.
| liqPx |
Floating PnL | Unrealized profit or loss of the current position. Calculation formula: Floating PnL = Total assets - (liability + interest) / mark price
Floating PnL = Total assets * mark price - (liability + interest)
Floating PnL = total assets - (liability + interest) * mark price
Floating PnL = Total assets / marked price - (liability + interest) | upl |
Floating PnL % | Floating PnL / Initial margin | uplRatio |
Initial margin | Long positions using base crypto as margin and having quote crypto as liability. Initial margin = (liability + interest) / (mark price * leverage)
Initial margin = (liability + interest) / leverage
Initial margin = (liability + interest) * mark price / leverage Long positions using quote crypto as margin and having quote crypto as liability. Initial margin = (liability + interest) / leverage | imr |
Maintenance margin | Long positions using base crypto as margin. Maintenance margin = (liability + interest) * maintenance margin ratio / mark price Long positions using quote crypto as margin. Maintenance margin = (liability + interest) * maintenance margin ratio Short positions using quote crypto as margin. Maintenance margin = (liability + interest) * maintenance margin ratio * mark price Short positions using base crypto as margin. Maintenance margin = (liability + interest) * maintenance margin ratio | mmr |
Initial margin
Both tokens of a pair can be used as margin for long/short positions.
Example:
When trading the BTC/USDT pair, you can choose either BTC or USDT as the margin crypto to open long/short margin positions in spot and futures cross mode.
Assuming you open a long position of 1 BTC using 10x leverage and use BTC as the margin crypto, a margin of 0.1 BTC is required (the free margin in spot and futures account should be greater than or equal to 0.1 BTC), the filled price is 10,000 USDT/BTC, and 10,000 USDT needs to be borrowed; no borrowings or interest will be incurred if the order has not been filled but the margin will be in use.
After the order is filled, a long position will be opened: the total asset of this position will be 1BTC, while its liability is 10,000 USDT. The margin of 0.1BTC will remain in the account balance, and will not be transferred to the position asset (It is different from isolated position, where margin for isolated position will be transferred to the position asset).
Closing positions
Position assets and margin are using the same crypto
Long positions using base crypto as margin, and having quote crypto as liability.
Short positions using quote crypto as margin and having base crypto as liability.
Principle of closing positions: Only the available asset can be used for closing a position. Users can close the position when they pay off the liability; Users can also choose whether to use "reduce only" when closing a position.
The available asset formula for closing positions:
The main difference from the isolated margin: the available asset can be used for closing the position is the total asset of the isolated margin positions, while in spot and futures cross margin mode (where position assets and margin crypto are the same), the available asset that can be used for closing the position may be the sum of total position asset and part of the equity in account balance.
Fundamentally, closing a margin position cannot affect the risks of other positions in a spot and futures cross margin mode. When the total equity is greater than or equal to the initial margin required for the account, the available asset for closing a margin position can include the initial margin of this position; when the equity is less than the initial margin required for the account, the available asset for closing a margin position can include the maintenance margin of this position.
Closing long positions with liability calculated in quote crypto:
Account equity ≥ account initial margin, the available asset for closing margin positions = (|liability + interest| of this margin position) * (1 + IMR% of this margin position) / mark price
Account equity < account initial margin, the available asset for closing margin positions = (|liability + interest| of this margin position) * (1 + MMR% of this margin position) / mark price
Closing short positions with liability calculated in base crypto:
Account equity ≥ account initial margin, the available asset for closing margin positions = (|liability + interest| of this margin position) * (1 + IMR% of this margin position) * mark price
Account equity < account initial margin, the available asset for closing margin positions = (|liability + interest| of this position) * (1 + MMR% of this position) * mark price
The rules of closing positions are the same as those of isolated positions, except the available asset formula.
No. | Mode | Closing method | Rule | Example |
1 | Close in Position | Market close all | 1. Only pay off the liabilities, and the remaining assets will be transferred to the spot and futures account balance. | User has a long position with available assets 2 BTC, liability 10,000 USDT, and interest 10 USDT. |
Using a limit order | 1. You can buy assets that exceed the liabilities. Once the liability is paid off, the margin position will be closed. The oversold assets and remaining ones will be transferred to the spot and futures account balance. | User has a long position with available assets 2 BTC, liability 10,000 USDT, and interest 10 USDT | ||
2 | Close in order placement area | Reduce only | The same as those of [Close in Position] | - |
Reduce + reverse position | 1. When the liability is paid off, the margin position will disappear. The oversold asset will be used to open a reverse position; | User has a short position with available assets 30,000 USDT, liability 2 BTC, with interest and transaction fees temporarily ignored. |
Position assets and margin are using different crypto
Short positions with base crypto as margin and having base crypto as liability.
Long positions using quote crypto as margin and having quote crypto as liability.
Principle of closing positions: Only position assets can be used to close a position. When the position assets are completely sold, the position will be closed. If the liability is not paid off, the equity in the account will be used to directly pay off the remaining liabilities; Users can choose whether to use "reduce only".The available asset that can be used to close the position = position assets.
No. | Mode | Closing method | Rule | Example |
1 | Close in Position | Market close all | 1. The position will be closed when all position assets are sold at market price. | User has a long position with available assets 2 BTC, liability 10,000 USDT, with interest and fees temporarily ignored.Its margin crypto is USDT, and its margin is in USDT spot and futures account balance. |
Using a limit order | 1. The position will be closed when all position assets are sold at limit price. | User has a long position with available assets 2 BTC, liability 10,000 USDT, with interest and fees temporarily ignored.Its margin crypto is USDT, and its margin is in USDT spot and futures account balance. | ||
2 | Close in order placement area | Reduce only | The same as those of [Close in Position] | - |
Reduce only + reverse position | 1. The position will be closed when all position assets are sold. The remaining assets will be used to open a reverse position; | User has a short position with available assets is 30,000 USDT, liability 2 BTC, with interest and fees temporarily ignored. |
Expiry and perpetual futures in cross margin mode
In spot and futures cross margin mode, both Hedge mode and One-way modes are supported.
Position fields
Term | Explanation | Parameter in Get position |
---|---|---|
Total | For the one-way mode, the total of long positions is a positive number, and the total of short positions is a negative number. | pos |
Avail. | Only shown in Hedge mode | availPos |
Floating PnL | Unrealized profit or loss of current position Floating PnL of long positions = face value * |number of contracts| * multiplier * (1 / avg. open price – 1 / mark price) Floating PnL of short positions = face value * |number of contracts| * multiplier * (1 / mark price – 1 / avg. open price) USDT-margined Floating PnL of long positions = face value * |number of contracts| * multiplier * (mark price – avg. open price) Floating PnL of short positions = face value * |number of contracts| * multiplier * (avg. open price - mark price) | upl |
Floating PnL % | Floating PnL / initial margin | uplRatio |
Initial margin | Crypto-margined Initial margin = face value * |number of contracts| * multiplier / (mark price * leverage) USDT-margined Initial margin = face value * |number of contracts| * multiplier * mark price / leverage | imr |
Maintenance margin | Crypto-margined Maintenance margin = face value * |number of contracts| * multiplier * maintenance margin ratio / mark price USDT-margined Maintenance margin = face value * |number of contracts| * multiplier * maintenance margin ratio * mark price | mmr |
Options in cross margin mode
In spot and futures mode, you will be able to open long and short positions of options
Position fields
Term | Explanation | Parameter in Get position |
---|---|---|
Total | The total of long positions is a positive number, and the total of short positions is a negative number. | pos |
Options value | If the unit for calculating the price is crypto, then options value = total positions * mark priceIf the unit for calculating the price is the number of contracts, then options value = total positions * mark price * multiplier | optVal |
Floating PnL | Unrealized profit or loss of current position Floating PnL = (mark price - avg. open price) * total positions * multiplier | upl |
Floating PnL % | Floating PnL % = (mark price – avg. open price) / avg. open price Floating PnL % = (avg. open price - mark price) / avg. open price | uplRatio |
Initial margin | The initial margin for long positions is 0. Information on how to calculate the initial margin for short positions can be found here. | imr |
Maintenance margin | The maintenance margin for long positions is 0. Information on how to calculate the maintenance margin for short positions can be found here. | mmr |
Risk assessment
The spot and futures cross margin mode applies a double-layer risk assessment measure. The first layer is "order cancellation by risk control system", and the other is "pre-liquidation verification". This measure ensures a smooth trading experience, prevents the open orders from being completely canceled, and prevents the positions from being partially or even fully liquidated due to insufficient margin.
Order cancellation by risk control system
If a user's account is assessed as risky but not risky enough to trigger "pre-liquidation verification", the" order cancellation by risk control system" will be executed, and some open orders will be canceled to ensure the account stays within a safe risk control level, which can prevent the open orders from being canceled because of a sudden triggering of "pre-liquidation verification".Rules for "order cancellation by risk control system" in spot and futures margin mode
When (Available equity of the crypto in spot and futures account - used balance) < the required maintenance margin for all the positions + the initial margin for the open orders of opening positions in cross margin mode + the open orders fees, all the open orders that will increase the used equity amount will be cancelled. (Including the opening orders of futures, perpetual, options, and margin in both cross margin and isolated margin mode, as well as the open orders for selling the crypto).
When the available balance <0, all open orders in isolated margin mode, open orders for selling the crypto, and options buy orders will be canceled.
Pre-liquidation verification
The liquidation that happens in spot and futures margin mode is triggered depending on whether or not the margin level reaches 100%. In the spot and futures cross margin mode, the margin level is an indicator calculated from the cross margin account equity and maintenance margin in a certain crypto. Generally, the higher the account equity, and the lower the maintenance margin, the lower the risk.
When the margin level of a certain crypto in spot and futures cross margin mode is < 300%, the system will send a liquidation alert to the account, warning users of the risk of liquidation. 300% is set as the pre-alert parameter, and OKX reserves the right to adjust this parameter according to the actual situation.
When the margin level of a certain crypto in spot and futures cross margin mode is <= 100%, the system will cancel the orders according to the following rules, that is, order cancellation by pre-liquidation system:
Business line | Mode | Spot and futures cross margin |
Expiry and perpetual futures | Hedge mode | Cancel all unfilled open orders (including algo orders) in cross margin mode, the limit orders and stop-loss orders of opening positions in isolated margin mode; the stop-loss orders of closing positions in isolated margin mode and algo orders except stop orders in isolated margin mode will not be canceled. |
One-way mode | Cancel all unfilled open orders (including algo orders) in cross margin mode, and the limit orders of opening positions in isolated margin mode; algo orders in isolated margin mode will not be canceled. | |
Margin | - | Cancel all unfilled open orders (including algo orders) in cross margin mode, and the limit orders with the same direction of current positions in isolated margin mode; algo orders in isolated margin mode will not be canceled. |
Options | - | Cancel all unfilled open orders in cross margin mode and orders of opening positions in isolated margin mode. |
If the margin level is still <= 100% after the orders are canceled, the account will trigger a liquidation.The partial liquidation process can be divided into three phases. In each stage, the positions to be partially liquidated will be handed over to the liquidation engine at the mark price, and a certain amount of maintenance margin will be charged (It is determined by your position tier, which will make up for the loss of the liquidation engine, and the remaining will be injected into the insurance fund, which will not get additional liquidation fee). The option long position will not be partially liquidated.
Three phases of partial liquidation:
1)First, partial liquidation will start with the long and short reverse positions of the same contract under the Hedge mode.
2) When there is no position described in phase 1), or all positions described in phase 1) are partially liquidated, and the account is not restored to a safe state, the system will try to keep the total delta value of the account unchanged while attempting to reduce the overall risk of the account. That is, partially liquidate the long and short hedged positions in terms of delta value (Delta refers to a rate of change in the position value of a contract per change in the index price. When the two changes are in the same direction, the delta is positive. Otherwise, it is negative. The greater the change in the position value of a contract per change in the index price, the greater the absolute value of delta). If multiple positions meet the delta long and short offsetting conditions, the system will first partially liquidate the position with a larger maintenance margin.
3) When there is no position described in 2), or all positions described in 2) are partially liquidated (that is, the total delta value of the account cannot be kept almost unchanged at this time, while the account risk cannot be reduced), and the account has not been restored to safety status, the system will try to partially liquidate the remaining unhedged positions, and will give priority to those with the best risk reduction effect. Each time you partially liquidate your position, the position tier will be reduced by one level until the account is safe again.
For example, the current price of futures contract BTC-USD-0925 is 50000 USD/BTC, assuming the account assets are as follows:
Type | Amount |
Balance | 5 BTC |
Positions | Expiry futures: BTCUSD0925 +1000 conts, Position delta > 0 Options: BTCUSD-20200925-65000-C -100 conts, Position delta < 0 BTCUSD-20200925-55000-P -500 conts, Position delta > 0 |
Open orders | Expiry futures: BTCUSD1225 +100 conts, Order price at 9,000 Perpetual futures: BTCUSD perpetual swap -100 conts, Order price at 8,000 |
The liquidation condition is triggered when the margin level is 93%. After all the open orders are canceled, the margin level of the position turns 95%. Then the position goes into liquidation status. At this moment, the available equity in the cross margin account is 9.5 BTC, and the maintenance margin is 10 BTC.
The position does not contain the long and short reverse positions of the same contract in the long and short mode, but contains the long and short hedged positions in terms of delta value.
After calculation, the futures BTCUSD0925 will be liquidated by 500 conts of long positions, and the options BTCUSD-20200925-65000-C will be liquidated by 100 conts of short positions. After liquidation, the account equity is 9.4 BTC, and the maintenance margin is 9.6 BTC.
If the account is not restored to a safe state and there is no hedged position in the single currency account (all short positions of BTCUSD-20200925-65000-C are liquidated, and the delta value of all remaining positions is positive), please apply liquidation logic to unhedged positions.
Digital asset holdings, including stablecoins, involve a high degree of risk, can fluctuate greatly, and can even become worthless. Leveraged trading in digital assets magnifies both potential gains and potential losses and could result in the loss of your entire investment. Past performance is not indicative of future results. You should carefully consider whether trading or holding digital assets is suitable for you in light of your financial condition, particularly if considering the use of leverage. You are solely responsible for your trading strategies and decisions, and OKX is not responsible for any potential losses. Not all products and promotions are available in all regions. For more details, please refer to the OKX Terms of Service and Risk & Compliance Disclosure.
© 2024 OKX. All rights reserved.