Articles ·

How a Metrand backtest prices liquidation and the largest position

Leverage lets an account carry a position larger than itself. The exchange keeps part of the position's value as maintenance margin, and when the account's equity falls to it, the position is liquidated and the account loses what is left. How much the exchange keeps is not one number: it is set per market, and it grows with the size of the position. A Metrand backtest uses the schedule of the market it replays.

The schedule

Each market publishes a table of tiers. A position whose value falls in a tier keeps that tier's rate of its value, less a fixed deduction that makes the requirement continuous across tiers, and may be opened at up to that tier's leverage. Two markets on Binance USDⓈ-M, as read on 23 October 2026:

Market Position value, USDT Maintenance margin Up to
BTCUSDT up to 300,000 0.40% 150×
BTCUSDT 300,000 – 800,000 0.50% less 300 100×
BTCUSDT 800,000 – 3,000,000 0.65% less 1,500 75×
BTCUSDT 3,000,000 – 12,000,000 1.00% less 12,000 50×
LTCUSDT up to 10,000 0.50% 75×
LTCUSDT 10,000 – 50,000 1.00% less 50 50×
LTCUSDT 50,000 – 160,000 1.50% less 300 40×

Smaller markets keep more: 2.5% from the first dollar is common. A backtest that charged every market BTCUSDT's 0.4% put liquidation too far away on most of them.

The liquidation price

The position is liquidated where the account's equity equals the maintenance margin:

where cost is what the position cost, wallet the account's balance and rate and deduction those of the tier the position's value falls in at that price. A long is worth less as the price falls toward its liquidation, so its tier there can be lower than at entry; the engine finds the one tier whose answer lands inside it. Funding paid and losses taken are already out of the wallet, so they bring the price closer, as on a cross-margin account. A liquidated account loses its whole balance.

A 10× long at 100 on 1,000 USDT: on a market that keeps 2.5% it is liquidated at 92.36; a flat 0.4% put liquidation at 90.41, below the low, and kept the position
The same long and the same prices: the market's own schedule liquidates it, a flat 0.4% did not.

A 10× long, 100 units at 100 on 1,000 USDT, has 995 USDT left after the entry fee. On a market that keeps 2.5% it is liquidated at (10,000 − 995) / (100 × 0.975) ≈ 92.36. A flat 0.4% put that price at 90.41, so a drop to 91.5 used to leave the position open and let it recover. On the exchange it would have been gone.

The largest position

The leverage an account is set to decides how large its position may grow: up to the value of the last tier that still allows that leverage. On BTCUSDT at 20× that is 100,000,000 USDT; on LTCUSDT at 20×, 1,600,000; on a small market at 15×, often a few hundred thousand. An entry that would take the position past it is not opened, as the exchange rejects it. The report counts these entries (entries_skipped_position_limit) and the app says how many there were and where the limit stood.

A leverage above the market's maximum (LTCUSDT's 75×, for one) is refused before the backtest runs and before it is charged: the exchange would not let the account set it.

Where the schedule comes from

Binance publishes the schedule of every USDⓈ-M market at once, without a key, at the address its own Leverage & Margin page reads; Bybit publishes its risk limits through its public market API. The platform reads both once a day and keeps them. A read that fails leaves the last schedule in place, and every backtest names the one it used: report.config.margin_tiers is, for example, "binance 2026-10-23", and report.config.position_limit the largest position at the backtest's leverage. A market whose schedule has never been read is replayed on a flat 0.4% with no position limit, and says so: margin_tiers: "flat".

The schedule in force today is applied to the whole history: exchanges change their tiers from time to time and do not publish the past ones.

In the API

A backtest request may carry its own schedule:

"margin_tiers": {
  "source": "binance",
  "as_of": "2026-10-23",
  "tiers": [
    {"cap": 300000, "mmr": 0.004, "cum": 0, "max_leverage": 150},
    {"cap": 800000, "mmr": 0.005, "cum": 300, "max_leverage": 100}
  ]
}

Tiers come smallest first, each up to cap USDT of position value; mmr is a fraction (0.004 is 0.4%) and cum the deduction. Caps must rise, rates lie in (0, 0.5], deductions are not negative and leverage never rises from one tier to the next. A schedule that breaks these, or a leverage above the first tier's, is refused with backtest_config_invalid: and the reason, for example backtest_config_invalid: leverage=25 is above the 20x this market allows.