agentleFS
wwumitwwumit/skills-stock/skills/backtest-analyzer/SKILL.md

backtest-analyzer

Skill0 starsChanged 3 months agoMITView on GitHub

回测分析工具。从交易记录CSV计算回测核心指标: 胜率、盈亏比、最大回撤、夏普比率、获利因子、 单笔最高/最低盈亏交易。支持JSON报告导出。

The file

Files
SKILL.md

⚠️ 免责声明:本工具为辅助性参考工具,不构成投资建议,不构成法律建议。市场有风险,投资需谨慎;据此操作,风险自担。正式合规意见请咨询具备资质的律师。最终决策与责任由使用者自行承担。 仅供学习研究参考;> 仅供参考,不构成任何操作依据;市场有风险,投资需谨慎,据此操作风险自担。

📊 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输入文件
  • ❌ 无任意代码执行

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.