strategy-compare

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
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.
$ARGUMENTS
解析为:标的代码,后跟策略名称
  • $0
    = 标的代码(例如:SBIN、RELIANCE、NIFTY)
  • 剩余参数 = 待对比的策略(例如:ema-crossover、rsi、donchian)
如果仅提供标的代码而未指定策略,则默认对比以下策略:ema-crossover、rsi、donchian、supertrend。 如果策略列表中包含"long-vs-short",则针对第一个实际策略对比仅做多、仅做空、多空双向三种模式。

Instructions

操作步骤

  1. Read the vectorbt-expert skill for reference patterns
  2. Create a
    .py
    file in
    D:\QuantFlow 3\Day17\backtesting\
    named
    {symbol}_strategy_comparison.py
  3. The script must:
    • Fetch data once via OpenAlgo
    • Run each strategy on the same data
    • Collect
      pf.stats()
      from each into a side-by-side DataFrame
    • Print the comparison table
    • Plot overlaid equity curves for all strategies using Plotly
    • Save comparison to CSV
  4. Never use icons/emojis in code or logger output
  1. 参考vectorbt-expert skill的代码模式
  2. D:\QuantFlow 3\Day17\backtesting\
    目录下创建名为
    {symbol}_strategy_comparison.py
    的.py文件
  3. 脚本必须实现以下功能:
    • 通过OpenAlgo获取一次数据
    • 在同一数据上运行每个策略
    • 将每个策略的
      pf.stats()
      结果收集到一个并列的DataFrame中
    • 打印对比表格
    • 使用Plotly绘制所有策略的叠加权益曲线
    • 将对比结果保存为CSV文件
  4. 代码或日志输出中禁止使用图标/表情符号

Example Usage

使用示例

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