cachel5

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CorrectDate

func CorrectDate(date string) (cacheDate, resourcesDate string)

CorrectDate 校正日期

func DefaultCanReadDate

func DefaultCanReadDate() string

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

func DefaultCanUpdateDate

func DefaultCanUpdateDate() string

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

func RegisterCacheLoader

func RegisterCacheLoader(key string, loader CacheLoader)

func SwitchDate

func SwitchDate(date string)

Types

type Cache1D

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

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

func NewCache1D

func NewCache1D[T CacheFeature](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

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 CacheFeature

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

CacheFeature 特征

type CacheLoader

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

CacheLoader 缓存加载器

Jump to

Keyboard shortcuts

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