DEV Community

Dinesh Wijethunga
Dinesh Wijethunga

Posted on • Originally published at dineshstack.com

How to Deploy an AI Crypto Trading Bot on Your VPS

How to Deploy an AI Crypto Trading Bot on Your VPS

In this tutorial you’ll deploy an AI crypto trading bot to your own VPS — the open-source Claude-powered bot from Part 1 — and have it analysing BTC and ETH on Binance testnet, messaging you on Telegram, in about 20–30 minutes. I’ll give you the exact steps, a complete list of the API keys you need, an honest running-cost breakdown, and every gotcha I hit so you don’t lose an evening to them.

⚠️ Start on testnet. Everything below uses Binance testnet (fake money). Never point live keys at a bot you haven’t watched run for weeks. This is educational content, not financial advice.

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.sh reinstalls and restarts but doesn’t git pull — run git pull yourself first.
  • Laravel defaults to SQLite. If you add the dashboard, its API must use DB_CONNECTION=mysql pointed 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)

AI crypto trading bot deployed on a VPS sending an analysis message on Telegram
First contact: the deployed bot’s analysis message arriving in Telegram.

Related posts

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.

Top comments (0)