datasource

package
v0.0.0-...-c68f7f2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_FILE_DAMAGED = errors.New("file damaged")
)

Functions

func MergeData

func MergeData(destData []Record, sourceData []Record, multiplier int) []Record

Types

type BaseDataSource

type BaseDataSource interface {
	GetData(security *Security, period Period) (error, []Record)
	GetDataEx(security *Security, period Period, startDate uint64, count int) (error, []Record)

	GetRangeData(security *Security, period Period, startDate, endDate uint64) (error, []Record)
	GetDataFromLast(security *Security, period Period, endDate uint64, count int) (error, []Record)
	GetLastRecord(security *Security, period Period) (error, *Record)

	AppendData(security *Security, period Period, data []Record) error // Append data
	SaveData(security *Security, period Period, data []Record) error   // Replace data with new data

	RemoveData(security *Security, period Period, startDate, endDate uint64) error
}

endDate: inclusive

type CompositeDataSource

type CompositeDataSource interface {
	BaseDataSource
	AddSubDatasource(ds BaseDataSource)
}

type Converter

type Converter interface {
	Convert(sourceData []Record) []Record
}

func NewForwardAdjustConverter

func NewForwardAdjustConverter(period Period, items []InfoExItem) Converter

func NewPeriodConverter

func NewPeriodConverter(srcPeriod Period, destPeriod Period) Converter

type DataSource

type DataSource interface {
	InfoExDataSource
	BaseDataSource

	// market - 市场代码, sz-深交所, sh-上交所
	GetStockCodes(exchange string) []string
	GetStockNameHistory(security *Security) []StockNameItem
	GetStockName(security *Security) string
	GetStockNames() map[string]string

	Reset()

	SupportedPeriods() []Period

	GetForwardAdjustedData(security *Security, period Period) (error, []Record)
	GetForwardAdjustedRangeData(security *Security, period Period, startDate, endDate uint64) (error, []Record)
	GetForwardAdjustedDataFromLast(security *Security, period Period, endDate uint64, count int) (error, []Record)

	AppendRawData(security *Security, period Period, data []byte) error // Append raw data

	// Remove data which date is greater or equal to date
	TruncateTo(security *Security, period Period, date uint64) error
}

type DateRange

type DateRange struct {
	Security  *Security
	StartDate uint64 // inclusive, 0 if no start date
	EndDate   uint64 // exclusive, 0 if no end date
}

type DateRangeMapper

type DateRangeMapper interface {
	MapDateRanges(security *Security) []DateRange
}

type InfoExDataSource

type InfoExDataSource interface {
	GetStockInfoEx(security *Security) (error, []InfoExItem)
	SetInfoEx(infoEx map[string][]InfoExItem) error
}

type MappedDataSource

type MappedDataSource interface {
	BaseDataSource
	SetMapper(mapper DateRangeMapper)
	SetTargetDataSource(ds BaseDataSource)
}

type RecordMarshaller

type RecordMarshaller interface {
	ToBytes(record *Record) ([]byte, error)
	FromBytes(bytes []byte, record *Record) error
}

type RecordReader

type RecordReader interface {
	Read(start, end int) (error, []Record)
	Count() (error, int)
}

func NewRecordReader

func NewRecordReader(file *os.File, recordSize int, marshaller RecordMarshaller) RecordReader

type RecordWriter

type RecordWriter interface {
	Write(from int, data []Record) error
	WriteRaw(from int, data []byte) error
}

func NewRecordWriter

func NewRecordWriter(file *os.File, recordSize int, marshaller RecordMarshaller) RecordWriter

type StockNameItem

type StockNameItem struct {
	Date uint32
	Name string
}

type TickDataSource

type TickDataSource interface {
	Save(security *Security, ticks []TickItem) error
	Get(security *Security, startTs, endTs uint64) (error, []TickItem)
	Remove(security *Security, startTs, endTs uint64) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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