/autotrade halt is the full-stop command for the real-money auto-trade engine — a single atomic SQL UPDATE that freezes both new order submission and automatic exit execution.

What Was Built

config.rs — crates/polymarket-fetch/src/pmv2/autotrade/config.rs

New async function:

pub async fn halt(pool: &PgPool) -> Result<()>

Executes a single UPDATE pmv2_autotrade_config SET mode = 'off', exit_mode = 'notify', updated_at = now() WHERE id = 1 — both columns change together with no intermediate state.

commands.rs — crates/polymarket-fetch/src/pmv2/autotrade/commands.rs

  • Halt variant added to the command enum
  • Parse arm wired (matches "halt" token in parse_autotrade)
  • run_halt(pool) -> String async function: calls config::halt, returns a confirmation or stringified error
  • Unit test for the halt parse arm + success path

Key Design Decisions

DecisionRationale
Single atomic UPDATE for both mode and exit_modeNo window where mode=off but exit_mode still auto_sell — one SQL round-trip, no intermediate state
Does NOT reset breaker_tripped / breaker_fail_countHalt is a stop, not an arm; breaker state is preserved for diagnostics and must be reset explicitly
Does NOT cancel in-flight ordersOnly prevents new automated submissions from the next engine tick; any order already handed to the CLOB is unaffected
exit_mode = 'notify' not nullExits become Telegram alerts + 1-click /autotrade sell rather than silent; visibility is preserved even when the engine is fully halted

Halt vs Off

/autotrade off stops new ENTRIES but exits still execute automatically (exit_mode unchanged). /autotrade halt stops BOTH — entries AND automatic exits. After a halt, all exit signals surface as Telegram notifications that require a manual /autotrade sell action.

Resume path

To resume after a halt: /autotrade live (re-enables entries) and /autotrade exits auto_sell (re-enables automatic exit execution). Both steps are required to fully restore normal operation.

SQL

UPDATE pmv2_autotrade_config
SET mode = 'off', exit_mode = 'notify', updated_at = now()
WHERE id = 1

State After Halt

FieldValueEffect
mode'off'Engine skips all entry gate evaluation; no new orders submitted
exit_mode'notify'Exit signals send Telegram alerts; no automatic sell orders
breaker_trippedunchangedPreserved for diagnostics
breaker_fail_countunchangedPreserved for diagnostics

For Agents

halt is the most conservative safe state for the autotrade engine. mode='off' and exit_mode='notify' together mean no automated order flow of any kind. The config singleton is always id = 1. The breaker state is intentionally NOT cleared here — check autotrade_breaker_module for breaker reset semantics.