/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
Haltvariant added to the command enum- Parse arm wired (matches
"halt"token inparse_autotrade) run_halt(pool) -> Stringasync function: callsconfig::halt, returns a confirmation or stringified error- Unit test for the halt parse arm + success path
Key Design Decisions
| Decision | Rationale |
|---|---|
Single atomic UPDATE for both mode and exit_mode | No window where mode=off but exit_mode still auto_sell — one SQL round-trip, no intermediate state |
Does NOT reset breaker_tripped / breaker_fail_count | Halt is a stop, not an arm; breaker state is preserved for diagnostics and must be reset explicitly |
| Does NOT cancel in-flight orders | Only prevents new automated submissions from the next engine tick; any order already handed to the CLOB is unaffected |
exit_mode = 'notify' not null | Exits become Telegram alerts + 1-click /autotrade sell rather than silent; visibility is preserved even when the engine is fully halted |
Halt vs Off
/autotrade offstops new ENTRIES but exits still execute automatically (exit_modeunchanged)./autotrade haltstops BOTH — entries AND automatic exits. After a halt, all exit signals surface as Telegram notifications that require a manual/autotrade sellaction.
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 = 1State After Halt
| Field | Value | Effect |
|---|---|---|
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_tripped | unchanged | Preserved for diagnostics |
breaker_fail_count | unchanged | Preserved for diagnostics |
For Agents
haltis the most conservative safe state for the autotrade engine.mode='off'andexit_mode='notify'together mean no automated order flow of any kind. The config singleton is alwaysid = 1. The breaker state is intentionally NOT cleared here — checkautotrade_breaker_modulefor breaker reset semantics.
Related
- autotrade-commands-bot-wiring — dispatcher that routes
/autotrade haltintorun_halt - autotrade-config-repo —
config.rslayer wherehalt()lives alongsideload,update_numeric,set_text - autotrade-breaker-module — circuit breaker; its state is NOT touched by halt
- pmv2-autotrade-engine-design — overall engine design, mode/exit_mode semantics, kill-switch architecture