You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.6 KiB
76 lines
1.6 KiB
package adapter
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// DataSourceAdapter 数据源适配器接口
|
|
type DataSourceAdapter interface {
|
|
// Connect 建立连接
|
|
Connect(config map[string]string) error
|
|
|
|
// SubscribeTicks 订阅实时Tick
|
|
SubscribeTicks(symbols []string, callback TickCallback) error
|
|
|
|
// FetchKLines 拉取历史K线
|
|
FetchKLines(symbol, start, end, freq string) ([]KLineData, error)
|
|
|
|
// FetchSymbols 获取标的列表
|
|
FetchSymbols(assetType string) ([]SymbolInfo, error)
|
|
|
|
// FetchTradingCalendar 获取交易日历
|
|
FetchTradingCalendar(exchange, start, end string) ([]TradeCalData, error)
|
|
|
|
// HealthCheck 健康检查
|
|
HealthCheck() error
|
|
|
|
// Close 关闭连接
|
|
Close() error
|
|
}
|
|
|
|
// TickCallback Tick数据回调
|
|
type TickCallback func(symbol string, tick TickData)
|
|
|
|
// TickData Tick数据
|
|
type TickData struct {
|
|
Symbol string
|
|
Price float64
|
|
Volume int64
|
|
Time int64
|
|
}
|
|
|
|
// KLineData K线数据
|
|
type KLineData struct {
|
|
Symbol string
|
|
Time int64
|
|
Open float64
|
|
High float64
|
|
Low float64
|
|
Close float64
|
|
Volume int64
|
|
Amount float64
|
|
OpenInterest int64
|
|
}
|
|
|
|
// SymbolInfo 标的信息
|
|
type SymbolInfo struct {
|
|
SymbolID string
|
|
Name string
|
|
Exchange string
|
|
Underlying string
|
|
ContractMonth string
|
|
ListDate string
|
|
DelistDate string
|
|
}
|
|
|
|
// TradeCalData 交易日历数据
|
|
type TradeCalData struct {
|
|
Date time.Time
|
|
IsTradingDay bool
|
|
HasNightSession bool
|
|
}
|
|
|
|
// AdapterFactory 适配器工厂
|
|
type AdapterFactory interface {
|
|
Create(name string) (DataSourceAdapter, error)
|
|
} |