cachel5

package
v0.1.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCacheLoader

func RegisterCacheLoader(key string, loader CacheAdapter)

func SwitchDate

func SwitchDate(date string)

Types

type Cache1D

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

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

func NewCache1D

func NewCache1D[T features.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]) Checkout

func (this *Cache1D[T]) Checkout(date ...string)

func (*Cache1D[T]) Factory

func (this *Cache1D[T]) Factory(date, securityCode string) features.Feature

func (*Cache1D[T]) Get

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

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

func (*Cache1D[T]) Init added in v0.1.7

func (this *Cache1D[T]) Init(barIndex *int, date string) error

func (*Cache1D[T]) Kind added in v0.1.7

func (this *Cache1D[T]) Kind() cache.Kind

func (*Cache1D[T]) Length

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

Length 获取长度

func (*Cache1D[T]) Merge

func (this *Cache1D[T]) Merge(p *treemap.Map)

func (*Cache1D[T]) Name

func (this *Cache1D[T]) Name() string

func (*Cache1D[T]) ReplaceCache

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

ReplaceCache 替换当前缓存数据

func (*Cache1D[T]) Set

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

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

type CacheAdapter

type CacheAdapter interface {
	// Name 名称
	Name() string
	// Checkout 加载指定日期的缓存
	Checkout(date ...string)
	// Merge 合并数据
	Merge(p *treemap.Map)
	// Factory 工厂
	Factory(date, securityCode string) features.Feature
}

CacheAdapter 缓存加载器

func Get

func Get(key string) CacheAdapter

Jump to

Keyboard shortcuts

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