#!/usr/bin/env bash # Sets up a Python virtual environment and installs dependencies. # Run once after cloning: bash setup.sh set -euo pipefail MIN_PYTHON_MINOR=8 # Prefer python3.10+ if available, fall back to whatever python3 is present if command -v python3.12 &>/dev/null; then PYTHON=python3.12 elif command -v python3.11 &>/dev/null; then PYTHON=python3.11 elif command -v python3.10 &>/dev/null; then PYTHON=python3.10 elif command -v python3.9 &>/dev/null; then PYTHON=python3.9 elif command -v python3.8 &>/dev/null; then PYTHON=python3.8 elif command -v python3 &>/dev/null; then PYTHON=python3 else echo "ERROR: python3 not found. Install it with: sudo apt install python3 python3-venv python3-pip" exit 1 fi PYVER=$($PYTHON -c "import sys; print(sys.version_info.minor)") if [ "$PYVER" -lt "$MIN_PYTHON_MINOR" ]; then echo "ERROR: Python 3.$MIN_PYTHON_MINOR or newer required (found 3.$PYVER)" exit 1 fi echo "Using $($PYTHON --version)" # Create virtual environment if [ ! -d venv ]; then $PYTHON -m venv venv echo "Created virtual environment in ./venv" else echo "Virtual environment already exists, skipping creation" fi # Install dependencies ./venv/bin/pip install --upgrade pip -q ./venv/bin/pip install -r requirements.txt -q echo "Dependencies installed" # Create .env if missing if [ ! -f .env ]; then cp .env.example .env chmod 600 .env echo "" echo "Created .env — edit it now and add your Kraken API keys:" echo " nano .env" else echo ".env already exists" fi echo "" echo "Setup complete. To run the bot in paper trading mode:" echo " ./venv/bin/python bot.py" echo "" echo "To go live:" echo " ./venv/bin/python bot.py --live"