features

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheL5KeyHistory = "cache/history"
)

Variables

This section is empty.

Functions

func BoolIndexOf

func BoolIndexOf(s stat.Series, n int) bool

func IndexReverse

func IndexReverse(s stat.Series) stat.Series

func SeriesChangeRate

func SeriesChangeRate(base, v stat.Series) stat.Series

SeriesChangeRate 计算两个序列的净增长

func SeriesIndexOf

func SeriesIndexOf(s stat.Series, n int) float64

SeriesIndexOf 获取序列第n索引的值

func StringIndexOf

func StringIndexOf(s stat.Series, n int) string

Types

type DataBuilder

type DataBuilder struct {
	Name          string // 名称
	CacheDate     string // 缓存文件日期
	ResourcesDate string // 源数据日期, 一般来说源数据日期要比缓存文件的日期早一个交易日
	Build         func(allCodes []string)
}

DataBuilder 数据构建器

func NewDataBuilder

func NewDataBuilder(name, date string, build func(allCodes []string)) *DataBuilder

func (*DataBuilder) Execute

func (this *DataBuilder) Execute(allCodes []string)

type DataCache

type DataCache struct {
	Date string // 日期
	Code string // 证券代码
	// contains filtered or unexported fields
}

type DataKLine

type DataKLine struct {
	DataCache
}

func (*DataKLine) Clone

func (k *DataKLine) Clone(date, code string) DataSet

func (*DataKLine) Filename

func (k *DataKLine) Filename(date, code string) string

func (*DataKLine) Increase

func (k *DataKLine) Increase(snapshot Snapshot)

func (*DataKLine) Key

func (k *DataKLine) Key() string

func (*DataKLine) Kind

func (k *DataKLine) Kind() FeatureKind

func (*DataKLine) Name

func (k *DataKLine) Name() string

func (*DataKLine) Repair

func (k *DataKLine) Repair(cacheDate, featureDate string)

func (*DataKLine) Update

func (k *DataKLine) Update(cacheDate, featureDate string)

type DataSet

type DataSet interface {
	Kind() FeatureKind                      // 类型
	Name() string                           // 特征名称
	Key() string                            // 缓存关键字
	Filename(date, code string) string      // 缓存文件名
	Update(cacheDate, featureDate string)   // 更新数据
	Repair(cacheDate, featureDate string)   // 回补数据
	Increase(snapshot Snapshot)             // 增量计算, 用快照增量计算特征
	Clone(date string, code string) DataSet // 克隆一个DataSet
}

DataSet 数据层, 数据集接口

type DataXdxr

type DataXdxr struct {
	DataCache
}

func (*DataXdxr) Clone

func (x *DataXdxr) Clone(date string, code string) DataSet

func (*DataXdxr) Filename

func (x *DataXdxr) Filename(date, code string) string

func (*DataXdxr) Increase

func (x *DataXdxr) Increase(snapshot Snapshot)

func (*DataXdxr) Key

func (x *DataXdxr) Key() string

func (*DataXdxr) Kind

func (x *DataXdxr) Kind() FeatureKind

func (*DataXdxr) Name

func (x *DataXdxr) Name() string

func (*DataXdxr) Repair

func (x *DataXdxr) Repair(cacheDate, featureDate string)

func (*DataXdxr) Update

func (x *DataXdxr) Update(cacheDate, featureDate string)

type Feature

type Feature interface {
	Factory(date string, code string) Feature // 工厂
	Kind() FeatureKind                        // 类型
	Name() string                             // 特征名称
	Key() string                              // 缓存关键字
	Init() error                              // 初始化, 加载配置信息
	GetDate() string                          //  日期
	GetSecurityCode() string                  // 证券代码
	FromHistory(history History) Feature      // 从历史数据加载
	Update(cacheDate, featureDate string)     // 更新数据
	Repair(cacheDate, featureDate string)     // 回补数据
	Increase(snapshot Snapshot)               // 增量计算, 用快照增量计算特征
}

