Formulas & Calculations
Trading formulas, conversion rules, margin calculations, and High Margin Requirements.
Precision rule
Use decimal-safe arithmetic for money, prices, margin, and volume. Do not rely on binary floating-point for critical calculations.
Trading formulas
Equity
Total value of a trader account at any current time.
Formula:
equity = balance + floating_pnl
Where:
balance= realized account balance (reflects the result of all balance operations and result of closed positions)
trade commissions as well as swap fees\admin fees - are applied to the account balance immediately at the moment of charging
floating_pnl= unrealized PnL for currently opened positions
Notes
- all values are in account currency
Floating PnL
Floating PnL represents unrealized profit or loss for currently open positions. It does not affect account balance and represents the potential profit or loss that would be realized if a trade were closed at the current market price.
Formula:
floating_pnl = sum of PnL for all opened positions = sum (buy_position_pnl) + sum (sell_position_pnl)
Where:
-
``buy_position_pnl
= volume * (LastBidPrice - OpenPrice) * contractSize * ProfitRate -
``sell_position_pnl
= volume * (OpenPrice - LastAskPrice) * contractSize * ProfitRate -
volume = position volume in lots -
contractSize= instrument contract size -
OpenPrice= position open price -
LastBidPrice/LastAskPrice= last instrument tick -
ProfitRate= rate for conversion from instrument quote currency to the account currency (see conversion rules below)
Notes
-
floating_pnlis in account currency -
once a position is closed, realised pnl (Profit) is stored to the closing deal and applied to the account balance
Used margin
Used margin represents the amount of funds currently reserved to maintain open positions. Margin acts as a deposit, not a fee, and is returned after an order is closed, provided losses don't consume it. Margin requirements for fully hedged orders equal 0%. Partially hedged orders margin applied to the unhedged part. No margin is taken for pending orders.
Formula:
-
if the instrument calculation mode is "Forex" or "ForexNoLeverage" (instrument.calc_mode=1 or instrument.calc_mode=2):
used_margin = volume * contractSize * marginRate * marginPercentage -
if the instrument calculation mode is "CFD" or "CFDLeverage" (instrument.calc_mode=3 or instrument.calc_mode=4):
used_margin = volume * contractSize * openPrice * marginRate * marginPercentage
Where:
-
volume= position volume in lots -
contractSize= instrument contract size -
openPrice = position open price
-
marginRate= rate for conversion from instrument margin currency to the account currency (see conversion rules below) -
marginPercentage depends on the instrument calculation mode:
Forex / CFDLeverage:
marginPercentage = 1 / account.leverage
if the account has unlimited leverage => marginPercentage=0
- ForexNoLeverage / CFD (fixed margin):
marginPercentage = instrument.margin_percent
Notes:
-
High Margin Requirements may be applied at some specific period of time for certain instruments.
-
For the majority of instruments, orders opened up to 15 minutes before and 90 seconds after a high-impact news release are subject to higher margin requirements (HMR). During this time, leverage for affected instruments is capped. Learn more about the leverage requirements for instruments below.
-
After HMR, margins are recalculated based on the account’s equity and leverage.
-
HMR is also applied before and after scheduled market breaks, including weekends, public holidays, and daily breaks.
-
Once the HMR period ends, margin requirements are automatically recalculated based on the account’s equity and selected leverage.
Instruments and their leverage during HMR
| Instrument group | Instruments | Leverage during HMR |
|---|---|---|
| Forex | All | 1:200 |
| Energies | USOIL | 1:20 |
| Energies | UKOIL | 1:20 |
| Energies | XNGUSD | 1:5 |
| Metals | XAU | 1:200 – 1:1000 |
| XAG | 1:50 – 1:200 | |
| XALUSD, XCUUSD, XNIUSD, XPBUSD, XZNUSD | 1:50 | |
| Metals | XAG | 1:50 – 1:200 |
| Metals | XALUSD | 1:50 |
| Metals | XCUUSD | 1:50 |
| Metals | XNIUSD | 1:50 |
| Metals | XPBUSD | 1:50 |
| Metals | XZNUSD | 1:50 |
| Indices | US30, USTEC, US500 | 1:50 – 1:100 |
| Indices | USTEC | 1:50 – 1:100 |
| Indices | US500 | 1:50 – 1:100 |
| Indices | All others | 1:20 – 1:50 |
| Stocks | All | 1:5 |
| Cryptocurrencies | All | 1:200 |
HMR periods before & after weekend market breaks
| Instrument group | Before weekend break | After weekend break |
|---|---|---|
| All trading instruments except BTC and ETH* | ~3 hours | 1 hour |
HMR periods before & after daily market breaks
| Instrument group | Before daily break | After daily break |
|---|---|---|
| US Indices (US500, US30, USTEC) | ~3 hours | 10 minutes |
| JP225 | ~1 hour 30 minutes | 1 hour 40 minutes |
| DE30, FR40, UK100 | 1 hour 35 minutes | 9 hours 10 minutes |
| STOXX50 | 1 hour 35 minutes | 2 hours 25 minutes |
| HK50 | 30 minutes Last session: ~4 hours | 15 minutes |
| AUS200 | 4 hours Last session: ~4 hours | 5 minutes |
| USOIL | 30 minutes | 5 minutes |
| UKOIL | ~30 minutes | 5 minutes |
| Gold (XAU*) | 30 minutes | ~10 minutes |
| Silver (XAG*) | 30 minutes | ~10 minutes |
| Stocks | 20 minutes | 15 minutes |
| BTCXAG, BTCXAU | ~30 minutes | 5 minutes |
Details: https://get.exness.help/hc/en-us/articles/20618327917596-Higher-Margin-Requirements-HMR
Free margin
While the broker holds a margin for open orders, the free margin is the funds remaining in the trading account that are not held and are free to use for new orders.
Formula:
free_margin = equity - used_margin
Where:
-
equity= current account equity -
used_margin= currently reserved margin for open positions
Margin level
Margin level represents account risk level.
Formula:
margin_level = (equity / used_margin) * 100
- If
used_margin = 0, margin level is undefined. This is the case when an account has no opened positions.
Margin call conditions
margin_level <= margin_call_level
A margin call is an alert sent by the trading platform, warning that it may be necessary to deposit funds or close a few position(s) to avoid a stop out. This notification is sent once the margin level drops to a certain amount, known as the margin call.
Stop out conditions
margin_level <= stopout_level
Stop out (account liquidation) is triggered when account margin level falls below the configured stop out threshold.
Stop out is the automatic closing of opened positions (even hedged positions) when the margin level drops to the stop out level.
Notes:
At Exness, margin call and stop levels are based on trading account types.
| Account | Margin Call | Stop Out |
|---|---|---|
| Standard Cent | 60% | 0% |
| Standard | 60% | 0% |
| Pro | 30% | 0% |
| Raw Spread | 30% | 0% |
| Zero | 30% | 0% |
For stocks, stop out level can be increased to 100% in case of increased market risk.
Leverage
Leverage is the ratio of equity to the capital provided by the broker, which affects the margin required for an open order.
-
The minimum leverage setting is 1:2
-
Leverage cannot be disabled
-
The leverage requested by the client when opening an account is not a mandatory requirement for execution. Leverage may be recalculated to account for periods of increased margin requirements or other rules.
-
Leverage may be reduced during High Margin Requirement (HMR)
-
The current leverage can be tracked through HMR updates on the Server Events stream.
Details: https://get.exness.help/hc/en-us/articles/360014529380-Leverage
Conversion rules
Trading calculations requires currency conversion to account currency. It's needed to define a rate for conversion.
How it works:
if currency_from = currency_to:
then conversion_rate = 1.0
else:
try direct conversion (find a currency pair XXXYYY, where XXX=currency_from and YYY=currency_to)
else try reverse conversion (find a currency pair YYYXXX, where XXX=currency_from and YYY=currency_to)
else try two-step conversion through USD: currency_from -> USD -> currency_to (note: at each step there may be XXXYYY or YYYXXX conversion cases)
For conversion, it's needed to define a certain price to be applied. To do so, we need to define ConversionDirection (it's not the same as PositionDirection):
-
ConversionDirection::Sell:
base_currency -> quote_currency : bid
quote_currency → base_currency : 1 / ask
-
ConversionDirection::Buy:
base_currency → quote_currency : ask
quote_currency → base_currency : 1 / bid
Example for EURUSD (bid = 1.1000 / ask = 1.1002):
- If converting EUR → USD:
Sell selection -> rate = bid = 1.1000 Buy selection -> rate = ask = 1.1002
- If converting USD→ EUR:
Sell selection -> rate = 1 / ask = 1 / 1.1002 Buy selection -> rate = 1 / bid = 1 / 1.1000
ProfitRate
ProfitRate converts from instrument quote currency to account currency.
ForProfitRate, ConversionDirection depends on the instrument calc_mode:
-
if the instrument calculation mode is "Forex" or "ForexNoLeverage" (instrument.calc_mode=1 or instrument.calc_mode=2) - depends on position direction: `Buy Position -> ConversionDirection=Buy
Sell Position -> ConversionDirection=Sell`
-
if the instrument calculation mode is "CFD" or "CFDLeverage" (instrument.calc_mode=3 or instrument.calc_mode=4) - depends on position profitability: `Position is profitable (profit > 0) -> ConversionDirection=Sell
Position is losing (profit < 0) -> ConversionDirection=Buy`
MarginRate
MarginRate converts from instrument margin currency to account currency.
It is calculated on position opening and the stored in "Position.margin_rate" field.
For MarginRate, need to use ConversionDirection the same as Position direction:
Buy position -> ConversionDirection=Buy
Sell position -> ConversionDirection=Sell