<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DeepRade</title>
    <description>The latest articles on DEV Community by DeepRade (@deeprade).</description>
    <link>https://dev.to/deeprade</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4221503%2F8af77a00-9834-4ceb-8704-0ac395d3c259.jpg</url>
      <title>DEV Community: DeepRade</title>
      <link>https://dev.to/deeprade</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deeprade"/>
    <language>en</language>
    <item>
      <title>Liquidation isn't triggered by a price — it's triggered by running out of margin</title>
      <dc:creator>DeepRade</dc:creator>
      <pubDate>Tue, 03 Nov 2026 01:08:02 +0000</pubDate>
      <link>https://dev.to/deeprade/liquidation-isnt-triggered-by-a-price-its-triggered-by-running-out-of-margin-17ic</link>
      <guid>https://dev.to/deeprade/liquidation-isnt-triggered-by-a-price-its-triggered-by-running-out-of-margin-17ic</guid>
      <description>&lt;p&gt;Last week roughly &lt;strong&gt;$1.6 billion&lt;/strong&gt; in crypto positions was liquidated in a single day after an exchange reported a theft. Almost none of those traders were wrong about the direction. They were wrong about a rule: &lt;em&gt;how much margin a position must keep to stay open.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is the mechanism, in the order it actually fires.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The price that kills you is not the last traded price
&lt;/h2&gt;

&lt;p&gt;Most venues compute liquidation against a &lt;strong&gt;mark price&lt;/strong&gt; — an index built from several spot exchanges — rather than the last trade on their own book. The reason is protective: a single wick on one exchange shouldn't vaporise positions across the market.&lt;/p&gt;

&lt;p&gt;That protection produces the two confusing observations you've probably seen on a forum:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"The candle clearly wicked down to my liquidation level, but I survived." → the mark price never got there.&lt;/li&gt;
&lt;li&gt;"The candle never touched it and I still got liquidated." → the mark price did.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you build anything that reads candles and shows a liquidation line, &lt;strong&gt;decide explicitly which price you are using&lt;/strong&gt; and label it. Mixing them is the single most common source of wrong backtests.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The actual condition
&lt;/h2&gt;

&lt;p&gt;A position ties up two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Initial margin&lt;/strong&gt; — what you locked to open it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintenance margin&lt;/strong&gt; — the minimum that must remain, expressed as a percentage of the position's notional value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Liquidation fires when:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wallet_balance &amp;lt; notional_value × maintenance_margin_rate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Worked example, with round numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;notional            = 10,000 USDT
leverage            = 10x
initial margin      = 1,000 USDT
maintenance rate    = 0.5%   (example only)
threshold           = 10,000 × 0.005 = 50 USDT
→ the position dies once the margin balance falls to 50 USDT,
  i.e. after roughly 950 USDT of loss, not after 1,000.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Those rates are per-exchange and per size tier, and higher leverage usually carries a higher maintenance rate.&lt;/strong&gt; Read the venue's own rules page before you hard-code anything — a bot that assumes 0.5% everywhere will be confidently wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Why liquidations cascade
&lt;/h2&gt;

&lt;p&gt;A liquidation order is a &lt;strong&gt;market order&lt;/strong&gt;. It takes liquidity rather than providing it. The first wave eats the best bids, the mark price moves another tick, more positions cross their threshold, and those orders hit the book too. Nothing new needs to happen for the waterfall to continue — the mechanism is self-feeding while depth is thin.&lt;/p&gt;

&lt;p&gt;For software this matters twice: your simulator must model &lt;em&gt;slippage against a shrinking book&lt;/em&gt;, and your risk layer should treat "distance to liquidation" as a &lt;strong&gt;non-linear&lt;/strong&gt; quantity, not a linear buffer.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Cross vs isolated margin
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cross&lt;/strong&gt;: every open position draws on the same free balance. One blown position can eat the collateral that was protecting the others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Isolated&lt;/strong&gt;: each position has its own slice; the worst case is that slice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The difference isn't about which earns more. It's about &lt;strong&gt;which one survives a wick&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What to do before you touch real money
&lt;/h2&gt;

&lt;p&gt;Two concrete calculations, both of which belong in software rather than in memory:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Compute the liquidation price for the leverage you picked, then measure &lt;strong&gt;how many percentage points away it is from the current price&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Compare that distance against the loss you decided you're willing to take. If the liquidation sits closer than your stop, the leverage is wrong — not the market.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We run this as a &lt;strong&gt;simulation-first&lt;/strong&gt; flow in DeepRade: the strategy executes against replayed market data, you watch it hit liquidation in a sandbox, and only then does it get a live key. The terminal runs locally and keeps exchange API keys on your machine, so the dry run and the live run are the same code path with different credentials.&lt;/p&gt;

&lt;p&gt;One boundary we keep hard: this explains &lt;strong&gt;mechanism&lt;/strong&gt;, it does not forecast direction, and nothing here is investment advice.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Chinese original of this piece lives at &lt;a href="https://community.deeprade.com/t/67" rel="noopener noreferrer"&gt;https://community.deeprade.com/t/67&lt;/a&gt; — this is our own translation for the dev.to audience.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>finance</category>
      <category>python</category>
      <category>api</category>
    </item>
  </channel>
</rss>
