Documentation
¶
Index ¶
- Constants
- func SetSaveOrderLog(v bool)
- type Element
- type KernelErr
- type MatchResult
- type MatchingEngine
- func (e *MatchingEngine) AskLength() int
- func (e *MatchingEngine) BestAsk() int64
- func (e *MatchingEngine) BestBid() int64
- func (e *MatchingEngine) BidLength() int
- func (e *MatchingEngine) MatchedInfoChan() <-chan MatchResult
- func (e *MatchingEngine) OrderBook() *OrderBookSnapshot
- func (e *MatchingEngine) Start()
- func (e *MatchingEngine) Stop()
- func (e *MatchingEngine) SubmitOrder(order *types.KernelOrder)
- type OrderBookSnapshot
- type PriceLevel
- type SkipList
Constants ¶
const ( DISABLED redoKernelStatus = iota WAITTING_START STARTED WAITTING_STOP STOPPED )
const ( // Suitable for math.Floor(math.Pow(math.E, 18)) == 65659969 elements in list DefaultMaxLevel int = 18 DefaultProbability float64 = 1 / math.E )
const (
REDO_KERNEL = 1
)
Variables ¶
This section is empty.
Functions ¶
func SetSaveOrderLog ¶
func SetSaveOrderLog(v bool)
SetSaveOrderLog controls whether orders are written to the WAL log file.
Types ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
type MatchResult ¶
type MatchResult struct {
TakerOrder types.KernelOrder
MakerOrders []types.KernelOrder
MatchedSizeMap map[uint64]int64
}
MatchResult holds the result of a matching event.
type MatchingEngine ¶
type MatchingEngine struct {
// contains filtered or unexported fields
}
MatchingEngine is the exported wrapper around the internal matching kernel.
func NewMatchingEngine ¶
func NewMatchingEngine(serverID uint64, desc string) *MatchingEngine
NewMatchingEngine creates a new matching engine instance.
func (*MatchingEngine) AskLength ¶
func (e *MatchingEngine) AskLength() int
AskLength returns the number of ask price levels.
func (*MatchingEngine) BestAsk ¶
func (e *MatchingEngine) BestAsk() int64
BestAsk returns the current best (lowest) ask price.
func (*MatchingEngine) BestBid ¶
func (e *MatchingEngine) BestBid() int64
BestBid returns the current best (highest) bid price.
func (*MatchingEngine) BidLength ¶
func (e *MatchingEngine) BidLength() int
BidLength returns the number of bid price levels.
func (*MatchingEngine) MatchedInfoChan ¶
func (e *MatchingEngine) MatchedInfoChan() <-chan MatchResult
MatchedInfoChan returns a read-only channel of match results.
func (*MatchingEngine) OrderBook ¶
func (e *MatchingEngine) OrderBook() *OrderBookSnapshot
OrderBook returns a snapshot of the current order book.
func (*MatchingEngine) Start ¶
func (e *MatchingEngine) Start()
Start begins order processing. Must be called before submitting orders.
func (*MatchingEngine) Stop ¶
func (e *MatchingEngine) Stop()
Stop gracefully shuts down the matching engine.
func (*MatchingEngine) SubmitOrder ¶
func (e *MatchingEngine) SubmitOrder(order *types.KernelOrder)
SubmitOrder sends an order into the matching engine.
type OrderBookSnapshot ¶
type OrderBookSnapshot struct {
Asks []PriceLevel `json:"asks"`
Bids []PriceLevel `json:"bids"`
}
OrderBookSnapshot is a snapshot of the current order book.
type PriceLevel ¶
PriceLevel represents a single price level in the order book.
type SkipList ¶
type SkipList struct {
Length int
// contains filtered or unexported fields
}
func NewSkipList ¶
func NewSkipList() *SkipList
NewSkipList creates a new skip list with default parameters. Returns a pointer to the new list.
func NewWithMaxLevel ¶
NewWithMaxLevel creates a new skip list with MaxLevel set to the provided number. maxLevel has to be int(math.Ceil(math.Log(N))) for DefaultProbability (where N is an upper bound on the number of elements in a skip list). See http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.17.524 Returns a pointer to the new list.
func (*SkipList) Get ¶
Get finds an element by key. It returns element pointer if found, nil if not found. Locking is optimistic and happens only after searching with a fast check for deletion after locking.
func (*SkipList) Remove ¶
Remove deletes an element from the list. Returns removed element pointer if found, nil if not found. This method is NOT thread-safe and should be called only when the list is not being accessed by other goroutines.
func (*SkipList) Set ¶
Set inserts a value in the list with the specified key, ordered by the key. If the key exists, it updates the value in the existing node. Returns a pointer to the new element. Locking is optimistic and happens only after searching.
func (*SkipList) SetProbability ¶
SetProbability changes the current P value of the list. It doesn't alter any existing data, only changes how future insert heights are calculated.