Hedge Guard

What it does
Detects when your long position has fallen significantly behind your short position and temporarily increases long OPEN order size so the long side catches up through normal grid activity. Deactivates once the sides are roughly balanced again.

Why this exists

When price trends strongly in one direction, one side accumulates a much larger position than the other. Your short grows while your long stays small, or vice versa. Left unchecked, this widens the net exposure gap and concentrates risk on one side.
Hedge Guard solves this by temporarily increasing long OPEN order sizes so your long catches up to your short through normal grid activity. Once the sides are close enough in size, it deactivates automatically.
This feature only activates for your long. There is no equivalent for your short.
For all config fields, see Config Reference → Hedge Guard.

How activation and deactivation work

Hedge Guard uses two separate thresholds: one to switch on and a higher one to switch off. This gap between them creates a buffer zone so the feature does not toggle on and off repeatedly when positions hover near the boundary.
  • Activates when your long falls below entryThresholdPct (default 0.667) of your short size
  • Deactivates only when your long recovers above exitThresholdPct (default 0.9) of your short size
Your long must fall well behind to trigger it, and must recover substantially before it turns off.

Worked example

Hedge Guard activates when your short position is 50% larger than your long position. With default settings, entryThresholdPct = 0.667 produces exactly this: it triggers when your long is less than 66.7% of your short, meaning your short is at least 50% larger.
Settings: defaults (multiplier = 1.5, entryThresholdPct = 0.667, exitThresholdPct = 0.9, cooldownMs = 60000).
You hold $1,500 short and $1,000 long on HYPEUSDT. Your short is 50% larger than your long.
Step 1: Entry check
ValueCheck
Your long$1,000
Your short$1,500
Entry threshold (0.667 × $1,500)$1,000.50$1,000 < $1,000.50 → Hedge Guard activates
Step 2: While active
Order typeNormal sizeActive size
Long OPEN orders$10.00$15.00 (1.5× multiplier)
Short OPEN orders$10.00$10.00 (unchanged)
Step 3: Recovery and exit check
ValueCheck
Your long (after recovery)$1,400
Your short$1,500
Exit threshold (0.9 × $1,500)$1,350$1,400 > $1,350 → Hedge Guard deactivates
Step 4: Cooldown
For the next 60 seconds, Hedge Guard will not reactivate even if your long dips back below the entry threshold. This prevents rapid toggling after deactivation.

Startup behavior

When the bot starts (or restarts), the cooldown timer begins immediately. This prevents the bot from activating Hedge Guard right after a restart based on stale state. The bot needs to observe at least one cooldown period of stable market data before it can activate for the first time.

Technical notes

  • Two-state machine: The bot switches between NORMAL (standard sizing) and HEDGE_ACTIVE (multiplied sizing). Each transition triggers a grid reconstruction to update all outstanding orders.
  • Long-only mode: If you run long-only (no short track for a symbol), Hedge Guard never activates since there is no short position to compare against.

Tuning tips

If you want...Adjust this
Hedge Guard to trigger only on large imbalancesLower entryThresholdPct (e.g. 0.5 requires short to be 2x long)
Long to recover closer to full parity before deactivatingRaise exitThresholdPct toward 1.0
Long to catch up fasterIncrease multiplier (note: larger orders mean larger position growth)
Fewer on/off cycles when positions hover near the thresholdRaise cooldownMs (e.g. 120000 for a 2-minute cooldown)
See Config Reference for all fields.