360 Secure SkillHub
360 安全技能中心

Crypto Backtest

核心功能:支持所有ccxt兼容交易所的OHLCV数据获取,内置EMA、RSI等经典策略,可自动参数扫测、配置杠杆/止盈止损等风险模拟,还支持自定义策略扩展。典型场景:回测交易策略、对比参数组合、构建量化交易管道。通过命令行调用,输出含胜率、PnL、最大回撤等指标,结果可导出JSON用于系统集成。

sunnyztj
sunnyztj
热度 95.40
最近更新 2026-05-11 17:26:14
分类:数据依赖:代码执行 / 第三方 API应用场景:数据处理 / 财务 / 报告撰写

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add crypto-backtest
Metadata
name
crypto-backtest
description
Crypto futures backtesting engine with built-in EMA, RSI, MACD, and Bollinger Band strategies. Fetches OHLCV data from any ccxt-supported exchange (Bybit, Binance, OKX, etc.), runs multi-strategy sweeps, calculates win rate / PnL / drawdown, and exports results to JSON. Use when backtesting trading strategies, comparing parameter combinations, evaluating crypto trading signals, or building a quantitative trading pipeline.

Crypto Backtest Engine

Fast, scriptable backtesting for crypto futures strategies. Fetches data via ccxt, runs strategies, reports metrics.

Quick Start

pip install ccxt numpy
python scripts/backtest_engine.py --symbol ETH/USDT:USDT --strategy ema --fast 12 --slow 26

Features

  • Multi-exchange: Any ccxt-supported exchange (Bybit, Binance, OKX, Bitget...)
  • Built-in strategies: EMA crossover, RSI, MACD, Bollinger Bands
  • Parameter sweep: Test all combinations automatically
  • Risk simulation: Configurable leverage, position size, SL/TP, fees
  • JSON export: Machine-readable results for pipeline integration
  • Custom strategies: Simple plug-in interface

Usage

Single Strategy

python scripts/backtest_engine.py \
  --symbol SOL/USDT:USDT \
  --strategy rsi \
  --period 14 --oversold 30 --overbought 70 \
  --capital 1000 --leverage 5

Parameter Sweep

python scripts/sweep.py \
  --symbol ETH/USDT:USDT \
  --strategies ema,rsi,macd,bbands \
  --capital 1000 --leverage 5 \
  --output results.json

Custom Strategy

See references/custom_strategy.md for the plug-in interface.

Output Metrics

Each backtest reports:

  • Total trades, win rate, profit factor
  • Total PnL (absolute + percentage)
  • Max drawdown
  • Best/worst trade
  • Final balance

Files

  • scripts/backtest_engine.py — Core engine with EMA, RSI, MACD, Bollinger Bands
  • scripts/sweep.py — Multi-strategy parameter sweep runner
  • references/custom_strategy.md — Guide for adding custom strategies
  • references/strategy_notes.md — Notes on each built-in strategy's edge cases