Trading Bot Cloud Server Setup
Writing a trading bot and running it reliably in production are two different tasks. Most bots crash not because of trading logic errors, but because of infrastructure issues: connection drops, OOM kills, no monitoring, no restart after crash. This page covers the infrastructure part.
Minimal viable stack
For one bot on Python/Node.js:
VPS (DigitalOcean/Hetzner/Vultr) → systemd service → bot process → exchange API
↓
Telegram alert bot (status alerts)
Why not Docker for one bot? Extra complexity without benefit. systemd is simpler, more reliable for single-process, and works on any Linux VPS out of the box.
Server selection
| Parameter | Minimum | Recommended |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU |
| RAM | 1GB | 2–4GB |
| Disk | 20GB SSD | 40GB SSD |
| Network | Any | Close to exchange (for latency) |
| Provider | DigitalOcean, Hetzner | Vultr Tokyo/Singapore for Binance |
For bots where latency matters (scalping, arbitrage) — server in same region as exchange. Binance mainnet — AWS Tokyo or Singapore. FTX was in AWS Virginia. Latency between Europe and Asia — 200–300ms, death for HFT strategies.
systemd unit file
# /etc/systemd/system/trading-bot.service
[Unit]
Description=Trading Bot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=bot
WorkingDirectory=/home/bot/trading-bot
EnvironmentFile=/home/bot/trading-bot/.env
ExecStart=/home/bot/.venv/bin/python main.py
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
# Resource limits
MemoryMax=512M
CPUQuota=80%
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable trading-bot
systemctl start trading-bot
journalctl -u trading-bot -f # real-time logs
Restart=on-failure + RestartSec=10 — bot auto-restarts after crash with 10-second pause. Important: on-failure, not always — bot should not restart on normal exit (e.g., manual stop).
Environment variables and secrets
API keys — only via environment variables, never in code:
# /home/bot/trading-bot/.env (permissions 600, owner bot)
BINANCE_API_KEY=xxx
BINANCE_SECRET=yyy
TELEGRAM_BOT_TOKEN=zzz
TELEGRAM_CHAT_ID=123456
chmod 600 /home/bot/trading-bot/.env
chown bot:bot /home/bot/trading-bot/.env
Monitoring and Telegram alerts
Minimal monitoring for bot:
import httpx, asyncio
TELEGRAM_URL = f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage"
async def send_alert(message: str, level: str = "INFO"):
prefix = {"INFO": "ℹ️", "WARN": "⚠️", "ERROR": "🚨"}.get(level, "")
await httpx.AsyncClient().post(TELEGRAM_URL, json={
"chat_id": TELEGRAM_CHAT_ID,
"text": f"{prefix} *{level}*\n{message}",
"parse_mode": "Markdown"
})
# Alert on start
await send_alert("Bot started", "INFO")
# Alert on order
await send_alert(f"Order placed: BUY {qty} BTC @ {price}", "INFO")
# Heartbeat — bot alive
async def heartbeat():
while True:
await asyncio.sleep(3600) # once per hour
await send_alert(f"Heartbeat: balance={await get_balance()}", "INFO")
If heartbeat stops coming — bot crashed. Can also set up UptimeRobot or BetterStack for external process monitoring.
Bot update without downtime
# Deploy new version
cd /home/bot/trading-bot
git pull origin main
/home/bot/.venv/bin/pip install -r requirements.txt
# Graceful restart — systemd waits for current iteration to finish
systemctl restart trading-bot
Setting up infrastructure for one bot from zero: 2–4 hours. For multiple bots with Docker Compose and centralized logging — 1–2 days.







