feat(market): Phase 1 扩展 — 更多 symbol + Bollinger/Vegas + 衍生品信号
- collector.symbols 与 supportedSymbols 加 SOL/BNB/DOGE,env-default 与 README 同步 - entity 追加 TechnicalStructure.Intervals(每周期 Bollinger + Vegas,omitempty 不破坏既有字段)与 DerivativesBundle.Signal - 新增纯解析 usecase derivatives_signal.go:fundingBias 绝对阈值、oiSignal 用 P20 baseline + 价格方向(OI up + 价格 up/down → long/short_building,funding 不参与方向)、lsrRegime 绝对阈值;signal 数据不足走 warnings 进 DataQuality - indicator.go 加 sma/stddev/ema/bollinger/vegas + computeIntervalTechnicals;IndicatorComputer 签名收 klines map - harness 同步:G12 扩入 derivatives_signal.go(含 Makefile G12.5/6 + ADR-0002 适用范围 + project-map / harness-health 更新)
This commit is contained in:
@@ -14,8 +14,11 @@ import (
|
||||
)
|
||||
|
||||
var supportedSymbols = map[string]bool{
|
||||
"BTCUSDT": true,
|
||||
"ETHUSDT": true,
|
||||
"BTCUSDT": true,
|
||||
"ETHUSDT": true,
|
||||
"SOLUSDT": true,
|
||||
"BNBUSDT": true,
|
||||
"DOGEUSDT": true,
|
||||
}
|
||||
|
||||
var supportedIntervals = []string{"15m", "1h", "4h", "1d", "1w"}
|
||||
@@ -39,7 +42,8 @@ type MarketContextUsecase struct {
|
||||
oiRepo OpenInterestRepository
|
||||
lsRepo LongShortRatioRepository
|
||||
|
||||
indicator IndicatorComputer
|
||||
indicator IndicatorComputer
|
||||
derivSignal DerivativesSignalComputer
|
||||
|
||||
log *slog.Logger
|
||||
}
|
||||
@@ -52,6 +56,7 @@ func NewMarketContextUsecase(
|
||||
oiRepo OpenInterestRepository,
|
||||
lsRepo LongShortRatioRepository,
|
||||
indicator IndicatorComputer,
|
||||
derivSignal DerivativesSignalComputer,
|
||||
log *slog.Logger,
|
||||
) *MarketContextUsecase {
|
||||
return &MarketContextUsecase{
|
||||
@@ -62,6 +67,7 @@ func NewMarketContextUsecase(
|
||||
oiRepo: oiRepo,
|
||||
lsRepo: lsRepo,
|
||||
indicator: indicator,
|
||||
derivSignal: derivSignal,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
@@ -167,27 +173,36 @@ func (u *MarketContextUsecase) Build(ctx context.Context, symbol string) (*entit
|
||||
addWarn("top trader position long/short query failed: " + err.Error())
|
||||
}
|
||||
|
||||
derivBundle := entity.DerivativesBundle{
|
||||
Funding: entity.FundingBundle{
|
||||
Current: currentFund,
|
||||
History: fundingHist,
|
||||
},
|
||||
OpenInterest: entity.OpenInterestBundle{
|
||||
Current: currentOI,
|
||||
History: oiHist,
|
||||
},
|
||||
LongShortRatio: entity.LongShortBundle{
|
||||
Global: globalLS,
|
||||
TopTraderPosition: topLS,
|
||||
},
|
||||
TakerBuySellVolume: nil,
|
||||
}
|
||||
if u.derivSignal != nil {
|
||||
signal, sigWarnings := u.derivSignal.Compute(currentFund, oiHist, globalLS, klines[derivativePeriod])
|
||||
derivBundle.Signal = signal
|
||||
for _, w := range sigWarnings {
|
||||
addWarn(w)
|
||||
}
|
||||
}
|
||||
|
||||
out := &entity.MarketContext{
|
||||
Symbol: symbol,
|
||||
GeneratedAt: time.Now().UnixMilli(),
|
||||
Snapshot: snapshot,
|
||||
Klines: klines,
|
||||
Derivatives: entity.DerivativesBundle{
|
||||
Funding: entity.FundingBundle{
|
||||
Current: currentFund,
|
||||
History: fundingHist,
|
||||
},
|
||||
OpenInterest: entity.OpenInterestBundle{
|
||||
Current: currentOI,
|
||||
History: oiHist,
|
||||
},
|
||||
LongShortRatio: entity.LongShortBundle{
|
||||
Global: globalLS,
|
||||
TopTraderPosition: topLS,
|
||||
},
|
||||
TakerBuySellVolume: nil,
|
||||
},
|
||||
Technical: u.indicator.Compute(klines[derivativePeriod], globalLS),
|
||||
Derivatives: derivBundle,
|
||||
Technical: u.indicator.Compute(klines, derivativePeriod, globalLS),
|
||||
DataQuality: entity.DataQuality{
|
||||
Source: "binance",
|
||||
Warnings: warnings,
|
||||
|
||||
Reference in New Issue
Block a user