2 Star 5 Fork 10

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dataset.go 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-12 14:25 . 调整子命令的检索逻辑
package datasets
import (
"gitee.com/quant1x/engine/cache"
"gitee.com/quant1x/gotdx/quotes"
)
type DataKind = uint64
const (
baseKind DataKind = 0
)
const (
BaseXdxr DataKind = cache.PluginMaskBaseData | (baseKind + 1) // 基础数据-除权除息
BaseKLine DataKind = cache.PluginMaskBaseData | (baseKind + 2) // 基础数据-基础K线
BaseTransaction DataKind = cache.PluginMaskBaseData | (baseKind + 3) // 基础数据-历史成交
BaseMinutes DataKind = cache.PluginMaskBaseData | (baseKind + 4) // 基础数据-分时数据
BaseQuarterlyReports DataKind = cache.PluginMaskBaseData | (baseKind + 5) // 基础数据-季报
BaseSafetyScore DataKind = cache.PluginMaskBaseData | (baseKind + 6) // 基础数据-安全分
BaseAggregationData DataKind = 1 << 63
BaseTest DataKind = 0x8000000000000000
)
// DataSet 数据层, 数据集接口 smart
type DataSet interface {
Kind() DataKind // 类型
Name() string // 特征名称
Key() string // 缓存关键字
Init(barIndex *int, date string) error // 初始化, 加载配置信息
Filename(date, code string) string // 缓存文件名
Update(cacheDate, featureDate string) // 更新数据
Repair(cacheDate, featureDate string) // 回补数据
Increase(snapshot quotes.Snapshot) // 增量计算, 用快照增量计算特征
Clone(date string, code string) DataSet // 克隆一个DataSet
}
// DataCache 基础的数据缓存
type DataCache struct {
Date string // 日期
Code string // 证券代码
filename string // 文件名
}
type DataSetSummary struct {
Type DataKind
Key string
Name string
}
var (
mapDataSets = map[DataKind]DataSetSummary{
BaseXdxr: {Type: BaseXdxr, Key: "xdxr", Name: "除权除息"},
BaseKLine: {Type: BaseKLine, Key: "day", Name: "日K线"},
BaseTransaction: {Type: BaseTransaction, Key: "trans", Name: "成交数据"},
BaseMinutes: {Type: BaseMinutes, Key: "minutes", Name: "分时数据"},
BaseQuarterlyReports: {Type: BaseQuarterlyReports, Key: "reports", Name: "季报"},
BaseSafetyScore: {Type: BaseSafetyScore, Key: "safescore", Name: "安全分"},
}
)
func GetDataDescript(kind DataKind) DataSetSummary {
v, ok := mapDataSets[kind]
if !ok {
panic("类型不存在")
}
return v
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.2.8

搜索帮助