page

package
v0.0.0-...-be256ff Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BLOCK_WIDTH int = 48
View Source
const HEADER_SIZE int = 60
View Source
const INDEX_COUNT int = INDEX_ROW_COUNT * (BLOCK_WIDTH / 4)

12 columns, 31 rows of uint32

View Source
const INDEX_ROW_COUNT int = 31
View Source
const MAX_CODE_LENGTH int = 18
View Source
const MAX_MARKET_CODE_LENGTH int = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type CandleSet

type CandleSet struct {
	CandleSetWithoutYear
	Year uint16
}

func (CandleSet) IsZero

func (p CandleSet) IsZero() bool

func (CandleSet) UniqueKey

func (p CandleSet) UniqueKey() string

type CandleSetWithoutYear

type CandleSetWithoutYear struct {
	MarketCode   string
	Code         string
	CandleLength uint32
}

type Page

type Page struct {
	Header PageHeader
	Body   PageBodyBlockList
}

func NewPage

func NewPage(set CandleSet) Page

func (*Page) Add

func (p *Page) Add(candles common.CandleList) error

func (*Page) Copy

func (p *Page) Copy() Page

func (Page) IsZero

func (p Page) IsZero() bool

func (*Page) Read

func (p *Page) Read(_ uint32, r io.Reader) error

func (Page) UniqueKey

func (p Page) UniqueKey() string

type PageBodyBlock

type PageBodyBlock struct {
	Timestamp       uint64
	TimestampOffset uint32

	BitFields uint32
	Open      float64
	High      float64
	Low       float64
	Close     float64
	Volume    float64
}

func NewPageBodyBlock

func NewPageBodyBlock(year uint16, candle common.Candle) PageBodyBlock

func (*PageBodyBlock) Read

func (p *PageBodyBlock) Read(_ uint32, r io.Reader) error

func (*PageBodyBlock) SetYear

func (p *PageBodyBlock) SetYear(year uint16)

func (*PageBodyBlock) Write

func (p *PageBodyBlock) Write(w io.Writer) (err error)

type PageBodyBlockList

type PageBodyBlockList []PageBodyBlock

func NewPageBodyBlockList

func NewPageBodyBlockList(year uint16, candles []common.Candle) PageBodyBlockList

func (PageBodyBlockList) CreateIndex

func (c PageBodyBlockList) CreateIndex() (PageIndex, error)

func (PageBodyBlockList) Len

func (c PageBodyBlockList) Len() int

func (PageBodyBlockList) Less

func (c PageBodyBlockList) Less(i, j int) bool

func (*PageBodyBlockList) Read

func (p *PageBodyBlockList) Read(count uint32, r io.Reader) error

func (PageBodyBlockList) Swap

func (c PageBodyBlockList) Swap(i, j int)

func (*PageBodyBlockList) Write

func (c *PageBodyBlockList) Write(w io.Writer) error
type PageHeader struct {
	LastTxId     uint64
	MarketCode   string
	Year         uint16
	CandleLength uint32
	Count        uint32
	StartOffset  uint32
	EndOffset    uint32
	Code         string
	Index        PageIndex
}

func (PageHeader) CalculateTimestampOffset

func (p PageHeader) CalculateTimestampOffset(ts int64) (offset uint32, inRange bool)

func (PageHeader) GetFirstTime

func (p PageHeader) GetFirstTime() time.Time

func (PageHeader) GetFirstTimestamp

func (p PageHeader) GetFirstTimestamp() int64

func (PageHeader) GetLastTime

func (p PageHeader) GetLastTime() time.Time

func (PageHeader) GetLastTimestamp

func (p PageHeader) GetLastTimestamp() int64

func (PageHeader) IsZero

func (p PageHeader) IsZero() bool

func (*PageHeader) Read

func (p *PageHeader) Read(size uint32, r io.Reader) error

func (PageHeader) TimestampInPageRange

func (p PageHeader) TimestampInPageRange(ts int64) bool

Utility methods

func (PageHeader) ToCandleSet

func (p PageHeader) ToCandleSet() CandleSet

func (*PageHeader) Write

func (p *PageHeader) Write(w io.Writer) error

type PageIndex

type PageIndex []uint32

func (PageIndex) ApplyDailyCount

func (p PageIndex) ApplyDailyCount(dailyCount PageIndex)

Jump to

Keyboard shortcuts

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