2 Star 14 Fork 16

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
flash.go 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-10 09:20 +08:00 . 调整插件模式的遍历方法
package flash
import (
"gitee.com/quant1x/engine/cache"
"gitee.com/quant1x/engine/cachel5"
"gitee.com/quant1x/engine/datasets"
"gitee.com/quant1x/engine/features"
"sync"
)
var (
__l5Once sync.Once
// 历史数据
__l5History *cachel5.Cache1D[*features.History] = nil
// 基本面F10
__l5F10 *cachel5.Cache1D[*features.F10] = nil
)
func init() {
__l5Once.Do(lazyInitFeatures)
}
func lazyInitFeatures() {
// 历史数据
__l5History = cachel5.NewCache1D[*features.History](features.CacheL5KeyHistory, features.NewHistory)
err := cache.Register(__l5History)
if err != nil {
panic(err)
}
// 基本面F10
__l5F10 = cachel5.NewCache1D[*features.F10](features.CacheL5KeyF10, features.NewF10)
err = cache.Register(__l5F10)
if err != nil {
panic(err)
}
}
// CacheList 缓存列表
func CacheList() []cachel5.CacheAdapter {
__l5Once.Do(lazyInitFeatures)
list := []cachel5.CacheAdapter{
__l5F10,
__l5History,
}
return list
}
func GetHistory() *cachel5.Cache1D[*features.History] {
__l5Once.Do(lazyInitFeatures)
return __l5History
}
func GetL5History(securityCode string, date ...string) *features.History {
__l5Once.Do(lazyInitFeatures)
data := __l5History.Get(securityCode, date...)
if data == nil {
return nil
}
return *data
}
func GetL5F10(securityCode string, date ...string) *features.F10 {
__l5Once.Do(lazyInitFeatures)
data := __l5F10.Get(securityCode, date...)
if data == nil {
return nil
}
return *data
}
var (
__dataSetOnce sync.Once
__dataSets []datasets.DataSet = nil
)
func lazyInitDataSets() {
__dataSets = []datasets.DataSet{
new(datasets.DataQuarterlyReport), // 季报
new(datasets.DataXdxr), // 除权除息
new(datasets.DataKLine), // 基础K线
//new(datasets.DataSafetyScore), // 安全分
}
}
// DataSetList 数据集 列表
func DataSetList() []datasets.DataSet {
__dataSetOnce.Do(lazyInitDataSets)
return __dataSets
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.1.7

搜索帮助