2 Star 7 Fork 10

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
aggregation.go 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2023-10-17 11:11 . 调整代码结构
package smart
import (
"gitee.com/quant1x/engine/cache"
"gitee.com/quant1x/engine/cachel5"
"gitee.com/quant1x/engine/factors"
"sync"
)
var (
__l5Once sync.Once
// 历史数据
__l5History *cachel5.Cache1D[*factors.History] = nil
// 基本面F10
__l5F10 *cachel5.Cache1D[*factors.F10] = nil
)
func init() {
__l5Once.Do(lazyInitFeatures)
}
func lazyInitFeatures() {
// 历史数据
__l5History = cachel5.NewCache1D[*factors.History](factors.CacheL5KeyHistory, factors.NewHistory)
err := cache.Register(__l5History)
if err != nil {
panic(err)
}
// 基本面F10
__l5F10 = cachel5.NewCache1D[*factors.F10](factors.CacheL5KeyF10, factors.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 CacheHistory() *cachel5.Cache1D[*factors.History] {
__l5Once.Do(lazyInitFeatures)
return __l5History
}
func GetL5History(securityCode string, date ...string) *factors.History {
__l5Once.Do(lazyInitFeatures)
data := __l5History.Get(securityCode, date...)
if data == nil {
return nil
}
return *data
}
func CacheF10() *cachel5.Cache1D[*factors.F10] {
__l5Once.Do(lazyInitFeatures)
return __l5F10
}
func GetL5F10(securityCode string, date ...string) *factors.F10 {
__l5Once.Do(lazyInitFeatures)
data := __l5F10.Get(securityCode, date...)
if data == nil {
return nil
}
return *data
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v0.3.6

搜索帮助