EasyQuant logo EasyQuant量化研究 返回

策略规则 JSON 编写说明

规则 JSON 用于经典策略、自定义策略以及回测引擎。核心结构包括 entry(买入条件)、exit(卖出条件)、止损止盈和可选自定义特征。

最小结构

{
  "entry": { "type": "threshold", "feature": "rsi", "op": "<", "value": 30 },
  "exit": { "type": "threshold", "feature": "rsi", "op": ">", "value": 70 },
  "stop_loss": 0.08,
  "take_profit": 0.20
}

条件类型

type说明常用字段
threshold数值阈值条件featureopvalue
cross_above快线从下向上穿过慢线fastslow
cross_below快线从上向下穿过慢线fastslow
all多个条件同时满足conditions
any多个条件满足其一conditions

常用操作符

>>=<<=

常用内置特征

closeopenhighlowvolumema_5ma_20rsidifdeaboll_upperboll_midboll_lowerret_1ret_5ret_20volatility_20volume_ratio_5volume_ratio_20

卖出条件补充

除 exit 外,还可以使用 holding_period 按持仓天数退出:

{
  "entry": { "type": "threshold", "feature": "ret_20", "op": ">", "value": 0.10 },
  "exit": { "type": "holding_period", "bars": 10 }
}

自定义特征

在“特征”页新增并启用自定义特征后,它会被自动注入回测和交易建议;也可以在当前 JSON 中显式声明:

{
  "entry": { "type": "threshold", "feature": "my_roc", "op": ">", "value": 0.05 },
  "exit": { "type": "threshold", "feature": "my_roc", "op": "<", "value": -0.03 },
  "custom_features": [
    { "name": "my_roc", "source": "close", "operation": "pct_change", "window": 10 }
  ]
}

计算方式支持 pct_changerolling_meanrolling_stdrolling_maxrolling_mindiffzscoreratio

返回上一页