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

@@ -55,6 +55,7 @@ func Run(cfg *config.Config, log *slog.Logger) error {
fundingRepo, fundingRepo,
oiRepo, oiRepo,
lsRepo, lsRepo,
usecase.NewIndicatorUsecase(),
log, log,
) )

View File

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