gitee.com/quant1x/engine@v1.8.4/factors/feature.go (about)

     1  package factors
     2  
     3  import (
     4  	"errors"
     5  	"gitee.com/quant1x/engine/cache"
     6  )
     7  
     8  const (
     9  	InvalidPeriod = -1              // 无效的周期
    10  	InvalidWeight = float64(-99.99) // 无效的权重值
    11  )
    12  
    13  // Trait 基础的特性
    14  //
    15  //	这也是一个特征, 为啥起这个名字, 自己可以脑补 哈哈~
    16  type Trait interface {
    17  	// FromHistory 从历史数据加载
    18  	FromHistory(history History) Feature
    19  	// Increase 增量计算
    20  	//	用快照增量计算特征
    21  	Increase(snapshot QuoteSnapshot) Feature
    22  	// ValidateSample 验证样本
    23  	ValidateSample() error
    24  }
    25  
    26  // Feature 特征
    27  type Feature interface {
    28  	cache.Manifest
    29  	cache.Future
    30  	// Factory 工厂
    31  	Factory(date string, code string) Feature
    32  	Trait
    33  }
    34  
    35  // Weight 权重数据类型为64, 实际容纳63个
    36  type Weight = uint64
    37  
    38  const (
    39  	baseFeature cache.Kind = cache.PluginMaskFeature // 特征类型基础编码
    40  )
    41  
    42  // 登记所有的特征数据
    43  const (
    44  	FeatureF10                       = baseFeature + 1 // 特征数据-基本面
    45  	FeatureHistory                   = baseFeature + 2 // 特征数据-历史
    46  	FeatureNo1                       = baseFeature + 3 // 特征数据-1号策略
    47  	FeatureMisc                      = baseFeature + 4 // 特征数据-Misc
    48  	FeatureBreaksThroughBox          = baseFeature + 5 // 特征数据-box
    49  	FeatureKLineShap                 = baseFeature + 6 // 特征数据-K线形态等
    50  	FeatureInvestmentSentimentMaster = baseFeature + 7 // 狩猎者-情绪周期
    51  )
    52  
    53  var (
    54  	__mapFeatures = map[cache.Kind]cache.DataSummary{
    55  		FeatureF10:                       cache.Summary(FeatureF10, cacheL5KeyF10, "基本面", cache.DefaultDataProvider),
    56  		FeatureHistory:                   cache.Summary(FeatureHistory, cacheL5KeyHistory, "历史数据", cache.DefaultDataProvider),
    57  		FeatureMisc:                      cache.Summary(FeatureMisc, cacheL5KeyMisc, "交易数据集合", cache.DefaultDataProvider),
    58  		FeatureBreaksThroughBox:          cache.Summary(FeatureBreaksThroughBox, cacheL5KeyBox, "有效突破平台", cache.DefaultDataProvider),
    59  		FeatureInvestmentSentimentMaster: cache.Summary(FeatureInvestmentSentimentMaster, cacheL5KeyInvestmentSentimentMaster, "情绪大师", cache.DefaultDataProvider),
    60  	}
    61  )
    62  
    63  var (
    64  	ErrInvalidFeatureSample = errors.New("无效的特征数据样本")
    65  )