Skip to content

The service

An agent that trades on its own must keep running when nobody is watching. trading-agent runs as the systemd user service trading-agent.service: systemd starts it at boot, restarts it ten seconds after a crash, and the desks resume their conversations.

The service systemd starts the gateway at boot and restarts it after a crash; every desk resumes its session. starts at boot restarts after 10 s resumes every session SIGKILL systemd --user trading-agent.service Restart=always enabled; runs without a login A crash tested with kill -9 on 17 Oct The gateway four desks, still in dry_run PID 883818, then 891447 Each desk's session the scalper still knew "PAPAYA" after the crash bin/trading-agent preflight what stands between today and live orders DONE Every doctor check DONE Service enabled and running DONE Desk limits: none, by your choice; the account stops at 15% a day, 35% a week MONDAY A dry-run order through UBI MONDAY Two desks, one stock: refused LATER Telegram pairing (optional) LAST mode = "live", then restart the steps are in docs/going_live.md start, crash, restart the desks' sessions coming back
Orange dots are systemd starting the gateway, a crash, and systemd starting it again; blue dots are the desks' sessions coming back each time. The panel on the right is the going-live checklist that bin/trading-agent preflight reports.

Installing it

The unit file is deploy/trading-agent.service. Link it into your systemd, then enable and start it:

systemctl --user link $PWD/deploy/trading-agent.service
systemctl --user enable --now trading-agent

For a user service to run without anyone logged in, lingering must be on for your user, which it is on this machine:

loginctl show-user $USER -p Linger      # Linger=yes

What it does

Setting in the unit Why
ExecStart=%h/Projects/trading-agent/bin/trading-agent serve The same command you run by hand
Restart=always, RestartSec=10 A crash costs ten seconds
Environment=PATH=%h/.local/bin:... A user service gets a minimal PATH; this keeps your tools reachable
TimeoutStopSec=60 Time for the desks and Claude Code processes to close

On 17 October 2026 the gateway was killed with kill -9. systemd logged status=9/KILL, started a new process eleven seconds later, and the scalper desk still remembered a word it had been given before the crash.

Everyday commands

systemctl --user status trading-agent      # running?
journalctl --user -u trading-agent -f      # the log, live
systemctl --user restart trading-agent     # after changing trading_agent.toml
systemctl --user stop trading-agent        # stops the desks; nothing is closed at the broker

Stopping the service stops the desks thinking, but orders and stops already held by UBI stay in place. To close positions, flatten a desk or fire the kill switch first, as Going live explains.