AITradingBot logo

Building an AI Trading Bot — Part 2: Setup Your VPS and Run an AI Bot in 15 Minutes

ByhovinngGitHub|X

In Part 1, we followed one AI-powered trade through the full pipeline: VPS → API → Data → Model → Execution → Exchange. You learned what each piece does. You wrote down your trading strategy.

Today we stop talking and start doing. You’ll have a working AI trading bot running on a server in about 15 minutes. It grabs live Bitcoin prices, runs a simulated AI prediction, and prints the result — laying the groundwork for the real model in Part 5.

No shortcuts, no “trust me.” Every command you’ll type, I’ll explain why.

What you need: A credit card (VPS costs $5/month), a computer, and 15 minutes. That’s it. If you’ve never touched a terminal before — good. You’re about to learn the one tool every trader-turned-dev uses daily.

Step 1: Get a VPS

Your bot needs a home that never sleeps. Not your laptop. Not your phone. A VPS — a Virtual Private Server — is a tiny slice of a computer in a data center. You rent it, it runs 24/7, and it costs about the same as one lunch.

Recommended: DigitalOcean Droplet

I use DigitalOcean for this series because:

  • One-click Ubuntu setup — no configuration decisions to make
  • $5/month gets you 1 GB RAM, 25 GB SSD, 1 TB transfer. Enough to run this bot and a few more.
  • Predictable billing. No surprise charges if traffic spikes.

Other options that work: Linode ($5/mo Nanode), Vultr ($6/mo), Hetzner ($4.50/mo). The steps below work on any of them — pick whichever you prefer.

Go to digitalocean.com, create an account, and add your payment method. Then:

  1. Click the green Create button → Droplets
  2. Region: pick the one closest to you (Singapore or Bangalore if you’re in Southeast Asia; San Francisco for West Coast; New York for East Coast; Frankfurt for Europe)
  3. Image: Ubuntu 24.04 LTS (the default)
  4. Size: Basic → $5/month (1 GB RAM)
  5. Authentication: Choose Password. Type a strong password — save it somewhere. You’ll need it in 60 seconds.
  6. Hostname: ai-trading-bot (or whatever you want)
  7. Click Create Droplet

DigitalOcean takes about 45 seconds to spin up your server. You’ll see an IP address like 167.99.123.45 — that’s your bot’s new home. Copy it.

Step 2: Connect to Your VPS

Open your terminal:

  • Mac: Press Cmd+Space, type “Terminal”, hit Enter
  • Windows: Press Win+R, type cmd, hit Enter

Type this — replacing 167.99.123.45 with your Droplet’s IP:

ssh root@167.99.123.45

First time, you’ll see:

The authenticity of host '167.99.123.45' can't be established.
Are you sure you want to continue connecting? (yes/no)

Type yes. This is normal — your computer hasn’t talked to this server before.

Then enter the password you set in Step 1. You won’t see anything typing — no dots, no asterisks. That’s normal. Hit Enter.

You’re now logged into your VPS. The prompt should look like:

root@ai-trading-bot:~#

Everything from here runs on the server. Your laptop is just the remote control.

Step 3: Install Python

Ubuntu 24.04 ships with Python 3.12 already. Check:

python3 --version

You should see Python 3.12.x. If it says “command not found” (unlikely but possible on older images):

apt update && apt install -y python3 python3-pip

What each flag means

  • apt update — refreshes the package list. Like refreshing a webpage to see the latest prices.
  • apt install -y python3 python3-pip — installs Python and pip (Python’s package manager). -y means “yes to all prompts” — your bot doesn’t have hands to type y.

No complicated setup. No virtual environments. No Docker. Keep it simple while you learn — add complexity when you need it.

Step 4: Clone Your AI Trading Bot

Your bot’s code lives on GitHub. This command downloads it to your server:

git clone https://github.com/hovinng/ai-trading-bot.git

If git isn’t installed, Ubuntu will prompt you to install it. Type apt install git and run the clone command again.

Move into the bot’s directory:

cd ai-trading-bot
ls

You should see:

bot.py  README.md  requirements.txt

Three files. That’s your entire bot. Take a look:

cat bot.py

Don’t worry about understanding every line — Part 3 walks through the code in detail. For now, notice two things:

  1. It imports ccxt — a library that talks to crypto exchanges. Binance, Bybit, Kraken, all of them.
  2. There’s a predict() function returning placeholder predictions. In Part 5, this becomes a real ML model.

Step 5: Install Dependencies

pip install -r requirements.txt --break-system-packages

Breakdown

  • pip install — Python’s package installer. Think of it as an app store for code libraries.
  • -r requirements.txt — read the list of packages from this file. Currently just one: ccxt.
  • --break-system-packages — Ubuntu’s safety lock that says “don’t let pip mess with system Python packages.” We’re skipping it because the bot needs ccxt and Ubuntu’s package manager doesn’t have the latest version. This is safe on a dedicated VPS running only your bot.

