feat(indicator): per-interval S/R + Range + LSLine + Donchian 箱体(ADR-0003)

按 ADR-0003 把 Support / Resistance / Range / LSLine 从顶层下沉进
IntervalTechnicals,每个周期独立计算;顶层 5 字段保留为 Intervals[primary]
镜像(单一来源,不双写)以维持向后兼容的 JSON shape。

新增 BoxBreak(Donchian 风格,lookback=20 根不含当前根,K 线 < 21 → nil),
落到 IntervalTechnicals.Box。

IndicatorComputer.Compute 签名升级到 longShortByInterval map:
market_context 改为并发拉取 15m/1h/4h/1d 的全局 LSR,1w 不在 Binance LSR
支持列表 → 加 warning lsr_unsupported_interval:1w。

测试:boxBreak 6 个 case(inside/break_up/break_down/insufficient/2 个 parse
失败)+ per-interval Support/Resistance/Range 跨周期断言 + 镜像不变量 +
缺 LSR key → LongShortLine nil。indicator.go 平均覆盖 97.26%(boxBreak 100%)。
This commit is contained in:
dela
2026-05-25 10:44:33 +08:00
parent 319e73d91f
commit 21b3078094
6 changed files with 423 additions and 39 deletions

View File

@@ -51,8 +51,14 @@ type TechnicalStructure struct {
}
type IntervalTechnicals struct {
Bollinger *Bollinger `json:"bollinger,omitempty"`
Vegas *Vegas `json:"vegas,omitempty"`
Bollinger *Bollinger `json:"bollinger,omitempty"`
Vegas *Vegas `json:"vegas,omitempty"`
Support []TechnicalLevel `json:"support,omitempty"`
Resistance []TechnicalLevel `json:"resistance,omitempty"`
RangeHigh *string `json:"rangeHigh,omitempty"`
RangeLow *string `json:"rangeLow,omitempty"`
LongShortLine *string `json:"longShortLine,omitempty"`
Box *BoxBreak `json:"box,omitempty"`
}
// Bollinger 是 20 周期、2 倍标准差的布林带。
@@ -74,6 +80,16 @@ type Vegas struct {
Trend string `json:"trend"`
}
// BoxBreak 是 Donchian 风格的 N 根 lookback 箱体突破信号。
// BoxHigh / BoxLow 取最近 LookbackBars 根(不含当前根)的最高高 / 最低低;
// Status: inside / break_up / break_down由最后一根 K 线收盘相对箱体边判定。
type BoxBreak struct {
BoxHigh string `json:"boxHigh"`
BoxLow string `json:"boxLow"`
Status string `json:"status"`
LookbackBars string `json:"lookbackBars"`
}
type TechnicalLevel struct {
Price string `json:"price"`
Strength string `json:"strength,omitempty"`