/** * A 股策略库(纯函数、零依赖)—— dsh-strategy 域。 * * 所有策略遵循统一契约: * - `generate(bars, ctx)` 返回 targetWeight[i][k](bar i 收盘后的目标权重) * - 只看 bar i 及之前的数据(无未来函数) * - 权重和 ≤ 1(引擎另有硬护栏兜底) * * 这些策略经 A 股 CSI300 样本(2023-11~2026-09,11 个不重叠 63 日窗口) * 实证评估,其中: * - `momentumStop`(动量+趋势闸门+个股止损):前向验证超额中位 +11.33%、跑赢 67% * - `lowVolCircuit`(低波+熔断):回撤小但前向验证超额不显著(-3.81%),已标注 * 详见项目 FORK.md 与 STATE.md。 */ import { type Bar, backtestTargetWeights } from './engine.js'; /** 策略上下文参数(各策略按需读取,未用到的忽略)。 */ export interface StrategyContext { [key: string]: number | boolean | undefined; } /** 策略定义。 */ export interface Strategy { /** 稳定标识(用于报告与参数覆盖) */ id: string; /** 人类可读名称 */ name: string; /** 假设说明(为什么可能有效) */ thesis: string; /** 生成目标权重矩阵 */ generate(bars: readonly (readonly Bar[])[], ctx?: StrategyContext): number[][]; /** 默认参数网格(供参数搜索使用) */ grid: Record; } /** 票池等权指数(用于大盘状态判断)。 */ export declare function equalWeightIndex(bars: readonly (readonly Bar[])[]): number[]; /** 指数距 N 日高点的回撤(实时量,比均线穿越反应快)。 */ export declare function drawdownFromHigh(index: readonly number[], window: number): number[]; /** 双均线交叉(单标的择时;多标的时各标的独立)。 */ export declare const maCross: Strategy; /** 波动率目标仓位(按已实现波动率反推仓位,压回撤)。 */ export declare const volTarget: Strategy; /** * 横截面动量选股(实证基准)。 * 注意:样本内表现强(跑赢率 82%)但最差窗口 -50%;建议配合止损与趋势闸门使用。 */ export declare const crossMomentum: Strategy; /** * 动量选股 + 趋势闸门 + 个股止损。 * * 前向验证(只用历史窗口选参、在未来窗口测试)结果: * 超额中位 +11.33%、跑赢基准 6/9 窗口、回撤中位 17.73%。 * 这是本项目实证出的最优可复现策略。 */ export declare const momentumStop: Strategy; /** * 低波动选股 + 快速熔断 + 反波动率加权。 * * ⚠️ 诚实标注:本策略样本内 Calmar 极高(0.999 vs momentumStop 0.320), * 但**真·前向验证下超额为负**(-3.81%、跑赢率仅 33%)—— 属于过拟合的典型。 * 保留它作为「回撤极小」的参考实现,但不应作为收益策略推荐。 */ export declare const lowVolCircuit: Strategy; /** 短期超跌反转(买跌幅最大者);最差窗口最小但收益也最低。 */ export declare const shortReversal: Strategy; /** 全部内置策略。 */ export declare const ALL_STRATEGIES: readonly Strategy[]; /** 按 id 查找策略。 */ export declare function findStrategy(id: string): Strategy | undefined; /** * 便捷函数:用某策略跑一次回测。 * @param bars 标的多序列 * @param strategy 策略或策略 id * @param ctx 策略参数 * @param options 回测选项 */ export declare function runStrategy(bars: readonly (readonly Bar[])[], strategy: Strategy | string, ctx?: StrategyContext, options?: Parameters[2]): { signals: number[][]; equity: number[]; returns: number[]; totalReturnPct: number; maxDrawdownPct: number; sharpe: number; annualReturnPct: number; calmar: number; avgTurnover: number; bars: number; maxGrossRaw: number; totalCostRatio: number; strategy: string; ctx: StrategyContext; };