Install takes about 30 seconds. You’ll see a bunch of download progress bars, then a “Successfully installed” message.

Step 6: Run Your Bot

Moment of truth:

python3 bot.py

You should see:

==================================================
  AI Trading Bot — BTC/USDT
  Build Your Own AI Trading Bot (Part 2)
==================================================

Fetching BTC/USDT every 60s...
Press Ctrl+C to stop.

  ▼ BTC/USDT: $64,110.01  |  confidence: 65%  |  prediction: DOWN

That’s a live Bitcoin price pulled from Binance’s API. The confidence score and prediction direction are placeholder — Part 5 swaps them for a real model — but the data pipeline is real. Your bot is fetching actual market data from a real exchange.

Every 60 seconds, a new line appears:

  ▲ BTC/USDT: $64,115.30  |  confidence: 65%  |  prediction: UP
  ▼ BTC/USDT: $64,108.75  |  confidence: 65%  |  prediction: DOWN

What Just Happened?

Your bot:

  1. Connected to Binance’s public API (no account needed — market data is free)
  2. Fetched the current BTC/USDT price
  3. Ran the predict() function — placeholder for now, real model coming
  4. Printed the result
  5. Waited 60 seconds, then did it again

No browser. No TradingView tab. Just code asking a server for data, getting a response, and printing it. This loop is the heartbeat of every trading bot ever built — from hobbyist scripts to multi-million-dollar hedge fund systems.

Press Ctrl+C to stop it when you’re done watching.

Step 7: Keep It Running 24/7

Right now, closing your terminal kills the bot. That’s fine for testing, but you didn’t rent a VPS just to have your bot die when your WiFi drops.

The simplest fix: screen. It’s a tool that keeps programs running after you disconnect.

apt install -y screen
screen -S bot

-S bot gives the session a name. You’re now inside a new screen session. Start the bot again:

cd ~/ai-trading-bot
python3 bot.py

Now detach: press Ctrl+A, then D. You’re back at your normal terminal, but the bot is still running in the background.

To reattach later (check on your bot):

screen -r bot

To kill it: reattach (screen -r bot), then Ctrl+C.

Alternative: tmux does the same thing and has more features, but screen is simpler for a first bot. Once you’re comfortable with the basics, switch to tmux if you need multiple windows or split panes.

Verify It Survived

Close your terminal completely. Open a new one, SSH back in, and run:

screen -r bot

Your bot’s still there, still printing predictions. It ran the whole time you were disconnected.

What You Just Built

Seven steps, 15 minutes, one working AI trading bot:

Your Laptop (SSH) → VPS (screen session) → bot.py → Binance API → BTC price
                                                         ↓
                                              predict() — placeholder
                                                         ↓
                                              Prints: direction + confidence

You now have:

  • A $5/month server running 24/7 in a data center
  • Python + dependencies installed
  • A bot that pulls live market data from Binance
  • A screen session keeping it alive after you disconnect

This is the exact foundation the model in Part 5 will sit on. The data pipeline is real. The code is yours. The server is yours.

Troubleshooting

“pip: command not found”

apt install -y python3-pip

"git: command not found"

apt install -y git

"error: externally-managed-environment" Ubuntu 24.04 blocks pip install to protect system Python. Add --break-system-packages to your pip command:

pip install -r requirements.txt --break-system-packages

This is safe on a dedicated VPS. See Step 5 for the full explanation.

"ccxt.errors.NetworkError" Your VPS can’t reach Binance. Check your internet connection: ping binance.com. If that works and ccxt still fails, Binance might be blocked in your VPS region. Switch to a different region or edit bot.py — change ccxt.binance() to ccxt.bybit() on the line that creates the exchange object. Bybit also offers free market data, no account needed.

“Permission denied” when SSH You’re using the wrong password. Go back to DigitalOcean, click your Droplet, and reset the root password under “Access.” It sends a temporary one to your email.

Forgot your Droplet IP DigitalOcean dashboard → Droplets → your Droplet name. The IP is right there.

Your First Action

Before Part 3 drops, do two things:

  1. Open bot.py and read it. Doesn’t matter if you understand everything — just get familiar with the file. Part 3 walks through line by line.
  2. Break something. Change INTERVAL from 60 to 10. Run the bot. See what happens. Then change it back. The fastest way to learn a system is to poke it and watch it react.

Missed Part 1? Start here: Building an AI Trading Bot — Part 1: How One Trade Works — the mental model behind everything you just built.

Ready for more? Part 3 walks you through every line of bot.py so you can read, understand, and modify your bot’s code.