orderbook

package
v0.0.0-...-dcbaead Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuyComparator

func BuyComparator(a, b interface{}) int

func SellComparator

func SellComparator(a, b interface{}) int

Types

type DirectionEnum

type DirectionEnum int
const (
	DirectionEnumBuy DirectionEnum = iota + 1
	DirectionEnumSell
)

type MatchEngine

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

func NewMatchEngine

func NewMatchEngine() *MatchEngine

func (*MatchEngine) GetBuyBook

func (e *MatchEngine) GetBuyBook() *OrderBook

func (*MatchEngine) GetPrice

func (e *MatchEngine) GetPrice() decimal.Decimal

func (*MatchEngine) GetSellBook

func (e *MatchEngine) GetSellBook() *OrderBook

func (*MatchEngine) ProcessOrder

func (e *MatchEngine) ProcessOrder(ctx context.Context, order *Order) *MatchResponse

func (*MatchEngine) String

func (e *MatchEngine) String() string

type MatchResponse

type MatchResponse struct {
	TakerOrder   *Order
	MatchRecords []*MatchedRecord
}

type MatchedRecord

type MatchedRecord struct {
	FilledPrice  decimal.Decimal
	FilledAmount decimal.Decimal
	TakerOrder   *Order
	MakerOrder   *Order
}

type Order

type Order struct {
	Nonce     string // order id
	Trader    string
	Direction DirectionEnum
	Side      SideEnum
	Price     decimal.Decimal
	Amount    decimal.Decimal
	Slippage  uint
	CreateAt  time.Time
	UpdateAt  time.Time
	ExpireAt  time.Time
}

type OrderBook

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

func NewBook

func NewBook(direction DirectionEnum) *OrderBook

func (*OrderBook) Add

func (ob *OrderBook) Add(order *Order)

func (*OrderBook) Remove

func (ob *OrderBook) Remove(order *Order)

func (*OrderBook) String

func (ob *OrderBook) String() string

type OrderKey

type OrderKey struct {
	Nonce    string // order id
	Price    decimal.Decimal
	CreateAt time.Time
}

type SideEnum

type SideEnum int
const (
	SideEnumLong SideEnum = iota + 1
	SideEnumShort
)

Jump to

Keyboard shortcuts

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