How to Deploy an AI Crypto Trading Bot on Your VPS
Prerequisites
Before you deploy the AI crypto trading bot, get these ready:
- A VPS running Ubuntu 22.04 or 24.04. To run the bot, 2 vCPU / 4 GB RAM is plenty. To train the ML model, more RAM helps - or train it on your laptop and copy the model file over (more below).
- Python 3.12 and MySQL 8 on the server.
- Accounts and API keys (the next section is a full table).
- Basic comfort with SSH and the command line.
The API keys you’ll need
This trips people up, so here’s everything in one place:
| Key | Where to get it | Notes |
|---|---|---|
| Anthropic API key | console.anthropic.com | Enable billing - the free tier won’t sustain continuous calls. |
| Binance API key + secret | Binance testnet: testnet.binance.vision | For live later: spot-only, no withdrawal, IP-restricted. |
| Telegram bot token | @botfather | Create a bot, copy the token. |
| Telegram chat ID | @userinfobot | Your personal chat ID - the bot only talks to you. |
| CoinGecko API key | coingecko.com/api | Free tier is fine. |
Step 1: Set Up the Server
SSH into your VPS and install the essentials:
sudo apt update && sudo apt install -y python3.12 python3.12-venv python3-pip mysql-server libomp-dev
Create the database:
sudo mysql -e "CREATE DATABASE crypto_bot;"
sudo mysql -e "CREATE USER 'crypto_bot'@'localhost' IDENTIFIED BY 'your-strong-password';"
sudo mysql -e "GRANT ALL ON crypto_bot.* TO 'crypto_bot'@'localhost';"
Step 2: Clone and Install the Bot
Clone the repo and run the install script, which sets up the Python virtual environment, installs dependencies, and registers a systemd service that auto-restarts on crash:
git clone https://github.com/dineshstack/crypto_bot.git
cd crypto_bot
bash deploy/install.sh
Step 3: Configure Your API Keys
Copy the example environment file and fill in the keys from the table above. Never commit this file - it’s git-ignored for a reason.
cp .env.example .env
nano .env
ANTHROPIC_API_KEY=sk-ant-...
BINANCE_API_KEY=your_testnet_key
BINANCE_SECRET=your_testnet_secret
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
MYSQL_PASSWORD=your-strong-password
TESTNET=true # keep this true
Step 4: Train the ML Model
The bot ships without a trained model - you train it once on historical data. This is the only CPU/RAM-heavy step:
source venv/bin/activate
python3 -c "import ml_signal, market_data as md; ml_signal.train_model(md.get_exchange())"
💡 Low-RAM VPS? Run this same command on your laptop, then copy the generated ml_models/ folder to the server with scp. The bot’s runtime is light; only training is hungry.
Step 5: Start the Bot and Connect Telegram
sudo systemctl start crypto-bot
sudo systemctl enable crypto-bot # auto-start on reboot
Now open Telegram, find your bot, and send /start. Within a few minutes you’ll get your first analysis message. Useful commands: /status, /analyze, /performance, /history.
Adding the Dashboard (Optional)
The bot is fully functional headless, but the Next.js dashboard is where you see why it does everything. It’s a separate app (plus a Laravel API for auth and role-based access) served behind nginx. The full stack is:
bot → Laravel API (php-fpm) → Next.js dashboard (PM2) → nginx reverse proxy with SSL
It’s more involved than the bot itself, so I’m keeping the deep detail in the repo’s deployment docs rather than bloating this post.
🛠️ Wanted: a one-command docker compose up for the whole stack is on the roadmap. If you’d enjoy building it, it’s the single highest-impact contribution right now - open an issue and let’s talk.
What It Costs to Run
Nobody tells you this, and it’s the reason people abandon self-hosted bots. Realistic monthly cost:
- VPS: ~$5-$12/month for a 2 vCPU / 4 GB box.
- Anthropic API: the 4-hour loop uses cheap Claude Haiku, so the base cost is low; the weekly deep reviews and any research/report generation use pricier models. Budget a small, predictable amount and watch it for the first week.
- Everything else (Binance testnet, CoinGecko free tier, Telegram): free.
The takeaway: cheap to run in testnet, but the Anthropic bill scales with how often you trigger the heavy AI features - so keep an eye on it.
Common Mistakes (Gotchas I Hit)
- The update script doesn’t pull.
deploy/update.shreinstalls and restarts but doesn’tgit pull- rungit pullyourself first. - Laravel defaults to SQLite. If you add the dashboard, its API must use
DB_CONNECTION=mysqlpointed at the bot’s database, or the dashboard shows no data. - Run the migrations and seeder. The dashboard’s roles and admin user come from
php artisan migrate+db:seed- skip it and login breaks. - Exchange minimums. Binance rejects orders under a $5 minimum notional - the bot handles this now, but it’s the classic “why did my trade fail at $0” trap.
- The weekly review is quiet at first. It stays dormant until there are 7 days of trades to review. That’s expected, not a bug.
You’re Live - Now What?
You’ve deployed an AI crypto trading bot that analyses the market every four hours, explains its reasoning, and asks before it trades. Let it run on testnet for a couple of weeks and watch the /performance numbers accumulate before you even think about real money.
🎉 Got it running? I’d love to see it - drop a comment or a screenshot. And if this guide saved you time:
- ⭐ Star the repo on GitHub
- ☕ Support the project on Ko-fi (it covers the API and server costs that keep it running)
Related posts:
- Part 1 - How I Built an AI Crypto Trading Bot with Claude AI
- Part 3 - How to Contribute to the Project
Tags: AI Crypto Trading Bot, VPS Deployment, Self-Hosting, Binance, DevOps
Disclaimer: For educational and research purposes only. Not financial advice, not a solicitation to trade. Cryptocurrency trading carries substantial risk of loss. Always start on testnet and never trade money you can’t afford to lose.
Comments
No comments yet. Start the discussion.