candles

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultFilePerm = 0644
	DefaultDirPerm  = 0744
	DefaultDataDir  = "candles"
	DefaultExt      = ".bin"
	CandleByteSize  = 5 * 4 // 4 bytes for any field

)

Variables

This section is empty.

Functions

func SecToMilli

func SecToMilli(t uint32) int64

convert seconds to milliseconds

Types

type Candle

type Candle struct {
	HPrice float32
	LPrice float32
	CPrice float32
	Volume float32
	CTime  uint32
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func DefaultStorage

func DefaultStorage(symbol string) (*Storage, error)

Use an existing file with default path

func FileStorage

func FileStorage(path string) (*Storage, error)

Use an existin file from a path

func NewDefaultStorage

func NewDefaultStorage(symbol string) (*Storage, error)

Create new file with default path

func NewFileStorage

func NewFileStorage(path string) (*Storage, error)

Create a new file from a path

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) FirstCandleCloseTime

func (s *Storage) FirstCandleCloseTime() (int64, error)

return timestamp as milli seconds of the first candle

func (*Storage) LastCandleCloseTime

func (s *Storage) LastCandleCloseTime() (int64, error)

return timestamp as milli seconds of the last candle

func (*Storage) Read

func (s *Storage) Read(cs []Candle) (int, error)

Read bytes from the current data file and convert them to candles Returns the number of candle read and the error

func (*Storage) ReadAll added in v0.2.0

func (s *Storage) ReadAll() ([]Candle, error)

func (*Storage) ReadBack added in v0.2.0

func (s *Storage) ReadBack(cs []Candle) (int, error)

Read bytes from the end of the current data file and convert them to candles Returns the number of candle read and the error

func (*Storage) Save

func (s *Storage) Save(b []Candle) error

Convert candles to bytes and write them to a file to the data file

func (*Storage) SizeBytes

func (s *Storage) SizeBytes() (int64, error)

Returns length in bytes for the current data file

func (*Storage) SizeCandles

func (s *Storage) SizeCandles() (int64, error)

Returns length in candles for the current data file

Jump to

Keyboard shortcuts

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