46 lines
2.2 KiB
Go
46 lines
2.2 KiB
Go
package usecase
|
||
|
||
import (
|
||
"context"
|
||
)
|
||
|
||
type DataSourceUseCase interface {
|
||
GetSymbols(ctx context.Context) ([]*Symbol, error)
|
||
UpsertKline(ctx context.Context, data QueryKline) error
|
||
ListKline(ctx context.Context, param QueryKline) ([]Candle, error)
|
||
}
|
||
|
||
// 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"` // 報價資產顯示的小數位數
|
||
}
|
||
|
||
type QueryKline struct {
|
||
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"`
|
||
}
|