feat: 接入 CoinGlass 清算热力图隔离链路
Some checks failed
ci / build + vet + guard + race (push) Has been cancelled

This commit is contained in:
dela
2026-05-25 16:57:22 +08:00
parent e5fb54cb72
commit 1b61541ff5
32 changed files with 2550 additions and 70 deletions

View File

@@ -0,0 +1,27 @@
package usecase
import (
"context"
"strings"
"cryptoHermes/internal/entity"
)
const defaultCGLiqHeatMapLimit = 288
type CoinglassQueryUsecase struct {
liqHeatMapRepo CoinglassLiqHeatMapRepository
}
func NewCoinglassQueryUsecase(liqHeatMapRepo CoinglassLiqHeatMapRepository) *CoinglassQueryUsecase {
return &CoinglassQueryUsecase{liqHeatMapRepo: liqHeatMapRepo}
}
func (u *CoinglassQueryUsecase) GetLiqHeatMap(ctx context.Context, symbol, interval string, limit int) ([]entity.CGLiqHeatMap, error) {
symbol = strings.ToUpper(strings.TrimSpace(symbol))
symbol = strings.TrimPrefix(symbol, "BINANCE_")
if limit <= 0 {
limit = defaultCGLiqHeatMapLimit
}
return u.liqHeatMapRepo.FindRecent(ctx, symbol, interval, limit)
}

View File

@@ -25,6 +25,10 @@ type DerivativesProvider interface {
GetTakerBuySellVolume(ctx context.Context, symbol, period string, limit int) ([]entity.TakerBuySellVolume, error)
}
type CoinglassProvider interface {
GetLiqHeatMap(ctx context.Context, symbol, interval string, limit int) (*entity.CGLiqHeatMap, error)
}
type KlineRepository interface {
UpsertMany(ctx context.Context, items []entity.Kline) error
FindRecent(ctx context.Context, symbol, interval string, limit int) ([]entity.Kline, error)
@@ -50,6 +54,11 @@ type TakerVolumeRepository interface {
FindRecent(ctx context.Context, symbol, period string, limit int) ([]entity.TakerBuySellVolume, error)
}
type CoinglassLiqHeatMapRepository interface {
UpsertMany(ctx context.Context, items []entity.CGLiqHeatMap) error
FindRecent(ctx context.Context, symbol, interval string, limit int) ([]entity.CGLiqHeatMap, error)
}
// IndicatorComputer 纯函数式接口:接收已经被上层 fetch 的 slice
// 返回填充好的 TechnicalStructure。
//