dsh-tool-backtest
DiscoveredDSH Plugin: Strategy Backtesting Engine — Define buy/sell signals, run historical data, and output performance metrics.
dsh-tool-backtest
DSH 插件:策略回测引擎 — 定义买卖信号,跑历史数据,输出绩效指标。
工具清单
| 工具 | 功能 |
|---|---|
run_backtest | 输入 K 线 + 信号 → 输出收益率、夏普、回撤、胜率、交易记录 |
calc_indicator | 技术指标计算:SMA、EMA、RSI、MACD、布林带 |
安装
dsh plugin add dsh-tool-backtest
配置
- insert:
- id: backtest
name: dsh-tool-backtest
config:
defaultCapital: 100000 # 默认初始资金
defaultCommission: 0.001 # 默认手续费率 0.1%
使用流程
Agent 的标准回测工作流:
1. market_kline 获取历史数据
2. calc_indicator 计算技术指标
3. 根据策略规则生成 signals(Agent 自行判断)
4. run_backtest 执行回测
5. 分析结果,给出建议
工具详解
run_backtest
输入:
{
"strategyName": "MA5/20 金叉",
"bars": [{"date":"2024-01-02","open":100,"high":102,"low":99,"close":101,"volume":50000}, ...],
"signals": [{"date":"2024-01-15","action":"buy","reason":"MA5上穿MA20"}, ...],
"capital": 100000,
"commission": 0.001
}
输出:
{
"summary": {
"strategy": "MA5/20 金叉",
"period": "2024-01-02 ~ 2024-12-31",
"totalReturn": "18.5%",
"annualizedReturn": "18.5%",
"maxDrawdown": "7.2%",
"sharpeRatio": 1.82,
"winRate": "65%",
"totalTrades": 12,
"avgHoldingDays": 15,
"profitFactor": 2.3
},
"recentTrades": [...],
"equityCurve": [...]
}
calc_indicator
支持的指标:
| 指标 | 参数 | 说明 |
|---|---|---|
sma | period (默认 20) | 简单移动平均 |
ema | period (默认 20) | 指数移动平均 |
rsi | period (默认 14) | 相对强弱指标,0-100 |
macd | 固定 12/26/9 | DIF、DEA、柱状图 |
bollinger | period (默认 20) | 上轨、中轨、下轨 |
输入:
{
"prices": [100, 101.5, 99.8, 102.3, ...],
"indicator": "rsi",
"period": 14
}
输出:
{
"indicator": "RSI",
"period": 14,
"values": [45.2, 52.1, 68.3, ...]
}
绩效指标说明
| 指标 | 含义 | 参考值 |
|---|---|---|
| 年化收益 | 按交易天数折算的年化回报 | > 15% 算不错 |
| 最大回撤 | 从峰值到谷底的最大跌幅 | < 20% 较安全 |
| 夏普比率 | 风险调整后收益 | > 1 可接受,> 2 优秀 |
| 胜率 | 盈利交易占比 | 趋势策略 40-50% 正常 |
| 盈亏比 | 平均盈利/平均亏损 | > 1.5 配合低胜率可行 |
| 交易次数 | 样本量 | > 20 有统计意义 |
与 dsh-tool-market-data 配合
# 典型 Agent 对话:
User: 用 RSI 超卖策略回测 BTC 半年
Agent:
→ market_kline({ symbol: "BTC", market: "crypto", period: "1d", limit: 180 })
→ calc_indicator({ prices: [close prices...], indicator: "rsi", period: 14 })
# 生成信号:RSI < 30 → buy, RSI > 70 → sell
→ run_backtest({ strategyName: "RSI(14) 超买超卖", bars: [...], signals: [...] })
# 输出绩效报告
局限性
- 不支持做空(仅多头)
- 不支持分批建仓/加仓
- 不支持止损止盈(需在信号层面实现)
- 滑点未建模(以收盘价成交)
- 无资金管理(每次全仓进出)
这些适合作为 v0.2+ 的增强方向。
License
MIT
Comments
Loading…
Similar plugins
by Liu-Bot24
DeepSeek Harness(DSH)只读执行轨迹复盘插件,支持规则分析、独立模型解读、证据定位、任务概览与运行对比。
★ 5
MIT
JavaScript
Sep 26, 2026
dsh plugin --profile web add dsh-plugin-trace-insightby Areium
DeepSeek Harness(DSH)插件:自动记录所有执行模式(原生工具 / PTC run_code / 代码内嵌工具调用)的工具失败错因,去重、计数、确定性排序后沉淀进 skill 的机器维护实录区段——让 Agent 越用越少错。
★ 10
↓ 109/wk
MIT
JavaScript
Sep 20, 2026
dsh plugin --profile web add dsh-fail-loggerby xinmo114514
DSH(DeepSeek Harness)Web 插件:设置页 Token 消耗仪表盘 —— 指标卡、近 7 天/逐时趋势图、按模型/会话分布,数据全部来自本机会话日志,零外部请求。
★ 0
Unlicense
TypeScript
Aug 15, 2026
dsh plugin --profile web add dsh-usage-dashboardby omdsh-dev
An dsh plugin for role-based LLM retry&fallback strategy. 基于角色的模型重试备用策略插件
★ 20
MIT
TypeScript
Sep 28, 2026
dsh plugin --profile web add dsh-llm-fallbacksby MkaliezZ
Deterministic regression tests for DSH policy decisions, evaluated without invoking the protected tool body.
★ 0
TypeScript
Aug 29, 2026
dsh plugin --profile web add @mkaliezz/dsh-policy-testby SenmuuuuW
深迹 DeepTrace — Your Agent, in numbers. DSH 插件:从会话事件日志生成日报/周报/月报/年报/自定义区间,确定性洞察与协作复盘,只读、不改写历史。
★ 30
MIT
TypeScript
Sep 3, 2026
dsh plugin --profile web add dsh-whale-report