orderbook

package
v0.0.0-...-d3d1593 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MajorUpdate

type MajorUpdate struct {
	Exchange string // Name of the exchange
	Symbol   string // Trading pair symbol
}

MajorUpdate represents a significant change in the order book

type OrderBook

type OrderBook struct {
	Updates            chan PriceLevel  // Channel for receiving updates
	MajorUpdates       chan MajorUpdate // Channel for sending notifications of major changes
	ProcessingComplete chan struct{}    // Channel for signaling when all updates are processed
	// contains filtered or unexported fields
}

OrderBook represents the full order book for a trading pair

func NewOrderBook

func NewOrderBook(exchange, symbol string, depth int, updateChan chan PriceLevel, majorUpdateChan chan MajorUpdate) *OrderBook

NewOrderBook creates and initializes a new OrderBook

func (*OrderBook) BestBidAsk

func (ob *OrderBook) BestBidAsk() (decimal.Decimal, decimal.Decimal)

BestBidAsk returns the best bid and ask prices

func (*OrderBook) GetTopLevels

func (ob *OrderBook) GetTopLevels() ([]PriceLevel, []PriceLevel)

GetTopLevels returns copies of the top bid and ask levels

func (*OrderBook) Run

func (ob *OrderBook) Run(ctx context.Context)

Run starts the main loop of the OrderBook

type PriceLevel

type PriceLevel struct {
	Type      string // "bid" or "ask"
	Price     decimal.Decimal
	Amount    decimal.Decimal
	PriceStr  string
	AmountStr string
}

PriceLevel represents a single price level in the order book

Jump to

Keyboard shortcuts

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