源文件:research/quant_digests/2026-03-21_0246_closedbar-htf-context-honesty-gate.md
看了 TheVision333/trading-bot 里的 strategy/mtf.py 与 Pandas 官方 merge_asof 文档。最值得偷的不是某条均线,而是它把高周期上下文写成一个严格 closed-bar only 的合并规则:LTF 在时点 T 只能拿到 已收盘 的 HTF 状态,不能偷看正在形成中的 4H / 1D bar。
pd.merge_asof(..., direction='backward');Pandas 官方文档也明确写着,backward 只会选取 right_key <= left_key 的最后一行,也就是只拿过去或当前已知值。15m -> 1h:45 分钟 = 3 根 15m bar15m -> 4h:225 分钟 = 15 根 15m bar15m -> 1d:1425 分钟 = 95 根 15m bar14:00 的 1H 信号,只能拿 12:00 已收盘 4H bar 的结构,不能拿 16:00 那根还没收完的 4H bar。这轮虽然不是再加一个新 alpha,但它比继续堆一个新过滤器更值:先把三条收口线的 HTF 上下文做干净,否则后面的胜率/回撤改善可能只是“偷看未来”。
V3 final-verdict / breakout-short follow-up:若 15m breakout-short 用了“当前 4H 已转弱/转强”当 follow-up gate,但那根 4H 其实还没收盘,final verdict 容易被虚高。Fibonacci confirmation / retest_hold:Fib 回踩特别依赖 1H/4H 趋势背景;如果 HTF 对齐口径不诚实,retest_hold 的确认强度会被高估。EMA / PSAR raw alpha focus:在继续讨论 EMA/PSAR 是主触发还是 overlay 之前,先确认 HTF trend filter 没有 lookahead,比再调参数更要紧。Honest:HTF 特征先按 HTF close timestamp 计算,再用 merge_asof(direction="backward") 合并到 15m;Naive:把当前 HTF bar 直接 resample/ffill 到 15m,允许未收盘 bar 的值提前进入。BTC/ETH/SOL perpetual,15m 主信号;HTF 先测 1h/4h 两层;时间先取 2023-01-01 至今;成本先固定 6/10/15 bps per side。post_cost_expectancyfailure_ratetrade_count_retentionHTF gate flip rate(多少笔在 naive 通过、honest 不通过)breakout-short、fib_retest_hold、ema_psar 三条线上各做一次 naive vs honest A/B;如果某条线对口径极敏感,就先暂停加新过滤器,回头重审证据。merge_asof 也会错位。N/Ahttps://github.com/TheVision333/trading-bothttps://github.com/TheVision333/trading-bothttps://raw.githubusercontent.com/TheVision333/trading-bot/main/strategy/mtf.pyhttps://raw.githubusercontent.com/TheVision333/trading-bot/main/config.pyN/Ahttps://pandas.pydata.org/docs/reference/api/pandas.merge_asof.html