gitee.com/quant1x/engine@v1.8.4/factors/dataset.go (about) 1 package factors 2 3 import ( 4 "gitee.com/quant1x/engine/cache" 5 "gitee.com/quant1x/engine/config" 6 "gitee.com/quant1x/gotdx/quotes" 7 "gitee.com/quant1x/gox/logger" 8 ) 9 10 const ( 11 baseKind cache.Kind = 0 12 ) 13 14 const ( 15 BaseXdxr = cache.PluginMaskBaseData | (baseKind + 1) // 基础数据-除权除息 16 BaseKLine = cache.PluginMaskBaseData | (baseKind + 2) // 基础数据-基础K线 17 BaseTransaction = cache.PluginMaskBaseData | (baseKind + 3) // 基础数据-历史成交 18 BaseMinutes = cache.PluginMaskBaseData | (baseKind + 4) // 基础数据-分时数据 19 BaseQuarterlyReports = cache.PluginMaskBaseData | (baseKind + 5) // 基础数据-季报 20 BaseSafetyScore = cache.PluginMaskBaseData | (baseKind + 6) // 基础数据-安全分 21 BaseWideKLine = cache.PluginMaskBaseData | (baseKind + 7) // 基础数据-宽表 22 BasePerformanceForecast = cache.PluginMaskBaseData | (baseKind + 8) // 基础数据-业绩预告 23 ) 24 25 // DataSet 数据层, 数据集接口 smart 26 // 27 // 数据集是基础数据, 应当遵循结构简单, 尽量减小缓存的文件数量, 加载迅速 28 // 检索的规则是按日期和代码进行查询 29 type DataSet interface { 30 // Clone 克隆一个DataSet, 是所有写操作的基础 31 Clone(date string, code string) DataSet 32 cache.Manifest 33 // Update 更新数据 34 Update(date string) 35 // Repair 回补数据 36 Repair(date string) 37 // Increase 增量计算, 用快照增量计算特征 38 Increase(snapshot quotes.Snapshot) 39 } 40 41 var ( 42 // 数据集集合 43 __mapDataSets = map[cache.Kind]cache.DataSummary{ 44 BaseXdxr: cache.Summary(BaseXdxr, "xdxr", "除权除息", cache.DefaultDataProvider), 45 BaseKLine: cache.Summary(BaseKLine, "day", "日K线", cache.DefaultDataProvider), 46 BaseTransaction: cache.Summary(BaseTransaction, "trans", "成交数据", cache.DefaultDataProvider, "默认最早日期"+config.GetDataConfig().Trans.BeginDate), 47 BaseMinutes: cache.Summary(BaseMinutes, "minutes", "分时数据", cache.DefaultDataProvider), 48 BaseQuarterlyReports: cache.Summary(BaseQuarterlyReports, "reports", "季报", cache.DefaultDataProvider), 49 BaseSafetyScore: cache.Summary(BaseSafetyScore, "safetyscore", "安全分", cache.DefaultDataProvider), 50 BaseWideKLine: cache.Summary(BaseWideKLine, "wide", "宽表", cache.DefaultDataProvider), 51 BasePerformanceForecast: cache.Summary(BasePerformanceForecast, "forecast", "业绩预告", cache.DefaultDataProvider), 52 } 53 ) 54 55 func GetDataDescript(kind cache.Kind) cache.DataSummary { 56 v, ok := __mapDataSets[kind] 57 if !ok { 58 logger.Fatalf("类型不存在, name=%d", kind) 59 } 60 return v 61 } 62 63 type Manifest struct { 64 cache.DataSummary 65 Date string 66 Code string 67 } 68 69 func (m Manifest) GetDate() string { 70 return m.Date 71 } 72 73 func (m Manifest) GetSecurityCode() string { 74 return m.Code 75 }