Skip to content
  • Automation
  • Linux VPS
  • Ubuntu 24.04

Run a Python trading bot on a VPS

A Python trading bot runs well on a GhostRDP Linux VPS Basic plan with 2 vCPU and 6 GB RAM in Germany or the Netherlands, from €5.99/mo.

This guide sets up Python in a virtual environment, runs your bot as a systemd service that starts on boot and restarts if it crashes, and shows where to read its logs. The example uses the ccxt library; any Python bot works the same way.

  • Restarts on crashes

    systemd brings the bot back and starts it on boot.

  • Full root access

    Install any library or Python version you need.

  • Keys stay with you

    API keys live in a file only your bot user can read.

Plans for Python trading bot

Most bots that call exchange APIs need very little. Basic is plenty for several bots; pick a bigger plan for backtesting or data-heavy strategies.

  • Linux VPS Basic

    Recommended

    €5.99/mo

    €5.09/mo billed yearly, save €10/year

    • 2 vCPU
    • 6 GB ECC RAM
    • 40 GB NVMe
    • 1 Gbps port
    Order Basic
  • Linux VPS Standard

    €12.99/mo

    €11.04/mo billed yearly, save €23/year

    • 4 vCPU
    • 8 GB ECC RAM
    • 70 GB NVMe
    • 1 Gbps port
    Order Standard
  • Linux VPS Pro

    €25.99/mo

    €22.09/mo billed yearly, save €46/year

    • 6 vCPU
    • 12 GB ECC RAM
    • 90 GB NVMe
    • 1 Gbps port
    Order Pro

What you need

  • Operating system
    Linux VPS with Ubuntu 24.04 (Debian 12 works the same way)
  • Minimum resources
    1 vCPU and 1 GB RAM for a typical API bot
  • Your bot
    Your Python code and your exchange or broker API keys

Official site: python.org

How to install Python trading bot

Written for Ubuntu 24.04 from the official instructions. Run the commands as root and replace YOUR_SERVER_IP with your server's address.

  1. 1

    Connect to your server over SSH

    Use the IP address and root password from your welcome email (the server page has a Copy SSH command button). Windows 10 and 11, macOS and Linux all include an SSH client in the terminal.

    Shell
    ssh root@YOUR_SERVER_IP
  2. 2

    Update the system

    Install the latest security updates before you add anything else.

    Shell
    apt update && apt -y upgrade
  3. 3

    Install Python tools and create a bot user

    Ubuntu 24.04 ships Python 3.12. Run the bot as its own user, not as root.

    Shell
    apt install -y python3-venv python3-pip
    useradd -m -s /bin/bash bot
    sudo -u bot mkdir -p /home/bot/app
  4. 4

    Create a virtual environment and install your libraries

    Install what your bot needs into the virtual environment. The example installs ccxt.

    Shell
    sudo -u bot python3 -m venv /home/bot/venv
    sudo -u bot /home/bot/venv/bin/pip install ccxt
  5. 5

    Upload your bot

    Copy your code from your PC with scp (run this on your PC), then give the files to the bot user on the server. To try the setup first, the second block writes a small example bot that prints the BTC/EUR price every minute.

    Shell
    # on your PC
    scp -r ./mybot/* root@YOUR_SERVER_IP:/home/bot/app/
    
    # on the server
    chown -R bot:bot /home/bot/app
  6. 6

    Or start with an example bot

    A public price feed, no API keys needed.

    Shell
    cat > /home/bot/app/bot.py <<'EOF'
    import time
    import ccxt
    
    exchange = ccxt.kraken()
    while True:
        ticker = exchange.fetch_ticker("BTC/EUR")
        print("BTC/EUR", ticker["last"], flush=True)
        time.sleep(60)
    EOF
    chown bot:bot /home/bot/app/bot.py
  7. 7

    Run it as a service

    systemd starts the bot on boot and restarts it 5 seconds after a crash. Change bot.py if your entry file has another name.

    Shell
    cat > /etc/systemd/system/tradingbot.service <<'EOF'
    [Unit]
    Description=Trading bot
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    User=bot
    WorkingDirectory=/home/bot/app
    ExecStart=/home/bot/venv/bin/python /home/bot/app/bot.py
    Restart=always
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl daemon-reload
    systemctl enable --now tradingbot
  8. 8

    Watch the logs

    Press Ctrl+C to stop watching; the bot keeps running.

    Shell
    systemctl status tradingbot
    journalctl -u tradingbot -f

After installing

  • API keys
    Keep keys out of your code: put them in /home/bot/app/.env (chmod 600) and add EnvironmentFile=/home/bot/app/.env under [Service].
  • Updating the bot
    Upload the new code, then run systemctl restart tradingbot.
  • Open ports
    None. A bot that calls exchange APIs only makes outgoing connections.

Python trading bot questions

Which plan do I need for a Python trading bot?

The Basic Linux VPS runs several API bots. Choose a bigger plan if you backtest on the server or keep large market data in memory.

Will my bot restart if it crashes?

Yes. The systemd service on this page restarts it 5 seconds after it exits and starts it again when the server reboots.

Can exchanges block your IP addresses?

Each server has its own IPv4 address in Germany or the Netherlands. Check that your exchange serves customers from your country and allows API access from those locations.

Can I run several bots on one server?

Yes. Give each bot its own folder and its own service file (for example tradingbot2.service).

Stuck on a step? Our team answers on live chat and in tickets.

More on GhostRDP

Run Python trading bot on your own server.

Online in minutes. Pay with crypto, no ID needed.