Skip to content

Both and hedge mode

Both

A Both strategy has a Long side and a Short side, each with its own entry and its own exit. Both sides use the same main timeframe. The trigger may be On candle close or On candle touch. Buy and Hold, a trailing entry and trading hours are not available on either side.

Both can be used for a trade, a signal or a backtest on Perpetual and Futures, and on a Kraken Margin pair whose symbol contains :BTNL. Spot and other Margin pairs refuse it.

The Strategy Library's TK-flip shared wallet is a Both strategy. Its card is labeled Long + short, one shared position, which is the hedge-off case below.

One wallet per account

Paper and live keep one wallet per exchange account and market type, shared by every pair on it. A long on one pair and a short on another (for example a BTC long and an ETH short) always run at the same time, whatever the hedge mode.

When the wallet can cover only one side, the long gets the margin first. The short is rejected whole, not shrunk to fit.

Hedge mode

Hedge mode is not a setting. Apathia uses it only when it detects it on the account, and only for a long and a short on the same pair. Apathia never changes the exchange's mode.

  • Live reads the account when the trade starts. An account that cannot be read runs one-way.
  • Paper uses the linked account's detected mode.
  • A backtest uses that account's last detected value.

Apathia can detect hedge mode on OKX (okx) Perpetual and Futures, on Binance USD-M and COIN-M when the symbol shows the book (BTC/USDT:USDT is USD-M, BTC/USD:BTC is COIN-M), and from positions on Bybit, Bitget, Phemex, Woo and HTX. Everywhere else hedge is off.

Hedge off

Only one side of the pair is open at a time.

  • If the long entry and the short entry are both true on the same decision while flat, the long opens and the short is skipped.
  • An opposite entry while a side is open is skipped. The open position is never closed, reversed or flipped.
  • After that side has closed, a later signal on the other side may enter.

Hedge detected

The long and the short on the pair may be open together, each with its own exit.

  • Each leg takes its own isolated margin (the position's value divided by the leverage) plus its own entry fee from the shared wallet.
  • The size comes from the wallet before this decision's new entries, not from the cash left after the other leg.
  • If both entries are true together, the long is placed first at full size. The short is placed only when the cash left pays its full margin and fee; otherwise it is rejected whole.
  • A leg is never flipped into the other side.

If the exchange refuses a hedge-tagged order, that order is refused whole and opposite entries on that pair are skipped, never flipped and never retried one-way. The alert says opposite entries will be skipped until you switch the account to hedge mode on the exchange.

  • In a backtest, On candle touch uses the candle-colour path to estimate which side was touched first (a green or flat candle moves open → low → high → close; a red one open → high → low → close). If both sides are touched at the same point, including a gap through both levels, the long opens and the short is skipped on that bar. After a mid-bar exit, the backtest takes no new touch entry on that bar; live can still re-enter on later ticks. Paper and live check each tick against both sides in the order the ticks arrive. See Backtest and When orders fill.
  • Under Isolated, liquidation keeps hedge legs separate, each with its own margin. Under Cross, positions in the same shared pool (Standard trades, Ladder runs and Carry's perp leg on that account and market type) liquidate together, so a hedge's long and short in that pool share one liquidation; isolated trades stay out of that pool. See Liquidation.
  • A perpetual Grid (0.13.1, unreleased) never holds both sides at once, so it behaves the same on one-way and hedge accounts. See Grid perpetuals and recenter.
  • No exchange-side safety stop is placed for either side. See Safety stops.