Backtest Analyzer

回测分析工具。从交易记录CSV计算回测核心指标: 胜率、盈亏比、最大回撤、夏普比率、获利因子、 最佳/最差单笔交易。支持JSON报告导出。 Use when: 需要评估交易策略表现、分析回测结果、 计算策略风险指标、对比不同策略。 🎉 v1.0.0 指标: - 总交易数 / 盈利交易 / 亏损交易 - 胜率 / 盈亏比 / 获利因子 - 总收益率 / …

ChengQian

@cqdev-ai

What This Skill Does

Reads a CSV of trade records and calculates key backtesting metrics: win rate, profit/loss ratio, maximum drawdown, Sharpe ratio, profit factor, and best/worst single trade. Supports automatic column name detection and JSON report export.

Replaces manual spreadsheet calculations or custom scripts for computing standard backtest metrics from trade logs.

When to Use It

  • Evaluate a trading strategy's performance from a CSV backtest output
  • Analyze actual trade records to assess trading quality and risk
  • Compare multiple strategies by exporting and reviewing their JSON reports
  • Calculate maximum drawdown and Sharpe ratio for a set of trades
  • Identify best and worst single trades from a trading history

Install

$ openclaw skills install @cqdev-ai/backtest-analyzer

📊 Backtest Analyzer

Overview

从交易记录CSV自动计算回测核心指标。支持自动列名识别(pnl/profit/盈亏、price/成交价等),无需手动配置数据格式。

Usage

# 标准分析
python3 scripts/backtest_analyzer.py --file trades.csv

# 指定本金
python3 scripts/backtest_analyzer.py --file trades.csv --capital 500000

# 导出JSON报告
python3 scripts/backtest_analyzer.py --file trades.csv --output report.json --json

输出示例

📊 回测分析报告
    =============================================
    总交易数:    342
    盈利交易:    198 (57.9%)
    亏损交易:    144 (42.1%)
    =============================================
    总收益:     +128,450.00 (+12.85%)
    平均每笔:   +0.04%
    胜率:       57.9%
    盈亏比:     2.35
    获利因子:   2.81
    =============================================
    最大回撤:    8.45%
    夏普比率:    1.62
    最佳交易:   +12,500.00
    最差交易:   -8,200.00

JSON Output

{
  "total_trades": 342,
  "win_trades": 198,
  "loss_trades": 144,
  "win_rate_pct": 57.9,
  "total_pnl": 128450.0,
  "total_return_pct": 12.85,
  "max_drawdown_pct": 8.45,
  "sharpe_ratio": 1.62,
  "profit_factor": 2.81
}

CSV列自动识别

自动匹配的列名(优先级顺序):

字段匹配列名
盈亏pnl, profit, 盈亏, return, net_pnl
价格price, 成交价, avg_price, close
日期date, 日期, trade_date
股票stock, 代码, symbol
数量shares, 数量, qty

Use Cases

  • 策略回测: 导入回测引擎输出,计算策略指标
  • 实盘复盘: 导入实际交易记录,分析交易质量
  • 对比分析: 对比不同策略的报告,选择最优

Security

  • ✅ 纯本地运行,无网络请求
  • ✅ 只读CSV输入文件
  • ❌ 无任意代码执行

Top skills in this category

description: 将用户讲稿一键生成乔布斯风极简科技感竖屏HTML演示稿。当用户需要生成PPT、演示文稿、Slides、幻灯片,或要求科技风/极简风/乔布斯风格的演示时触发此技能。输出为单个可直接运行的HTML文件。

@wwlyzzyorg

将讲稿一键生成乔布斯风极简科技感竖屏HTML演示稿

8534k

Feishu Evolver Wrapper

@autogame-17

(Depreciated: This skill is no longer maintained; its related functions have been absorbed by the Evolver main body.) Feishu-integrated wrapper for the capability-evolver. Manages the evolution loop lifecycle (start/stop/ensure), sends rich Feishu card reports, and provides...

1076k

Resume Assistant

@wscats

Assist job seekers by polishing, customizing, scoring, and exporting resumes with detailed checklist reviews and multi-format support.

1721k

LNBits Wallet wtih QR Code

@jamestsetsekas

Manage LNbits Lightning Wallet (Balance, Pay, Invoice)

622k

Smart Model Switching

@millibus

Auto-route tasks to the cheapest Claude model that works correctly. Three-tier progression: Haiku → Sonnet → Opus. Classify before responding. HAIKU (default): factual Q&A, greetings, reminders, status checks, lookups, simple file ops, heartbeats, casual chat, 1-2 sentence tasks. ESCALATE TO SONNET: code >10 lines, analysis, comparisons, planning, reports, multi-step reasoning, tables, long writing >3 paragraphs, summarization, research synthesis, most user conversations. ESCALATE TO OPUS: architecture decisions, complex debugging, multi-file refactoring, strategic planning, nuanced judgment, deep research, critical production decisions. Rule: If a human needs >30 seconds of focused thinking, escalate. If Sonnet struggles with complexity, go to Opus. Save 50-90% on API costs by starting cheap and escalating only when needed.

216.8k