cachel5

package
v1.12.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCanReadDate added in v1.12.0

func DefaultCanReadDate() string

DefaultCanReadDate 获取默认可以读缓存文件的日期

func DefaultCanUpdateDate added in v1.12.0

func DefaultCanUpdateDate() string

DefaultCanUpdateDate 获取默认可以更新缓存文件的日期

func RegisterCacheLoader added in v1.12.0

func RegisterCacheLoader(key string, loader CacheLoader)

func SwitchDate added in v1.12.0

func SwitchDate(date string)

Types

type Cache1D

type Cache1D[T Feature] struct {
	Key  string // 缓存关键字
	Date string // 日期
	// contains filtered or unexported fields
}

Cache1D 每天1个证券代码1条数据

func NewCache1D

func NewCache1D[T Feature](key string, factory func(date, securityCode string) T) *Cache1D[T]

NewCache1D 创建一个新的C1D对象

key支持多级相对路径, 比如a/b, 创建的路径是~/.quant1x/a/b.yyyy-mm-dd

func (*Cache1D[T]) Apply

func (this *Cache1D[T]) Apply(merge func(code string, local *T) (updated bool))

Apply 数据合并

泛型T需要保持一个string类型的Date字段

func (*Cache1D[T]) Get

func (this *Cache1D[T]) Get(securityCode string, date ...string) *T

Get 获取指定证券代码的数据

func (*Cache1D[T]) Length added in v1.9.3

func (this *Cache1D[T]) Length() int

Length 获取长度

func (*Cache1D[T]) LoadCache

func (this *Cache1D[T]) LoadCache(date string)

LoadCache 加载指定日期的数据

func (*Cache1D[T]) ReplaceCache

func (this *Cache1D[T]) ReplaceCache()

ReplaceCache 替换当前缓存数据

func (*Cache1D[T]) Set

func (this *Cache1D[T]) Set(securityCode string, newValue T)

Set 更新map中指定证券代码的数据

type CacheLoader added in v1.12.0

type CacheLoader interface {
	// LoadCache 加载指定日期的缓存
	LoadCache(date string)
}

CacheLoader 缓存加载器

type Feature

type Feature interface {
	GetDate() string
	GetSecurityCode() string
}

Feature 特征, 因子Factor

Jump to

Keyboard shortcuts

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