orderbook

package
v0.0.0-...-a7768ee Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PriceLevelComparator

func PriceLevelComparator(a, b interface{}) int

PriceLevelComparator .

Types

type Depth

type Depth struct {
	Symbol string
	Scale  int64
	Bids   *rbt.Tree
	Asks   *rbt.Tree
}

Depth .

func NewDepth

func NewDepth(symbol string, scale int64) *Depth

NewDepth returns a depth with specific scale.

func (*Depth) Serialize

func (d *Depth) Serialize() *oceanbookpb.Depth

Serialize returns a protobuf encoded depth.

func (*Depth) UpdatePriceLevel

func (d *Depth) UpdatePriceLevel(pl *PriceLevel)

UpdatePriceLevel updates depth with price level.

type OrderBook

type OrderBook struct {
	sync.RWMutex
	Symbol string
	Price  decimal.Decimal

	Bids     *rbt.Tree
	Asks     *rbt.Tree
	StopBids *rbt.Tree
	StopAsks *rbt.Tree
	// contains filtered or unexported fields
}

OrderBook is the order book.

func NewOrderBook

func NewOrderBook(symbol string) *OrderBook

NewOrderBook returns a pointer to an orderbook.

func (*OrderBook) CancelOrder

func (od *OrderBook) CancelOrder(o *order.Order)

CancelOrder removes order with specified id.

func (*OrderBook) GetDepth

func (od *OrderBook) GetDepth() *Depth

GetDepth returns the order book depth.

func (*OrderBook) InsertOrder

func (od *OrderBook) InsertOrder(newOrder *order.Order) []*trade.Trade

InsertOrder inserts new order into orderbook.

func (*OrderBook) String

func (od *OrderBook) String() string

type PriceLevel

type PriceLevel struct {
	Price    decimal.Decimal
	Quantity decimal.Decimal
	Side     order.Side
	Count    uint64
}

PriceLevel .

func (*PriceLevel) Key

func (pl *PriceLevel) Key() *PriceLevelKey

Key returns a key for PriceLevel.

func (*PriceLevel) Serialize

func (p *PriceLevel) Serialize() *oceanbookpb.PriceLevel

Serialize .

type PriceLevelKey

type PriceLevelKey struct {
	Price decimal.Decimal
	Side  order.Side
}

PriceLevelKey .

Jump to

Keyboard shortcuts

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