策略比较

数据 社区

技能解读

当前原文的自动摘译,尚未人工审校。

论点

将 $ARGUMENTS 解析为:符号后跟策略名称 $0 = 符号(例如 SBIN、RELIANCE、NIFTY) 剩余参数 = 要比较的策略(例如 ema-crossover rsi donchian) 如果仅给出符号而没有策略,则比较:ema-crossover、rsi、donchian、supertrend。如果“多头与空头”是策略之一,则比较多头与空头与两者,作为第一个真正的策略。

使用说明

阅读 vectorbt-expert 技能规则以获取参考模式 创建 backtesting/strategy_comparison/ 目录(如果不存在)(按需) 在 backtesting/strategy_comparison/ 中创建名为 {symbol}_strategy_comparison.py 的 .py 文件 脚本必须: 通过 OpenAlgo 获取数据一次

用法示例

/strategy-compare RELIANCE ema-crossover rsi donchian /strategy-compare SBIN long-vs-short ema-crossover

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
数据
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@marketcalls · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
允许外网请求
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

Create a strategy comparison script.

## Arguments

Parse `$ARGUMENTS` as: symbol followed by strategy names

- `$0` = symbol (e.g., SBIN, RELIANCE, NIFTY)
- Remaining args = strategies to compare (e.g., ema-crossover rsi donchian)

If only a symbol is given with no strategies, compare: ema-crossover, rsi, donchian, supertrend.
If "long-vs-short" is one of the strategies, compare longonly vs shortonly vs both for the first real strategy.

## Instructions

1. Read the vectorbt-expert skill rules for reference patterns
2. Create `backtesting/strategy_comparison/` directory if it doesn't exist (on-demand)
3. Create a `.py` file in `backtesting/strategy_comparison/` named `{symbol}_strategy_comparison.py`
3. The script must:
   - Fetch data once via OpenAlgo
   - If user provides a DuckDB path, load data directly via `duckdb.connect(path, read_only=True)`. See vectorbt-expert `rules/duckdb-data.md`.
   - If `openalgo.ta` is not importable (standalone DuckDB), use inline `exrem()` fallback.
   - **Use TA-Lib for ALL indicators** (never VectorBT built-in)
   - **Use OpenAlgo ta** for specialty indicators (Supertrend, Donchian, etc.)
   - Clean signals with `ta.exrem()` (always `.fillna(False)` before exrem)
   - Run each strategy on the same data
   - **Indian delivery fees**: `fees=0.00111, fixed_fees=20` for delivery equity
   - Collect key metrics from each into a side-by-side DataFrame
   - **Include NIFTY benchmark** in the comparison table (via OpenAlgo `NSE_INDEX`)
   - **Print Strategy vs Benchmark comparison table**: Total Return, Sharpe, Sortino, Max DD, Win Rate, Trades, Profit Factor
   - **Explain results** in plain language - which strategy performed best and why
   - Plot overlaid equity curves for all strategies using Plotly (`template="plotly_dark"`)
   - Save comparison to CSV
4. Never use icons/emojis in code or logger output

## Example Usage

`/strategy-compare RELIANCE ema-crossover rsi donchian`
`/strategy-compare SBIN long-vs-short ema-crossover`

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。