5.2 — VPS Deployment — Running Your Bot on a $5 Server
VPS Deployment — Running Your Bot on a $5 Server
Your laptop is not a production server. When you close the lid, the bot stops. When your ISP has an outage (a daily reality for many Pakistani users), the bot stops. When Windows decides to restart for updates at 3am, the bot stops. Running your Oracle on a Virtual Private Server (VPS) solves all of these problems for less than the cost of a chai at a DHA cafe.
Why a VPS and Not a Local Machine
A VPS is a Linux server running 24/7 in a data center with:
- 99.9%+ uptime (vs. your laptop's ~70% if you're lucky)
- Consistent internet connectivity (data center bandwidth, not residential PTCL)
- Remote access from anywhere — monitor your bot from your phone
- No electricity cost on your side (the server cost includes power)
- Automatic restart on crash via systemd
For a trading bot that needs to run continuously to catch the 15-60 minute laggard windows we've discussed throughout the course, a VPS is not optional — it's the minimum viable infrastructure.
Choosing Your VPS
The Oracle bot is computationally lightweight. It makes API calls and runs AI inference via cloud APIs — it doesn't need a GPU. CPU requirements are minimal. RAM requirement is about 512 MB to 1 GB.
Best VPS options for Pakistani developers:
Hetzner Cloud (Germany): CX11 server at €3.29/month (PKR ~1,030/month). 2 vCPU, 2 GB RAM, 20 GB SSD. Best value for money in Europe. Accepts international Visa/Mastercard. This is the recommended choice for Polymarket Oracle.
DigitalOcean: $6/month basic droplet ($4/month on annual plan). More expensive than Hetzner but excellent documentation and Pakistani developer community support.
Contabo: Aggressive pricing. 4 vCPU, 8 GB RAM, 50 GB SSD at €4.99/month. Overkill for this bot but great if you're running multiple bots on one server.
VPS.net / Hostinger: Available with Pakistani payment methods (local bank transfer or Easypaisa top-up for some providers).
Note: Do NOT run a financial bot on shared hosting (like Namecheap or BlueHost) — they have unpredictable performance and often terminate long-running processes.
Server Setup Script
#!/bin/bash
# Initial VPS setup for Oracle bot (Ubuntu 22.04)
# System updates
apt update && apt upgrade -y
# Python 3.11 (recommended for bot)
apt install -y python3.11 python3.11-venv python3.11-pip
# Essential tools
apt install -y git curl wget screen htop
# Create bot user (don't run as root)
useradd -m -s /bin/bash oracle_bot
su - oracle_bot
# Set up Python environment
python3.11 -m venv ~/oracle_env
source ~/oracle_env/bin/activate
# Clone your bot code
git clone https://github.com/yourusername/polymarket-oracle.git
cd polymarket-oracle
pip install -r requirements.txt
Environment Variables and Secrets Management
Never put API keys on your VPS in plain text. Use environment variables:
# Create .env file (on server, never commit to git)
cat > ~/.oracle_env << 'EOF'
ANTHROPIC_API_KEY=sk-ant-...
GEMINI_API_KEY=AI...
POLYMARKET_PRIVATE_KEY=0x...
WATI_API_KEY=...
DB_PATH=/home/oracle_bot/oracle.db
EOF
chmod 600 ~/.oracle_env # Only owner can read
Load in your Python code:
from dotenv import load_dotenv
load_dotenv(os.path.expanduser("~/.oracle_env"))
Systemd Service for Auto-Restart
# /etc/systemd/system/oracle-bot.service
[Unit]
Description=Polymarket Oracle Trading Bot
After=network.target
[Service]
Type=simple
User=oracle_bot
WorkingDirectory=/home/oracle_bot/polymarket-oracle
EnvironmentFile=/home/oracle_bot/.oracle_env
ExecStart=/home/oracle_bot/oracle_env/bin/python main.py --production
Restart=always
RestartSec=30
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable oracle-bot
systemctl start oracle-bot
systemctl status oracle-bot # Verify it's running
Restart=always means if the bot crashes at 3am, systemd restarts it within 30 seconds. Automatic.
Monitoring Logs Remotely
# View live logs from anywhere
journalctl -u oracle-bot -f
# View last 100 lines
journalctl -u oracle-bot -n 100
# Check if service is running
systemctl status oracle-bot
From your phone (using Termux on Android or iSH on iOS), you can SSH into your VPS and check logs in 30 seconds.
Cost Calculation for Pakistani Traders
Monthly VPS cost on Hetzner CX11:
- Server: €3.29 = PKR ~1,030/month
- Data transfer: Included (20 TB free)
- IPv4: €0.60/month if needed = PKR ~190
Total infrastructure: PKR ~1,220/month
AI API costs (at expected trade volume of 20 trades/month):
- Gemini Flash (triage): ~PKR 300/month
- Claude Sonnet (analysis): ~PKR 2,800/month
- Total AI: ~PKR 3,100/month
Total monthly operating cost: PKR ~4,320/month
Expected monthly profit (from Module 4 model): PKR 47,600-56,000
Net profit after operating costs: PKR 43,000-52,000/month on a PKR 280,000 starting bankroll.
ROI: 15-18% net monthly return on capital — extremely strong by any investment standard.
Practice Lab
-
VPS provisioning: Sign up for Hetzner (hetzner.com) or DigitalOcean. Create a CX11/Basic Droplet running Ubuntu 22.04. SSH in and confirm you can run
python3 --versionsuccessfully. -
Bot deployment: Clone your bot code repository to the VPS. Create the
.oracle_envfile with test credentials. Run the bot manually (python main.py --dry-run) and confirm it starts without errors. -
Systemd configuration: Create the oracle-bot.service file and enable it. Run
systemctl status oracle-botand confirm it shows "active (running)". Test the auto-restart by killing the process manually (kill -9 <pid>) and verifying systemd restarts it within 30 seconds.
Key Takeaways
- A VPS provides 24/7 uptime that a laptop cannot — for a bot exploiting time-sensitive laggard windows, continuous operation is not optional
- Hetzner CX11 at PKR ~1,220/month is the minimum viable production server — total operating costs (VPS + AI APIs) run PKR ~4,320/month
- systemd with Restart=always provides automatic recovery from crashes without manual intervention — essential for a bot running while you sleep
- Never store API keys or private keys in your code — use a chmod 600 .env file on the server and never commit it to version control
🇵🇰 Pakistan Case Study: The Bot That Never Slept (And Paid Rent)
Bilal from Nazimabad, Karachi, was a software developer earning PKR 95,000/month. He set up his Oracle on a Hetzner CX11 in January 2025.
The first week, he was nervous — he kept opening SSH on his phone every few hours to check the bot was running. Every time: systemctl status oracle-bot returned active (running). The systemd service had auto-restarted twice (once for a library import error, once for a Polymarket API timeout) without any action from him.
By week 3, he stopped checking. The bot was reliable.
Month 1 real results:
- Uptime: 99.2% (one 2-hour outage when Hetzner did maintenance)
- Trades executed: 18
- Trades won: 12 (66.7%)
- Gross P&L: $94
- Operating costs: PKR 4,320 (VPS + APIs)
- Net P&L: $94 - PKR 4,320 / 280 = $94 - $15.4 = $78.6 net (PKR 22,008)
The infrastructure decisions that mattered:
-
He set up Telegram alerts via python-telegram-bot — any trade execution, error, or drawdown event sent him a message. He could monitor the entire system from his phone.
-
He ran the bot in
--dry-runmode for 2 full weeks before going live. 23 paper trades, 65% win rate. Only then did he load USDC onto Polymarket. -
He kept API keys in
.oracle_envwithchmod 600and added a.gitignoreentry. His public GitHub repo has zero secrets.
Month 6 status:
- Bankroll grown: $400 → $780 (95% return)
- Monthly operating costs: unchanged at PKR 4,320
- Monthly average net profit: PKR 28,000-35,000
- Bilal's summary: "The VPS pays for itself in the first 2 trades of the month. Everything after that is profit."
📊 VPS Provider Comparison for Pakistani Traders
VPS OPTIONS (2026 prices, CX11-equivalent specs)
Provider | Price/mo | Latency to Polymarket | Pakistani Payment
──────────────────────────────────────────────────────────────
Hetzner (DE) | PKR 1,030 | ~120ms (EU servers) | International card
DigitalOcean | PKR 1,680 | ~80ms (NY server) | International card
Contabo (DE) | PKR 1,400 | ~130ms | International card
Vultr (NJ) | PKR 1,540 | ~70ms (best for US) | International card
Hostinger | PKR 980 | Varies | Some PK methods
RECOMMENDATION: Hetzner CX11 for best value
RECOMMENDATION: DigitalOcean Basic for lowest latency to Polymarket (US-based)
RECOMMENDATION: Hostinger if you need Pakistani payment method
KEY SPECS NEEDED:
CPU: 1-2 vCPU (sufficient for API-heavy bot)
RAM: 1 GB minimum (2 GB recommended)
Storage: 20 GB (database grows ~50 MB/month)
OS: Ubuntu 22.04 LTS (best systemd support)
MONITORING STACK (free):
Bot logs: journalctl -u oracle-bot -f
Alerts: python-telegram-bot (free)
Uptime check: UptimeRobot.com (free, 5-minute checks)
DB backup: rsync to local machine weekly
Lesson Summary
VPS Deployment Quiz
4 questions to test your understanding. Score 60% or higher to pass.