orderbook

package
v0.0.0-...-82616d5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByBestAsk

type ByBestAsk struct{ Limits }

func (ByBestAsk) Len

func (a ByBestAsk) Len() int

func (ByBestAsk) Less

func (a ByBestAsk) Less(i, j int) bool

func (ByBestAsk) Swap

func (a ByBestAsk) Swap(i, j int)

type ByBestBid

type ByBestBid struct{ Limits }

func (ByBestBid) Len

func (b ByBestBid) Len() int

func (ByBestBid) Less

func (b ByBestBid) Less(i, j int) bool

func (ByBestBid) Swap

func (b ByBestBid) Swap(i, j int)

type Limit

type Limit struct {
	Price       float64
	Orders      Orders
	TotalVolume float64
}

func NewLimit

func NewLimit(price float64) *Limit

func (*Limit) AddOrder

func (l *Limit) AddOrder(o *Order)

func (*Limit) DeleteOrder

func (l *Limit) DeleteOrder(o *Order)

func (*Limit) Fill

func (l *Limit) Fill(o *Order) []Match

func (*Limit) String

func (l *Limit) String() string

type Limits

type Limits []*Limit

type Match

type Match struct {
	Ask        *Order
	Bid        *Order
	SizeFilled float64
	Price      float64
}

type Order

type Order struct {
	ID        int64
	UserID    int64
	Size      float64
	Bid       bool
	Limit     *Limit
	Timestamp int64
}

func NewOrder

func NewOrder(bid bool, size float64, userID int64) *Order

func (*Order) IsFilled

func (o *Order) IsFilled() bool

func (*Order) String

func (o *Order) String() string

func (*Order) Type

func (o *Order) Type() string

type Orderbook

type Orderbook struct {
	Trade []*Trade

	AskLimits map[float64]*Limit
	BidLimits map[float64]*Limit
	Orders    map[int64]*Order
	// contains filtered or unexported fields
}

func NewOrderbook

func NewOrderbook() *Orderbook

func (*Orderbook) AskTotalVolume

func (ob *Orderbook) AskTotalVolume() float64

func (*Orderbook) Asks

func (ob *Orderbook) Asks() []*Limit

func (*Orderbook) BidTotalVolume

func (ob *Orderbook) BidTotalVolume() float64

func (*Orderbook) Bids

func (ob *Orderbook) Bids() []*Limit

func (*Orderbook) CancelOrder

func (ob *Orderbook) CancelOrder(o *Order)

func (*Orderbook) PlaceLimitOrder

func (ob *Orderbook) PlaceLimitOrder(price float64, o *Order)

func (*Orderbook) PlaceMarketOrder

func (ob *Orderbook) PlaceMarketOrder(o *Order) []Match

type Orders

type Orders []*Order

func (Orders) Len

func (o Orders) Len() int

func (Orders) Less

func (o Orders) Less(i, j int) bool

func (Orders) Swap

func (o Orders) Swap(i, j int)

type Trade

type Trade struct {
	Price     float64
	Size      float64
	Bid       bool
	Timestamp int64
}

Jump to

Keyboard shortcuts

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