Documentation ¶
Index ¶
Constants ¶
const ( MaxPrice Price = 100_000 MinPrice Price = 1 EstNumOrders Size = 1_000_000 // Rough estimate of number of orders (to pre-allocate orderIDMap) EstNumSymbols Size = 1_000 // Rough estimate of number of symbols (to pre-allocate orderbooksMap) ChanSize Size = 10_000 // Channel buffer size )
Define the constants used in the exchange These are used to provide bounds for the exchange and pre-allocate memory
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action represents an action event passed by the exchange
type ActionType ¶
type ActionType uint8
ActionType represents the type of action event passed by the exchange
const ( ActionBid ActionType = iota ActionAsk ActionOrderReject ActionCancel ActionCancelReject ActionExecute )
Define the action types used in the exchange for various order event states
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
Exchange represents the exchange engine, that stores the orderbooks (per symbol) and manages the orders
func (*Exchange) Cancel ¶
Cancel processes an incoming cancel order, cancelling the order if it exists in the exchange
func (*Exchange) Init ¶
Init initialises the exchange with the given name and actions channel, and establishes the order storage
func (*Exchange) Limit ¶
Limit processes an incoming limit order, validating it and passing it to the appropriate orderbook
func (*Exchange) PreWarmWithSymbols ¶
PreWarmWithSymbols 'pre-warms' the exchange with the given symbols, creating the orderbooks Used to avoid the first order for a symbol being slow due to orderbook creation
type Order ¶
type Order struct {
// contains filtered or unexported fields
}
Order represents an order on the exchange
type OrderBook ¶
type OrderBook struct {
// contains filtered or unexported fields
}
OrderBook represents the collection of asks and bids, for a specific symbol on the exchange
type OrderID ¶
type OrderID uint64 // Unique identifier for an order [range 0-2^64]
Define the types used in the exchange. These are used to represent the orderbook, orders, and traders
type PricePoint ¶
type PricePoint struct {
// contains filtered or unexported fields
}
PricePoint represents a price level and its associated orders Deque in the orderbook