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.
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:
For a user service to run without anyone logged in, lingering must be on for your user, which it is on this machine:
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.