order

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Comparator

func Comparator(a, b interface{}) (result int)

Comparator is used for comparing Key.

func StopComparator

func StopComparator(a, b interface{}) (result int)

StopComparator is used for comparing Key.

Types

type Key

type Key struct {
	ID        uint64          `json:"id"`
	Side      Side            `json:"side"`
	Price     decimal.Decimal `json:"price"`
	StopPrice decimal.Decimal `json:"stop_price"`
	CreatedAt time.Time       `json:"created_at"`
}

Key is used to sort orders in red black tree.

type Order

type Order struct {
	ID                uint64          `json:"id"`
	Side              Side            `json:"side"`
	Price             decimal.Decimal `json:"price"`
	StopPrice         decimal.Decimal `json:"stop_price"`
	Quantity          decimal.Decimal `json:"quantity"`
	FilledQuantity    decimal.Decimal `json:"filled_quantity"`
	CreatedAt         time.Time       `json:"created_at"`
	ImmediateOrCancel bool            `json:"immediate_or_cancel"`
}

Order .

func (*Order) Fill

func (o *Order) Fill(quantity decimal.Decimal)

Fill updates order filled quantity with passing arguments.

func (*Order) Filled

func (o *Order) Filled() bool

Filled returns true when its filled quantity equals to quantity.

func (*Order) IsLimit

func (o *Order) IsLimit() bool

IsLimit returns true when the order is limit order.

func (*Order) IsMarket

func (o *Order) IsMarket() bool

IsMarket returns true when the order is market order.

func (*Order) Key

func (o *Order) Key() *Key

Key returns a Key.

func (*Order) Match

func (o *Order) Match(taker *Order) *trade.Trade

Match matches maker with a taker and returns trade if there is a match.

func (*Order) PendingQuantity

func (o *Order) PendingQuantity() decimal.Decimal

PendingQuantity is the remaing quantity.

type Side

type Side string

Side is the orders' side.

const (
	// SideAsk represents the ask order side.
	SideAsk Side = "ask"

	// SideBid represents the bid order side.
	SideBid Side = "bid"
)

Jump to

Keyboard shortcuts

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