buffer

package
v0.0.0-...-069e140 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) GetOrderbook

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

GetOrderbook use sparingly. Modifying anything here will ruin hash calculation and cause problems

func (*Orderbook) LoadSnapshot

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

LoadSnapshot loads initial snapshot of ob data, overwrite allows full ob to be completely rewritten because the exchange is a doing a full update not an incremental one

func (*Orderbook) Setup

func (w *Orderbook) Setup(obBufferLimit int, bufferEnabled, sortBuffer, sortBufferByUpdateIDs, updateEntriesByID bool, exchangeName string, dataHandler chan interface{})

Setup sets private variables

func (*Orderbook) Update

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

Update updates a local buffer using bid targets and ask targets then updates main orderbook Volume == 0; deletion at price target Price target not found; append of price target Price target found; amend volume of price target

type Update

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

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