fix: map CoinGlass heatmap range bounds
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled

This commit is contained in:
dela
2026-05-25 22:06:21 +08:00
parent 7e31e9cbaf
commit b15d763287
2 changed files with 4 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ type CGEnvelope struct {
// 真实响应的 plaintext 是 data 本体(例如 {"instrument":...,"liq":[...]})。
// 为兼容早期 fixture如 plaintext 仍带 success/code/data envelope则先拆 data。
// PR-1 阶段做最薄映射data 整体进 RawGrid
// 若顶层有 minPrice/maxPrice/priceMin/priceMax 字段则抽出(容忍命名漂移)。
// 若顶层有 rangeLow/rangeHigh/minPrice/maxPrice/priceMin/priceMax 字段则抽出(容忍命名漂移)。
// 真实 schema 经 spike dump 后回填到 spec §5mapper 同步加显式字段)。
//
// 数值边界ADR-0004 D3解 JSON number 默认 float64 是 transient
@@ -45,8 +45,8 @@ func MapLiqHeatMap(symbol string, interval string, ts int64, plaintext []byte) (
var probe map[string]json.RawMessage
if err := json.Unmarshal(raw, &probe); err == nil {
out.PriceMin = pickFloatField(probe, "priceMin", "minPrice", "min")
out.PriceMax = pickFloatField(probe, "priceMax", "maxPrice", "max")
out.PriceMin = pickFloatField(probe, "priceMin", "rangeLow", "minPrice", "min")
out.PriceMax = pickFloatField(probe, "priceMax", "rangeHigh", "maxPrice", "max")
}
return out, nil
}

View File

@@ -20,7 +20,7 @@ func TestMapLiqHeatMap_FloatToString(t *testing.T) {
}{
{
name: "real decrypted data object",
plaintext: `{"instrument":{"exName":"Binance","instrumentId":"BTCUSDT"},"liq":[[1,2,3.4]],"priceMin":110234.5,"priceMax":118888.0}`,
plaintext: `{"instrument":{"exName":"Binance","instrumentId":"BTCUSDT"},"liq":[[1,2,3.4]],"prices":[110000,111000],"rangeLow":110234.5,"rangeHigh":118888.0,"updateTime":1779717600600,"y":[]}`,
wantSymbol: "Binance_BTCUSDT",
wantMin: "110234.5",
wantMax: "118888",