models

package
v4.1.23 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TradeSuffix    string = "TRADE"
	TradeTimeframe string = "1Sec"
)

Variables

Functions

func BarBucketKey

func BarBucketKey(symbol, timeframe string) string

BarBucketKey returns a string bucket key for a given symbol and timeframe.

func QuoteBucketKey

func QuoteBucketKey(symbol string) string

BarBucketKey returns a string bucket key for a given symbol and timeframe.

func TradeBucketKey

func TradeBucketKey(symbol string) string

TradeBucketKey returns a string bucket key for a given symbol and timeframe.

Types

type Bar

type Bar struct {
	Tbk                    *io.TimeBucketKey
	Csm                    io.ColumnSeriesMap
	Epoch                  []int64
	Open, High, Low, Close []enum.Price
	Volume                 []enum.Size
	WriteTime              time.Duration
}

Bar is a data model to persist arrays of Ask-Bid quotes.

func FromTrades

func FromTrades(trades *Trade, symbol, timeframe string) (*Bar, error)

func NewBar

func NewBar(symbol, timeframe string, capacity int) *Bar

NewBar creates a new Bar object and initializes it's internal column buffers to the given capacity.

func (*Bar) Add

func (model *Bar) Add(epoch int64, open, high, low, clos enum.Price, volume enum.Size)

Add adds a new data point to the internal buffers, and increment the internal index by one.

func (*Bar) BuildCsm

func (model *Bar) BuildCsm() *io.ColumnSeriesMap

BuildCsm prepares an io.ColumnSeriesMap object and populates it's columns with the contents of the internal buffers it is included in the .Write() method so use only when you need to work with the ColumnSeriesMap before writing it to disk.

func (*Bar) GetCs

func (model *Bar) GetCs() *io.ColumnSeries

func (*Bar) Key

func (model *Bar) Key() string

Key returns the key of the model's time bucket.

func (*Bar) Len

func (model *Bar) Len() int

Len returns the length of the internal column buffers.

func (*Bar) Symbol

func (model *Bar) Symbol() string

Symbol returns the Symbol part if the TimeBucketKey of this model.

func (*Bar) Write

func (model *Bar) Write() error

Write persist the internal buffers to disk.

type ConsolidatedUpdateInfo

type ConsolidatedUpdateInfo struct {
	UpdateHighLow bool
	UpdateLast    bool
	UpdateVolume  bool
}

type Quote

type Quote struct {
	Tbk         *io.TimeBucketKey
	Epoch       []int64
	Nanos       []int32
	BidPrice    []float64
	AskPrice    []float64
	BidSize     []uint64
	AskSize     []uint64
	BidExchange []byte
	AskExchange []byte
	Cond        []byte

	WriteTime time.Duration
	// contains filtered or unexported fields
}

Quote defines schema and helper functions for storing Ask-Bid quote data.

func NewQuote

func NewQuote(symbol string, length int) *Quote

NewBar creates a new Bar object and initializes it's internal column buffers to the given length.

func (*Quote) Add

func (model *Quote) Add(epoch int64, nanos int, bidPrice, askPrice float64,
	bidSize, askSize int, bidExchange, askExchange enum.Exchange, cond enum.QuoteCondition,
)

Add adds a new data point to the internal buffers, and increment the internal index by one.

func (*Quote) BuildCsm

func (model *Quote) BuildCsm() *io.ColumnSeriesMap

BuildCsm prepares an io.ColumnSeriesMap object and populates it's columns with the contents of the internal buffers it is included in the .Write() method so use only when you need to work with the ColumnSeriesMap before writing it to disk.

func (*Quote) Key

func (model *Quote) Key() string

Key returns the key of the model's time bucket.

func (*Quote) Len

func (model *Quote) Len() int

Len returns the length of the internal column buffers.

func (*Quote) SetLimit

func (model *Quote) SetLimit(limit int)

SetLimit sets a limit on how many entries are actually used when .Write() is called It is useful if the model's buffers populated through the exported buffers directly (Open[i], Close[i], etc) and the actual amount of inserted data is less than the initially specified length parameter.

func (*Quote) Symbol

func (model *Quote) Symbol() string

Symbol returns the Symbol part if the TimeBucketKey of this model.

func (*Quote) Write

func (model *Quote) Write() error

Write persist the internal buffers to disk.

type Trade

type Trade struct {
	Tbk      *io.TimeBucketKey
	Epoch    []int64
	Nanos    []int32
	Price    []enum.Price
	Size     []enum.Size
	Exchange []enum.Exchange
	TapeID   []enum.Tape
	Cond1    []enum.TradeCondition
	Cond2    []enum.TradeCondition
	Cond3    []enum.TradeCondition
	Cond4    []enum.TradeCondition

	WriteTime time.Duration
}

Trade defines schema and helper functions for storing trade data.

func NewTrade

func NewTrade(symbol string, capacity int) *Trade

NewTrade creates a new Trade object and initializes it's internal column buffers to the given capacity.

func (*Trade) Add

func (model *Trade) Add(epoch int64, nanos int, price enum.Price, size enum.Size,
	exchange enum.Exchange, tapeid enum.Tape, conditions ...enum.TradeCondition,
)

Add adds a new data point to the internal buffers, and increment the internal index by one.

func (*Trade) GetCs

func (model *Trade) GetCs() *io.ColumnSeries

func (*Trade) Key

func (model *Trade) Key() string

Key returns the key of the model's time bucket.

func (*Trade) Len

func (model *Trade) Len() int

Len returns the length of the internal column buffers.

func (*Trade) Symbol

func (model *Trade) Symbol() string

Symbol returns the Symbol part if the TimeBucketKey of this model.

func (*Trade) Write

func (model *Trade) Write() error

Write persist the internal buffers to disk.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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