buffer

package
v0.0.0-...-83dca6d Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action defines a set of differing states required to implement an incoming orderbook update used in conjunction with UpdateEntriesByID

const (
	// Amend applies amount adjustment by ID
	Amend Action = "update"
	// Delete removes price level from book by ID
	Delete Action = "delete"
	// Insert adds price level to book
	Insert Action = "insert"
	// UpdateInsert on conflict applies amount adjustment or appends new amount
	// to book
	UpdateInsert Action = "update/insert"
)

type Orderbook

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

Orderbook defines a local cache of orderbooks for amending, appending and deleting changes and updates the main store for a stream

func (*Orderbook) FlushBuffer

func (w *Orderbook) FlushBuffer()

FlushBuffer flushes w.ob data to be garbage collected and refreshed when a connection is lost and reconnected

func (*Orderbook) FlushOrderbook

func (w *Orderbook) FlushOrderbook(p currency.Pair, a asset.Item) error

FlushOrderbook flushes independent orderbook

func (*Orderbook) GetOrderbook

func (w *Orderbook) GetOrderbook(p currency.Pair, a asset.Item) (*orderbook.Base, error)

GetOrderbook returns an orderbook copy as orderbook.Base

func (*Orderbook) LoadSnapshot

func (w *Orderbook) LoadSnapshot(book *orderbook.Base) error

LoadSnapshot loads initial snapshot of orderbook data from websocket

func (*Orderbook) Setup

func (w *Orderbook) Setup(cfg *config.Exchange, sortBuffer, sortBufferByUpdateIDs, updateEntriesByID bool, dataHandler chan interface{}) error

Setup sets private variables

func (*Orderbook) Update

func (w *Orderbook) Update(u *Update) error

Update updates a stored pointer to an orderbook.Depth struct containing a linked list, this switches between the usage of a buffered update

type Update

type Update struct {
	UpdateID   int64 // Used when no time is provided
	UpdateTime time.Time
	Asset      asset.Item
	Action
	Bids []orderbook.Item
	Asks []orderbook.Item
	Pair currency.Pair

	// Determines if there is a max depth of orderbooks and after an append we
	// should remove any items that are outside of this scope. Kraken is the
	// only exchange utilising this field.
	MaxDepth int
}

Update stores orderbook updates and dictates what features to use when processing

Jump to

Keyboard shortcuts

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