blockchain/internal/domain/usecase/data_source.go

46 lines
2.2 KiB
Go
Raw Permalink Normal View History

2025-08-04 14:02:01 +00:00
package usecase
import (
"context"
)
type DataSourceUseCase interface {
GetSymbols(ctx context.Context) ([]*Symbol, error)
2025-08-06 23:41:18 +00:00
UpsertKline(ctx context.Context, data QueryKline) error
2025-08-14 23:41:29 +00:00
ListKline(ctx context.Context, param QueryKline) ([]Candle, error)
2025-08-04 14:02:01 +00:00
}
// Symbol 代表交易對資訊
type Symbol struct {
Symbol string `json:"symbol"` // 交易對名稱 BTCUSDT
Status string `json:"status"` // 狀態(如 "TRADING" 表示可交易)
BaseAsset string `json:"base_asset"` // 主幣種(如 BTCUSDT 的 BTC
BaseAssetPrecision int `json:"base_asset_precision"` // 主幣的小數點精度
QuoteAsset string `json:"quote_asset"` // 報價幣種(如 BTCUSDT 的 USDT
QuoteAssetPrecision int `json:"quote_asset_precision"` // 報價資產顯示的小數位數
}
2025-08-06 23:41:18 +00:00
type QueryKline struct {
2025-08-14 23:41:29 +00:00
Symbol string
Interval string
StartTime int64
EndTime int64
}
type Candle struct {
OpenTime int64 `json:"open_time"` // 開盤時間毫秒clustering key用於時序查詢
Open string `json:"open"` // 開盤價
High string `json:"high"` // 最高價
Low string `json:"low"` // 最低價
Close string `json:"close"` // 收盤價
Volume string `json:"volume" ` // 成交量
CloseTime int64 `json:"close_time" ` // 收盤時間(毫秒)
QuoteAssetVolume string `json:"quote_asset_volume" ` // 成交額(以報價資產計)
NumberOfTrades int `json:"number_of_trades"` // 交易筆數
TakerBuyBaseAssetVolume string `json:"taker_buy_base_asset_volume"` // 主動買入成交量
TakerBuyQuoteAssetVolume string `json:"taker_buy_quote_asset_volume"` // 主動買入成交額
Symbol string `json:"symbol"` // 交易對partition key
// K 線時間區間partition key // 12h,15m,1d,1h,1m,1s,2h,30m,3m,4h,5m,6h,8h
Interval string `json:"interval"`
2025-08-06 23:41:18 +00:00
}