Feature 特征

type FeatureCache

type FeatureCache struct {
	Type FeatureKind
	Key  string
	Name string
}

type FeatureKind

type FeatureKind = uint64
const (
	FeatureBaseKLine        FeatureKind = 1 << iota // 基础数据-基础K线
	FeatureBaseTransaction                          // 基础数据-历史成交
	FeatureBaseMinutes                              // 基础数据-分时数据
	FeatureHistory                                  // 历史特征数据
	FeatureF10                                      // 基本面
	FeatureKLineShap                                // K线形态等
	FeatureMovingAverage                            // 移动平均线
	FeatureBreaksThroughBox                         // 有效突破平台

)
const (
	FeatureBaseXdxr FeatureKind = 0 // 基础数据-除权除息
)

type History

type History struct {
	Date       string  // 日期, 数据落地的日期
	Code       string  // 代码
	MA3        float64 // 3日均价
	MV3        float64 // 3日均量
	MA5        float64 // 5日均价
	MV5        float64 // 5日均量
	MA10       float64 // 10日均价
	MV10       float64 // 10日均量
	MA20       float64 // 20日均价
	MV20       float64 // 20日均量
	QSFZ       bool    // QSFZ: 反转信号
	CP         float64 // QSFZ: 股价涨幅
	CV         float64 // QSFZ: 成交量涨幅
	VP         float64 // QSFZ: 价量比
	VP3        float64 // QSFZ: 3日价量比
	VP5        float64 // QSFZ: 5日价量比
	UpdateTime string  // 更新时间
}

History 历史整合数据

func NewHistory

func NewHistory(date, code string) *History

func (*History) Factory

func (h *History) Factory(date string, code string) Feature

func (*History) FromHistory

func (h *History) FromHistory(history History) Feature

func (*History) GetDate

func (h *History) GetDate() string

func (*History) GetSecurityCode

func (h *History) GetSecurityCode() string

func (*History) Increase

func (h *History) Increase(snapshot Snapshot)

func (*History) Init

func (h *History) Init() error

func (*History) Key

func (h *History) Key() string

func (*History) Kind

func (h *History) Kind() FeatureKind

func (*History) Name

func (h *History) Name() string

func (*History) Repair

func (h *History) Repair(cacheDate, featureDate string)

func (*History) Update

func (h *History) Update(cacheDate, featureDate string)

type QuShiFanZhuan

type QuShiFanZhuan struct {
	QSFZ bool    // 反转信号
	CP   float64 // 股价涨幅
	CV   float64 // 成交量涨幅
	VP   float64 // 价量比
	VP3  float64 // 3日价量比
	VP5  float64 // 5日价量比
}

QuShiFanZhuan 趋势反转

func (*QuShiFanZhuan) FromHistory

func (q *QuShiFanZhuan) FromHistory(history History) Feature

func (*QuShiFanZhuan) GetDate

func (q *QuShiFanZhuan) GetDate() string

func (*QuShiFanZhuan) GetSecurityCode

func (q *QuShiFanZhuan) GetSecurityCode() string

func (*QuShiFanZhuan) Increase

func (q *QuShiFanZhuan) Increase(snapshot Snapshot)

func (*QuShiFanZhuan) Init

func (q *QuShiFanZhuan) Init() error

func (*QuShiFanZhuan) Key

func (q *QuShiFanZhuan) Key() string

func (*QuShiFanZhuan) Kind

func (q *QuShiFanZhuan) Kind() FeatureKind

func (*QuShiFanZhuan) Name

func (q *QuShiFanZhuan) Name() string

func (*QuShiFanZhuan) Repair

func (q *QuShiFanZhuan) Repair(cacheDate, featureDate string)

func (*QuShiFanZhuan) Update

func (q *QuShiFanZhuan) Update(cacheDate, featureDate string)

type Snapshot

type Snapshot struct {
	Date       string // 日期
	Code       string // 证券代码
	UpdateTime string // 更新时间
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL