book

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromWSRaw

func FromWSRaw(symbol, precision string, data []interface{}) (interface{}, error)

FromWSRaw - based on condition will return snapshot of books or single book

func IsRawBook

func IsRawBook(precision string) bool

Types

type Book

type Book struct {
	Symbol      string // book symbol
	ID          int64  // the book update ID, optional
	Count       int64  // updated count, optional
	Period      int64
	Price       float64 // updated price
	Amount      float64 // updated amount
	Rate        float64
	PriceJsNum  json.Number      // update price as json.Number
	AmountJsNum json.Number      // update amount as json.Number
	Side        common.OrderSide // side
	Action      BookAction       // action (add/remove)
}

Book represents an order book price update.

func FromRaw

func FromRaw(symbol, precision string, raw []interface{}, rawNumbers interface{}) (b *Book, err error)

FromRaw creates a new book object from raw data. Precision determines how to interpret the side (baked into Count versus Amount) raw book updates [ID, price, qty], aggregated book updates [price, amount, count]

type BookAction

type BookAction byte

BookAction represents a new/update or removal for a book entry.

const (
	//BookEntry represents a new or updated book entry.
	BookEntry BookAction = 0
	//BookRemoveEntry represents a removal of a book entry.
	BookRemoveEntry BookAction = 1
)

type Snapshot

type Snapshot struct {
	Snapshot []*Book
}

func SnapshotFromRaw

func SnapshotFromRaw(symbol, precision string, raw [][]interface{}, rawNumbers interface{}) (*Snapshot, error)

Jump to

Keyboard shortcuts

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