Hedge Mode on Bybit V5: how it works and when you actually need it
Two independent legs on one symbol sound like more control. Sometimes they are. Often they are a way to pay funding on both sides while feeling hedged.
Vizanix engineering · about the author
- SECTION
- Bybit API
- PUBLISHED
- 2026-08-28
- CHAPTERS
- 5
- READ NEXT
- 3
- LANGUAGE
- written in English
In one-way mode a symbol has one position. Buying while short reduces the short. In hedge mode the same symbol can carry a long leg and a short leg at the same time, each with its own entry price, its own size and its own liquidation level.
What changes in the code
Mechanically the change is small and unforgiving. Orders carry a position index that says which leg they belong to. Get it wrong and the venue either rejects the order or — worse — applies it to the leg you did not mean.
- Position index
0is the single position in one-way mode. - Index
1is the long leg in hedge mode; index2is the short leg. - A reduce-only order must name the leg it reduces. Reduce-only without the right index is one of the more common sources of
110017. - Stop-loss and take-profit attach to a leg, not to the symbol.
The mode is a per-symbol account setting, and it cannot be changed while a position is open. A bot that assumes it can flip mode on demand will meet 110025 at the least convenient moment. Read the mode at startup, assert it matches configuration, and refuse to start on a mismatch rather than adapting silently.
POSITION_IDX = {("one_way", None): 0, ("hedge", "long"): 1, ("hedge", "short"): 2}
def place(symbol, side, qty, mode, leg=None, reduce_only=False):
idx = POSITION_IDX[(mode, leg)]
# In hedge mode a reduce-only order MUST name its leg, or it is rejected.
assert not (reduce_only and mode == "hedge" and leg is None)
return api.order(symbol=symbol, side=side, qty=qty,
positionIdx=idx, reduceOnly=reduce_only)Margin does not become free
The costly misconception: that a long and a short of equal size cancel out and leave you flat and safe. Directionally they do offset. Financially they do not.
- You pay funding on both legs. On a perpetual, a hedged pair typically pays the spread between the two funding flows continuously. Hedging is a position with a carry cost, not a pause button.
- Both legs consume margin. Depending on account mode and risk tier, offsetting positions may get partial margin relief, but you should verify what your account actually gets rather than assume the theoretical case.
- Both legs pay fees. Opening and eventually closing two positions costs four commissions where flattening costs one.
- Each leg has its own liquidation price. A hedged book is not immune to liquidation, particularly when one leg is added later at a much worse level.
When hedge mode earns its cost
There are real cases, and they share a shape: you genuinely need two independent decision processes on the same instrument.
- Two strategies, one symbol. A trend follower and a mean-reverter both trading BTCUSDT. In one-way mode they silently net each other out and neither one's risk accounting is true. In hedge mode each keeps its own position, stop and P&L.
- Separate risk rules per direction. Long entries sized one way, shorts another, with different stop logic that must not be merged.
- Staged exits with re-entry. Where the strategy needs to hold a residual position while opening an opposing tactical one.
Where it goes wrong
The pattern we see most often is hedging as loss avoidance. A long goes against the trader; instead of taking the stop, they open a short of equal size. The unrealised loss is now frozen rather than realised, which feels better and is financially worse: the position pays funding on both sides indefinitely, and the decision about which leg to close eventually has to be made anyway — usually at a moment of greater stress and less information.
A bot can implement this. We will implement it if a client specifies it. But it belongs in the specification as an explicit choice, with the carry cost visible in the monitoring, rather than emerging as a side effect of a risk rule that had no exit.
If you do use it, instrument it
- Track the net exposure and the gross exposure separately. Net tells you direction; gross tells you what you are paying for.
- Show cumulative funding paid per leg. Hedges get expensive quietly.
- Alarm on a hedged pair that has been open longer than the strategy intends. Legs that outlive their reason are how a hedge becomes a permanent tax.
- Keep the liquidation distance of each leg in the health output, not just the net.
Our futures work treats hedge mode as a first-class capability precisely because it needs this instrumentation to be safe. A hedged book without carry visibility is a position you have stopped measuring.
This article describes engineering practice. It is not investment advice. Vizanix develops software and does not promise trading returns.