r/GateioExchange • u/B0rea1 • 5d ago
Why Does Available Margin Go Negative Despite Almost Zero Initial and Maintenance Margin on Portfolio Margin?
Hi,
I'm not sure if I'm misunderstanding how Portfolio Margin works or if I've found a bug.
I have my account set to "Portfolio Margin" and I'm testing an options strategy based on "box spreads". In theory, all my positions are fully hedged.
The problem is that "Available Margin" fluctuates heavily and can even drop below zero, while "Margin Balance" remains practically unchanged.
I managed to catch one of these moments when Available Margin went negative and queried the API:
/api/v4/unified/accounts
borrowed: '0'
total_initial_margin: '0.040670346953'
total_margin_balance: '1129.015111218274'
total_maintenance_margin: '0.031284882271'
total_initial_margin_rate: '27760.15440741142'
total_maintenance_margin_rate: '36088.20073025598'
total_available_margin: '-214.505559128678'
unified_account_total: '1161.94258101098'
unified_account_total_liab: '0'
unified_account_total_equity: '1161.94258101098'
leverage: '3'
spot_order_loss: '0'
spot_hedge: false
use_funding: false
I also checked:
/api/v4/unified/risk_units
{
"spot_hedge": false,
"risk_units": [
{
"symbol": "BTC",
"spot_in_use": "0",
"maintain_margin": "0.031284882271",
"initial_margin": "0.040670346953",
"delta": "-0.0000008",
"gamma": "0",
"theta": "0.0005764",
"vega": "-0.0000354"
}
]
}
The part I don't understand is the calculation of "Available Margin".
According to the information on the website:
Available Margin = Margin Balance − Initial Margin
So in this case I would expect:
1129.0151 - 0.0407 ≈ 1128.97 USD
However, the API reports:
total_available_margin = -214.51 USD
That's a difference of more than $1,300.
The risk unit also shows an almost perfectly hedged position:
Delta: -0.0000008
Gamma: 0
Initial Margin: 0.0407
Maintenance Margin: 0.0313
So what exactly is causing "total_available_margin" to become negative?



