setup by marketcalls/vectorbt-backtesting-skills
npx skills add https://github.com/marketcalls/vectorbt-backtesting-skills --skill setup为 VectorBT + OpenAlgo 设置完整的 Python 回测环境。
$0 = Python 版本(可选,默认:python3)。例如:python3.12,python3.13运行以下命令来检测操作系统:
uname -s 2>/dev/null || echo "Windows"
映射结果:
Darwin = macOSLinux = LinuxMINGW* 或 或 = Windows广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
CYGWIN*Windows向用户打印检测到的操作系统。
在当前工作目录中创建一个 Python 虚拟环境:
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
如果用户指定了 Python 版本参数,则使用该版本而不是 python3:
$PYTHON_VERSION -m venv venv
TA-Lib 需要在 pip install ta-lib 之前在操作系统级别安装一个 C 库。
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
如果失败,请从 https://github.com/cgohlke/talib-build/releases 下载相应的 .whl 文件并使用以下命令安装:
pip install TA_Lib-0.4.32-cp312-cp312-win_amd64.whl
安装所有必需的包(最新版本):
pip install openalgo vectorbt plotly anywidget nbformat ta-lib pandas numpy yfinance python-dotenv tqdm scipy numba nbformat ipywidgets quantstats ccxt duckdb psutil
仅创建顶层的回测目录。策略子文件夹是在生成回测脚本时(通过 /backtest 技能)按需创建的。
mkdir -p backtesting
请不要预先创建策略子文件夹。
6a. 检查项目根目录下是否存在 .env.sample。 如果存在,则将其用作模板。
6b. 使用 AskUserQuestion 询问用户将回测哪些市场:
6c. 如果用户选择了印度市场,询问他们的 OpenAlgo API 密钥:
.env 中6d. 如果用户选择了印度市场 (DuckDB),询问 DuckDB 数据库路径:
symbol, exchange, interval, timestamp 列的 market_data 表,则为 OpenAlgo Historify 格式(存储为 HISTORIFY_DB_PATH)。否则存储为 DUCKDB_PATH。6e. 如果用户选择了加密货币市场,询问他们是否要配置交易所 API 密钥:
.env 中.env 中留空6f. 在项目根目录下写入 .env 文件。 使用此模板,填写用户提供的任何密钥/路径:
# Indian Markets (OpenAlgo)
OPENALGO_API_KEY={user_provided_key or "your_openalgo_api_key_here"}
OPENALGO_HOST=http://127.0.0.1:5000
# DuckDB Data Sources (direct database loading - fastest)
# Custom DuckDB (user-created with OHLCV table)
DUCKDB_PATH={user_provided_path or ""}
# OpenAlgo Historify DuckDB (market_data table with epoch timestamps)
HISTORIFY_DB_PATH={user_provided_path or ""}
# Crypto Markets (CCXT) - Optional
CRYPTO_API_KEY={user_provided_key or ""}
CRYPTO_SECRET_KEY={user_provided_key or ""}
6g. 将 .env 添加到 .gitignore(如果存在的话)(切勿提交机密信息):
脚本使用 find_dotenv() 自动向上查找单个根目录下的 .env,因此子目录中不需要副本。
grep -qxF '.env' .gitignore 2>/dev/null || echo '.env' >> .gitignore
运行快速验证:
python -c "
import vectorbt as vbt
import openalgo
import plotly
import talib
import duckdb
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' duckdb: {duckdb.__version__}')
print(f' nbformat: {nbformat.__version__}')
print(f' quantstats: {qs.__version__}')
print(f' TA-Lib: available')
print(f' python-dotenv: available')
"
如果 TA-Lib 导入失败,请通知用户需要先安装 C 库(参见步骤 3)。
打印摘要,显示:
/backtest 按需创建).env 文件状态(已配置密钥 / 占位符)— 项目根目录下的单个文件cp .env.sample .env 并填写 API 密钥"brew install ta-libbacktesting/ 文件夹是所有生成的回测脚本的保存位置.env 文件 — 它们包含机密信息。始终使用 .gitignore。.env — 不要要求用户手动编辑文件python-dotenv 已包含在 pip 安装中,所有脚本必须使用它来加载 .env每周安装次数
366
仓库
GitHub 星标数
104
首次出现
2026年2月27日
安全审计
安装于
codex358
opencode358
cursor351
gemini-cli350
github-copilot350
amp349
Set up the complete Python backtesting environment for VectorBT + OpenAlgo.
$0 = Python version (optional, default: python3). Examples: python3.12, python3.13Run the following to detect the OS:
uname -s 2>/dev/null || echo "Windows"
Map the result:
Darwin = macOSLinux = LinuxMINGW* or CYGWIN* or Windows = WindowsPrint the detected OS to the user.
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
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
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 duckdb psutil
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.
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:
6c. If the user selected Indian Markets , ask for their OpenAlgo API key:
.env6d. If the user selected Indian Markets (DuckDB) , ask for the DuckDB database path:
market_data table with symbol, exchange, interval, timestamp columns, it is OpenAlgo Historify format (store as HISTORIFY_DB_PATH). Otherwise store as DUCKDB_PATH.6e. If the user selected Crypto Markets , ask if they want to configure exchange API keys:
.env.env6f. Write the.env file in the project root directory. Use this template, filling in any keys/paths 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
# DuckDB Data Sources (direct database loading - fastest)
# Custom DuckDB (user-created with OHLCV table)
DUCKDB_PATH={user_provided_path or ""}
# OpenAlgo Historify DuckDB (market_data table with epoch timestamps)
HISTORIFY_DB_PATH={user_provided_path or ""}
# Crypto Markets (CCXT) - Optional
CRYPTO_API_KEY={user_provided_key or ""}
CRYPTO_SECRET_KEY={user_provided_key or ""}
6g. 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
Run a quick verification:
python -c "
import vectorbt as vbt
import openalgo
import plotly
import talib
import duckdb
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' duckdb: {duckdb.__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).
Print a summary showing:
/backtest).env file status (configured with keys / placeholder) — single file at project rootcp .env.sample .env and fill in API keys if you skipped configuration"brew install ta-lib.env files — they contain secrets. Always use .gitignore..env — do not ask them to edit the file manuallypython-dotenv is included in the pip install and must be used by all scripts to load .envWeekly Installs
366
Repository
GitHub Stars
104
First Seen
Feb 27, 2026
Security Audits
Gen Agent Trust HubWarnSocketWarnSnykFail
Installed on
codex358
opencode358
cursor351
gemini-cli350
github-copilot350
amp349
Python类型注解模式指南:现代类型提示与Typing最佳实践
24 周安装
Web应用安全模式指南:OWASP Top 10防护、输入验证、身份认证与授权最佳实践
25 周安装
task-runner任务运行器:使用just简化项目命令执行,替代make的跨平台工具
30 周安装
EdgeOne Pages 一键部署:无需账户,秒级将HTML文件发布到公共URL
35 周安装
Vibe Security 安全扫描器 - 多语言代码漏洞检测与AI智能修复工具
38 周安装
wechat-publisher:一键发布Markdown文章到微信公众号草稿箱工具
323 周安装