Running a trading bot from your laptop is fine for testing. Running it for real means putting it on a server that doesn't shut down when you close the lid, doesn't lose connection when your WiFi blips, and doesn't stop at 3am because macOS decided to install updates.
This article walks through choosing a VPS, setting up basic security, running your bot as a systemd service, and the operational practices that make the difference between a bot that runs reliably and one that mysteriously stops every few weeks.
For most retail trading bots, you want:
Three providers cover 95% of use cases:
**Hetzner** — best value. \$4-6/month for a CX11 instance (2 GB RAM, 1 vCPU). German company, datacenters in Germany and Finland. Latency to LMEX endpoints in Hong Kong is 200-300ms. Fine for non-HFT strategies. Excellent reputation for reliability and customer service.
**DigitalOcean** — most retail-friendly. \$6/month basic droplet. Datacenters globally including Singapore (lowest latency to LMEX). Clean dashboard, good docs, decent for beginners. Slightly more expensive than Hetzner.
**AWS Lightsail** — most flexible. \$5-10/month. Integrates with broader AWS if you ever need it. Singapore region for low LMEX latency. More complex than DO but worth knowing if you might scale.
For latency-sensitive strategies (market making, arbitrage), pick a provider with a Singapore or Hong Kong region. For trend following or DCA, any region works fine.
Skip VPS providers you've never heard of. Cheap is not worth uptime issues that lose money.
Once you have an Ubuntu 24.04 server (the default for all three providers):
That's the bare minimum security setup. Disable root SSH, use keys only, enable firewall.
For a trading bot, you typically don't need any incoming ports beyond SSH. The bot makes outgoing connections to the exchange; nothing connects to it.
Reconnect as the new user:
Clone or copy your bot code into this directory. Create a `.env` file for credentials:
Lock it down: `chmod 600 .env`
The right way to run a long-running bot on Linux is as a systemd service. This handles:
Create `/etc/systemd/system/lmex-bot.service`:
Enable and start it:
The bot now runs in the background, restarts automatically if it crashes, and starts on reboot.
Without log rotation, your bot's log file grows indefinitely and eventually fills the disk. Create `/etc/logrotate.d/lmex-bot`:
This rotates logs daily, keeps 14 days of compressed history, doesn't error if the log is missing.
A bot that runs silently isn't useful. You need to know when it stops or starts behaving weirdly.
Simplest approach: a heartbeat script that runs every 5 minutes via cron and sends an alert if the bot isn't running:
Cron entry: `*/5 * * * * /home/tradingbot/scripts/check-bot.py`
For more sophisticated monitoring, look at Healthchecks.io (free for one bot) or build a Telegram dashboard that reports P&L, positions, and recent trades every few hours.
A few practices that distinguish bots that survive from those that don't:
**SSH key rotation.** Rotate your SSH key annually. If you ever shared the server (paired programming, contractor access), rotate immediately.
**Regular updates.** Set up unattended upgrades for security patches: `sudo apt install unattended-upgrades`. Manually update major versions during quiet trading periods (weekends, holidays).
**Backups.** Back up your bot's state (open orders, recent trades, config) to a separate location at least weekly. Don't rely on the VPS being recoverable.
**Test changes locally first.** Changing code on the live server is asking for trouble. Develop locally, test in a paper environment, then deploy.
**Monitor what matters.** Bot uptime is one metric. Also track: deviation from expected position size, drawdown vs limit, fill rate vs expected. Anomalies in these often indicate the bot is technically running but actually misbehaving.
For a 1-bot retail setup:
Total: ~\$70-100/year. Less than a single bad trade.
Q: Can I run this from a Raspberry Pi at home instead?
Technically yes, but ISP outages, power outages, and home internet flakiness mean meaningfully less uptime. For a serious bot, a VPS is worth the \$5/month.
Q: What if I want to deploy multiple bots?
Same server is fine if they're small. Run each as its own systemd service. For 5+ bots or anything resource-intensive, scale up to a larger instance or run multiple smaller ones.
Q: Do I need a static IP?
VPS providers give you a static IP by default. If your exchange API key is IP-restricted (recommended), use this IP.
Q: What about Docker?
Docker is overkill for a single bot. The systemd setup above is simpler and more reliable. Docker becomes worthwhile when running multiple bots with different dependencies or when you need consistent deployment across environments.