feat(context): 接入 IndicatorUsecase,填实 Technical 字段

- MarketContextUsecase 增 IndicatorComputer 字段;构造器增参
- 用既有常量 derivativePeriod ("1h") 作为指标计算的 primary interval
  —— 与 LSR 采样时基对齐;未来切换 primary 改一个常量即可
- 替换原 hard-coded 空 Technical(market_context.go l.186-189)
- app.go 注入 usecase.NewIndicatorUsecase()

端到端 smoke 留给 commit 7 在所有测试就位后做(make docker-up + migrate-up + run)。
This commit is contained in:
dela
2026-05-24 20:32:30 +08:00
parent f47a151409
commit 0dabdb29ac
2 changed files with 6 additions and 4 deletions

View File

@@ -39,6 +39,8 @@ type MarketContextUsecase struct {
oiRepo OpenInterestRepository
lsRepo LongShortRatioRepository
indicator IndicatorComputer
log *slog.Logger
}
@@ -49,6 +51,7 @@ func NewMarketContextUsecase(
fundingRepo FundingRepository,
oiRepo OpenInterestRepository,
lsRepo LongShortRatioRepository,
indicator IndicatorComputer,
log *slog.Logger,
) *MarketContextUsecase {
return &MarketContextUsecase{
@@ -58,6 +61,7 @@ func NewMarketContextUsecase(
fundingRepo: fundingRepo,
oiRepo: oiRepo,
lsRepo: lsRepo,
indicator: indicator,
log: log,
}
}
@@ -183,10 +187,7 @@ func (u *MarketContextUsecase) Build(ctx context.Context, symbol string) (*entit
},
TakerBuySellVolume: nil,
},
Technical: entity.TechnicalStructure{
Support: []entity.TechnicalLevel{},
Resistance: []entity.TechnicalLevel{},
},
Technical: u.indicator.Compute(klines[derivativePeriod], globalLS),
DataQuality: entity.DataQuality{
Source: "binance",
Warnings: warnings,