Running a crypto trading bot from a Raspberry Pi is an efficient and cost-effective way to automate your strategies 24/7. Combined with the powerful CCXT library, which connects to dozens of crypto exchanges, your Pi can serve as a lightweight, always-on trading node.

This guide walks you through setting up a crypto trading bot using Python + CCXT on a Raspberry Pi.


Why Use a Raspberry Pi?

  • 🌱 Low power usage — great for 24/7 uptime
  • 💰 Affordable hardware — even older Pi models work
  • 💻 Runs full Linux — supports Python, cron jobs, logging
  • 🔒 Physical security — run your bot at home with full control

Step 1: Set Up Your Raspberry Pi

  1. Install Raspberry Pi OS (Lite or Desktop)
  2. Connect via SSH or use a monitor + keyboard
  3. Update your packages:
sudo apt update && sudo apt upgrade -y
  1. Install Python and pip if not already installed:
sudo apt install python3 python3-pip -y

Step 2: Install CCXT

CCXT is a Python library that supports trading and market data access from 100+ crypto exchanges.

pip3 install ccxt

OR for javascipt:

npm install ccxt

Verify installation:

python3 -c "import ccxt; print(ccxt.exchanges)"

OR Create a file like check.js:

const ccxt = require('ccxt');

console.log(ccxt.exchanges);

Run it like:

node check.js

Step 3: Write a Simple Trading Script

Create a file named bot.py:

import ccxt  
import time  

api_key = 'YOUR_API_KEY'  
secret = 'YOUR_API_SECRET'  

exchange = ccxt.binance({  
    'apiKey': api_key,  
    'secret': secret,  
    'enableRateLimit': True  
})  

def run():  
    balance = exchange.fetch_balance()  
    print("USDT Balance:", balance['total']['USDT'])  

    ticker = exchange.fetch_ticker('BTC/USDT')  
    price = ticker['last']  
    print("BTC Price:", price)

    # Example: place a market buy (disabled by default)
    # exchange.create_market_buy_order('BTC/USDT', 0.001)

while True:  
    try:  
        run()  
        time.sleep(60)  # Run every minute  
    except Exception as e:  
        print("Error:", str(e))  
        time.sleep(10)

OR create bot.js:

const ccxt = require('ccxt');

const apiKey = 'YOUR_API_KEY';
const secret = 'YOUR_API_SECRET';

const exchange = new ccxt.binance({
    apiKey,
    secret,
    enableRateLimit: true,
});

async function run() {
    try {
        const balance = await exchange.fetchBalance();
        console.log("USDT Balance:", balance.total.USDT);

        const ticker = await exchange.fetchTicker('BTC/USDT');
        console.log("BTC Price:", ticker.last);

        // Example: place a market buy order (disabled by default)
        // await exchange.createMarketBuyOrder('BTC/USDT', 0.001);

    } catch (err) {
        console.error("Error:", err.message);
    }
}

// Run every minute
setInterval(run, 60 * 1000);

Step 4: Secure Your API Keys

  • Never hard-code keys in production
  • Use .env or a config file with restricted permissions
  • Avoid trading with your main account — use sub-accounts if available

Step 5: Keep It Running 24/7

Use screen, tmux, or a background service to keep your bot running:

screen -S tradingbot  
python3 bot.py
# OR
node bot.js

# To detach, press: `Ctrl+A`, then `D`  
# To reattach: `screen -r tradingbot`

Alternatively, use cron or systemd to autostart on boot.


Step 6: Add Logic, Logging, and Alerts

Once your bot is up and polling live data:

  • Add your strategy logic (RSI, MA crossover, etc.)
  • Log to files or a database
  • Send Telegram or email alerts
  • Add risk controls: position sizing, max drawdown, etc.

Final Thoughts

Running your own trading bot on a Raspberry Pi gives you full control, privacy, and flexibility. Combined with CCXT’s broad exchange support and Python’s simplicity, it’s a solid foundation for building a real-world crypto trading system.


Learn More

For a deeper look at the CCXT library and how it integrates with real trading strategies, read our CCXT Framework Overview.

Build it small. Run it smart.