obm

package module
v0.0.0-...-d250ef0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomComparator

func CustomComparator(a, b interface{}) int

CustomComparator provides a basic comparison on decimal

Types

type Book

type Book struct {
	Price decimal.Decimal
	Size  decimal.Decimal
}

func Converter

func Converter(price, size any) Book

Converter is a function that converts the price and size of the book.

type Books

type Books struct {
	Books []Book
	// contains filtered or unexported fields
}

func (*Books) Each

func (p *Books) Each(fn func(key, val string))

func (*Books) Get

func (p *Books) Get(depth int) *Books

Get depth default:10 with sort bids: reverse, asks: sort

func (*Books) Len

func (p *Books) Len() int

func (*Books) Less

func (p *Books) Less(i, j int) bool

func (*Books) Put

func (p *Books) Put(book Book)

func (*Books) Remove

func (p *Books) Remove(key any)

func (*Books) Size

func (p *Books) Size() int

func (*Books) String

func (p *Books) String() string

func (*Books) Swap

func (p *Books) Swap(i, j int)

type LimitOrderBook

type LimitOrderBook struct {
	Book
	AccSize  decimal.Decimal
	AccRatio decimal.Decimal
}

type LimitOrderPlacement

type LimitOrderPlacement struct {
	Accumulation decimal.Decimal
	AccAsksRatio decimal.Decimal
	AccBidsRatio decimal.Decimal

	Asks []LimitOrderBook
	Bids []LimitOrderBook
}

type Orderbook

type Orderbook struct {
	sync.Mutex

	Symbol    string
	Bids      *Books
	Asks      *Books
	UpdatedAt time.Time
}

func New

func New(symbol string) *Orderbook

New is Create a new Orderbook default cap is 5

func (*Orderbook) Best

func (p *Orderbook) Best() (ask, bid Book)

func (*Orderbook) GetCap

func (p *Orderbook) GetCap() (askcap, bidcap int)

func (*Orderbook) GetMax

func (p *Orderbook) GetMax() (askmax, bidmax Book)

func (*Orderbook) GetMin

func (p *Orderbook) GetMin() (askmin, bidmin Book)

func (*Orderbook) LOB

func (p *Orderbook) LOB(rangeRatio decimal.Decimal) *LimitOrderPlacement

LOB 範囲板(cap)の総量とOrderPlacePriceの累計量と割合を算出

func (*Orderbook) Remover

func (p *Orderbook) Remover(setPrice decimal.Decimal) *Orderbook

func (*Orderbook) SetCap

func (p *Orderbook) SetCap(askcap, bidcap int) *Orderbook

SetCap is Determine the upper and lower limits of length stored in Map

func (*Orderbook) Update

func (p *Orderbook) Update(asks, bids []Book)

func (*Orderbook) Wall

func (p *Orderbook) Wall(targetSize float64) (ask, bid Book)

Wall search Big board In the setting cap range Search by Price near Mid

type Remover

type Remover int
const (
	MAX Remover = iota
	MIN
)

Jump to

Keyboard shortcuts

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