Files
cryptoHermes/internal/entity/market_context.go
dela fa769331c2 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 更新)
2026-05-24 23:19:57 +08:00

87 lines
3.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package entity
type MarketContext struct {
Symbol string `json:"symbol"`
GeneratedAt int64 `json:"generatedAt"`
Snapshot *Ticker24h `json:"snapshot"`
Klines map[string][]Kline `json:"klines"`
Derivatives DerivativesBundle `json:"derivatives"`
Technical TechnicalStructure `json:"technical"`
DataQuality DataQuality `json:"dataQuality"`
}
type DerivativesBundle struct {
Funding FundingBundle `json:"funding"`
OpenInterest OpenInterestBundle `json:"openInterest"`
LongShortRatio LongShortBundle `json:"longShortRatio"`
TakerBuySellVolume []TakerBuySellVolume `json:"takerBuySellVolume"`
Signal *DerivativesSignal `json:"signal,omitempty"`
}
// DerivativesSignal 把 funding / OI / LSR 的原始数字翻译成可读语义,
// 供上游策略引擎直接消费。任一子字段为空字符串表示数据不足以判定。
type DerivativesSignal struct {
FundingBias string `json:"fundingBias,omitempty"` // crowded_long / crowded_short / neutral
OISignal string `json:"oiSignal,omitempty"` // long_building / short_building / deleveraging / stable
LSRRegime string `json:"lsrRegime,omitempty"` // retail_long_heavy / retail_short_heavy / balanced
}
type FundingBundle struct {
Current *FundingRate `json:"current"`
History []FundingRate `json:"history"`
}
type OpenInterestBundle struct {
Current *OpenInterest `json:"current"`
History []OpenInterest `json:"history"`
}
type LongShortBundle struct {
Global []LongShortRatio `json:"global"`
TopTraderPosition []LongShortRatio `json:"topTraderPosition"`
}
type TechnicalStructure struct {
Support []TechnicalLevel `json:"support"`
Resistance []TechnicalLevel `json:"resistance"`
RangeHigh *string `json:"rangeHigh"`
RangeLow *string `json:"rangeLow"`
LongShortLine *string `json:"longShortLine"`
Intervals map[string]IntervalTechnicals `json:"intervals"`
}
type IntervalTechnicals struct {
Bollinger *Bollinger `json:"bollinger,omitempty"`
Vegas *Vegas `json:"vegas,omitempty"`
}
// Bollinger 是 20 周期、2 倍标准差的布林带。
// BandwidthPct = (upper-lower)/mid * 100Squeeze 取 tight/normal/expanded。
type Bollinger struct {
Mid string `json:"mid"`
Upper string `json:"upper"`
Lower string `json:"lower"`
BandwidthPct string `json:"bandwidthPct"`
Squeeze string `json:"squeeze"`
}
// Vegas 通道EMA12/144/169 三条线 + 趋势判定。
// Trend: bull / bear / range按三条线的堆叠顺序判定。
type Vegas struct {
EMA12 string `json:"ema12"`
EMA144 string `json:"ema144"`
EMA169 string `json:"ema169"`
Trend string `json:"trend"`
}
type TechnicalLevel struct {
Price string `json:"price"`
Strength string `json:"strength,omitempty"`
Source string `json:"source,omitempty"`
}
type DataQuality struct {
Source string `json:"source"`
Warnings []string `json:"warnings"`
}