Skip to content

Open-trade state loss#

HookTrader keeps open-trade state in fast internal storage; durable history is written to the database. This article explains what happens when internal state is lost mid-trade and how recovery works.

What's tracked internally#

HookTrader tracks your active trades, their current SL/TP/trail levels, and live price data while a trade is open. Permanent records of every fill and event are always saved to the database separately.

If no state was lost, HookTrader automatically re-arms monitoring for each open trade on restart. Recovery from a routine restart is automatic and transparent.

What happens if internal state is wiped while trades are open#

This is the bad case. On restart:

  1. HookTrader finds no record of open trades in internal state.
  2. No trade monitoring is re-armed.
  3. The exchange-side algo orders still exist (Binance doesn't know about the state loss) — the trade is still protected by its STOP_MARKET and TAKE_PROFIT_MARKETs.
  4. HookTrader's resync process scans Binance for open positions and pulls any fills that landed across the outage into the database.

What's preserved:

  • The position itself on Binance.
  • The resting SL and TP algos.
  • Database records of every fill — all entry, exit, and partial fill history is recoverable from the exchange trade history.
  • Entry, original SL, original TPs (can be rebuilt from the database).

What's lost:

  • The current trail level — if your trailing stop had advanced past the original SL, the exchange still holds the last stop-loss HookTrader placed, but HookTrader's own record of the active trail is gone. You may need to manually reset the trail level.

Recovery path#

The dashboard can reconstruct the trade view from the database. Live Trades will show the position with its history, but until the next event (a TP cross, SL fire, or webhook), the trail won't be actively managed.

Practical steps:

  1. Check Binance directly — confirm the position and resting orders are intact.
  2. If the trail had advanced significantly past the original SL, manually move the SL on Binance to where you'd want it, or send a move_sl alert via your indicator to restore HookTrader's in-memory state.
  3. Reactivate the strategy — incoming webhooks will pick up where they left off.

How likely is this?#

Extremely unlikely. HookTrader is designed for high availability and state loss would only occur in a catastrophic infrastructure event. The recovery steps above are a worst-case safety net, not something you should expect to need.

See also#