Get the FREE Ultimate OpenClaw Setup Guide →

setup

Scanned
npx machina-cli add skill marketcalls/vectorbt-backtesting-skills/setup --openclaw
Files (1)
SKILL.md
5.9 KB

Set up the complete Python backtesting environment for VectorBT + OpenAlgo.

Arguments

  • $0 = Python version (optional, default: python3). Examples: python3.12, python3.13

Steps

Step 1: Detect Operating System

Run the following to detect the OS:

uname -s 2>/dev/null || echo "Windows"

Map the result:

  • Darwin = macOS
  • Linux = Linux
  • MINGW* or CYGWIN* or Windows = Windows

Print the detected OS to the user.

Step 2: Create Virtual Environment

Create a Python virtual environment in the current working directory:

macOS / Linux:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip

Windows:

python -m venv venv
venv\Scripts\activate
pip install --upgrade pip

If the user specified a Python version argument, use that instead of python3:

$PYTHON_VERSION -m venv venv

Step 3: Install TA-Lib System Dependency

TA-Lib requires a C library installed at the OS level BEFORE pip install ta-lib.

macOS:

brew install ta-lib

Linux (Debian/Ubuntu):

sudo apt-get update
sudo apt-get install -y build-essential wget
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
cd ..
rm -rf ta-lib ta-lib-0.4.0-src.tar.gz

Linux (RHEL/CentOS/Fedora):

sudo yum groupinstall -y "Development Tools"
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure --prefix=/usr
make
sudo make install
cd ..
rm -rf ta-lib ta-lib-0.4.0-src.tar.gz

Windows:

pip install ta-lib

If that fails, download the appropriate .whl file from https://github.com/cgohlke/talib-build/releases and install with:

pip install TA_Lib-0.4.32-cp312-cp312-win_amd64.whl

Step 4: Install Python Packages

Install all required packages (latest versions):

pip install openalgo vectorbt plotly anywidget nbformat ta-lib pandas numpy yfinance python-dotenv tqdm scipy numba nbformat ipywidgets quantstats ccxt

Step 5: Create Backtesting Folder

Create only the top-level backtesting directory. Strategy subfolders are created on-demand when a backtest script is generated (by the /backtest skill).

mkdir -p backtesting

Do NOT pre-create strategy subfolders.

Step 6: Configure .env File

6a. Check if .env.sample exists at the project root. If it does, use it as a template.

6b. Ask the user which markets they will be backtesting using AskUserQuestion:

  • Indian Markets (OpenAlgo) — requires OpenAlgo API key
  • US Markets (yfinance) — no API key needed
  • Crypto Markets (CCXT) — optional API key for private data

6c. If the user selected Indian Markets, ask for their OpenAlgo API key:

  • Ask: "Enter your OpenAlgo API key (from the OpenAlgo dashboard):"
  • If the user provides a key, store it in .env
  • If the user skips, write a placeholder

6d. If the user selected Crypto Markets, ask if they want to configure exchange API keys:

  • Ask: "Do you have exchange API keys for authenticated data? (Optional — public OHLCV data works without keys)"
  • If yes, ask for API key and secret key, store in .env
  • If no, leave them blank in .env

6e. Write the .env file in the project root directory. Use this template, filling in any keys the user provided:

# Indian Markets (OpenAlgo)
OPENALGO_API_KEY={user_provided_key or "your_openalgo_api_key_here"}
OPENALGO_HOST=http://127.0.0.1:5000

# Crypto Markets (CCXT) - Optional
CRYPTO_API_KEY={user_provided_key or ""}
CRYPTO_SECRET_KEY={user_provided_key or ""}

6f. Add .env to .gitignore if it exists (never commit secrets):

Scripts use find_dotenv() to automatically walk up and find the single root .env, so no copies are needed in subdirectories.

grep -qxF '.env' .gitignore 2>/dev/null || echo '.env' >> .gitignore

Step 7: Verify Installation

Run a quick verification:

python -c "
import vectorbt as vbt
import openalgo
import plotly
import talib
import anywidget
import nbformat
import quantstats as qs
from dotenv import load_dotenv
print('All packages installed successfully')
print(f'  vectorbt: {vbt.__version__}')
print(f'  plotly: {plotly.__version__}')
print(f'  nbformat: {nbformat.__version__}')
print(f'  quantstats: {qs.__version__}')
print(f'  TA-Lib: available')
print(f'  python-dotenv: available')
"

If TA-Lib import fails, inform the user that the C library needs to be installed first (see Step 3).

Step 8: Print Summary

Print a summary showing:

  • Detected OS
  • Python version used
  • Virtual environment path
  • Installed packages and versions
  • Backtesting folder created (strategy subfolders created on-demand by /backtest)
  • .env file status (configured with keys / placeholder) — single file at project root
  • Reminder: "Run cp .env.sample .env and fill in API keys if you skipped configuration"

Important Notes

  • Never install packages globally — always use the virtual environment
  • TA-Lib C library installation requires admin/sudo privileges on Linux
  • On macOS, Homebrew must be installed for brew install ta-lib
  • If the user already has a virtual environment, ask before creating a new one
  • The backtesting/ folder is where all generated backtest scripts will be saved
  • NEVER commit .env files — they contain secrets. Always use .gitignore.
  • If the user provides an API key during setup, write it directly to .env — do not ask them to edit the file manually
  • python-dotenv is included in the pip install and must be used by all scripts to load .env

Source

git clone https://github.com/marketcalls/vectorbt-backtesting-skills/blob/master/.claude/skills/setup/SKILL.mdView on GitHub

Overview

This skill bootstraps a full Python backtesting environment for VectorBT and OpenAlgo. It detects the OS, creates a virtual environment, installs core dependencies (openalgo, ta-lib, vectorbt, plotly), and establishes the backtesting directory structure to accelerate a first backtest.

How This Skill Works

The process detects the operating system, creates a tailored virtual environment (honoring an optional Python version argument), installs required Python packages, handles TA-Lib system dependencies, and initializes a top-level backtesting directory. It then guides env configuration via a .env template and prepares market sources through user prompts.

When to Use It

  • Starting a new backtesting project with VectorBT and OpenAlgo
  • Setting up on macOS/Linux where TA-Lib requires system libraries
  • Setting up on Windows with a prebuilt TA-Lib wheel if needed
  • Initializing a project with a specific Python version as requested by the project
  • Bootstrapping a project before writing backtests, including initial market configuration

Quick Start

  1. Step 1: Detect OS and confirm environment details are correct
  2. Step 2: Create a virtual environment using the provided Python version or default to python3
  3. Step 3: Install dependencies (openalgo, vectorbt, plotly, ta-lib, and others) and create the backtesting folder

Best Practices

  • Verify OS detection output before proceeding to venv creation
  • If a Python version is specified, honor it; otherwise default to python3
  • Install the TA-Lib system dependency prior to pip installing ta-lib
  • Install all core packages in a single step to minimize environment drift
  • Create only the top-level 'backtesting' directory; avoid pre-creating strategy subfolders

Example Use Cases

  • macOS setup for a VectorBT + OpenAlgo project using brew-ta-lib and python3.12
  • Windows setup with a provided Python version and a prebuilt TA-Lib wheel
  • Ubuntu-based setup performing TA-Lib build steps before pip installs
  • Bootstrapper creating the backtesting directory and configuring .env prompts
  • Crypto market backtest setup with optional CCXT API keys configured in .env

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers