orderbook

package
v0.0.0-...-fe11d6f Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InsufficientVolumeError

type InsufficientVolumeError struct {
	// contains filtered or unexported fields
}

func (*InsufficientVolumeError) Error

func (e *InsufficientVolumeError) Error() string

func (*InsufficientVolumeError) HTTPCode

func (e *InsufficientVolumeError) HTTPCode() int

type Limit

type Limit struct {
	Price       float64  `json:"price"`
	TotalVolume float64  `json:"total_volume"`
	Orders      []*Order `json:"orders"`
}

type Match

type Match struct {
	Ask        *Order  `json:"ask"`
	Bid        *Order  `json:"bid"`
	SizeFilled float64 `json:"size_filled"`
	Price      float64 `json:"price"`
}

type Order

type Order struct {
	Side      Side    `json:"side"`
	Price     float64 `json:"price"`
	Size      float64 `json:"size"`
	Timestamp int64   `json:"timestamp"`
}

func NewOrder

func NewOrder(side Side, size float64) *Order

type OrderType

type OrderType string
const (
	LimitOrder  OrderType = "limit"
	MarketOrder OrderType = "market"
)

func (*OrderType) UnmarshalJSON

func (ot *OrderType) UnmarshalJSON(data []byte) error

type Orderbook

type Orderbook struct {
	Market *TradingPair `json:"market"`
	Asks   []*Limit     `json:"asks"`
	Bids   []*Limit     `json:"bids"`
	// contains filtered or unexported fields
}

func (*Orderbook) GetAsks

func (book *Orderbook) GetAsks() []*Limit

func (*Orderbook) GetBids

func (book *Orderbook) GetBids() []*Limit

type OrderbookNotFoundError

type OrderbookNotFoundError struct {
	// contains filtered or unexported fields
}

func (*OrderbookNotFoundError) Error

func (e *OrderbookNotFoundError) Error() string

func (*OrderbookNotFoundError) HTTPCode

func (e *OrderbookNotFoundError) HTTPCode() int

type Side

type Side string
const (
	Bid Side = "bid"
	Ask Side = "ask"
)

func (*Side) UnmarshalJSON

func (side *Side) UnmarshalJSON(data []byte) error

type TradingPair

type TradingPair struct {
	Base  string `json:"base"`
	Quote string `json:"quote"`
}

func NewTradingPair

func NewTradingPair(base string, quote string) TradingPair

func (*TradingPair) ToString

func (pair *TradingPair) ToString() string

type TradingPlatform

type TradingPlatform struct {
	Accounts   *accounting.Accounts
	Orderbooks map[TradingPair]*Orderbook `json:"orderbooks"`
	// contains filtered or unexported fields
}

func NewTradingPlatform

func NewTradingPlatform() *TradingPlatform

func (*TradingPlatform) AddNewMarket

func (platform *TradingPlatform) AddNewMarket(pair TradingPair) *Orderbook

func (*TradingPlatform) GetOrderBook

func (platform *TradingPlatform) GetOrderBook(pair TradingPair) (*Orderbook, error)

func (*TradingPlatform) PlaceLimitOrder

func (platform *TradingPlatform) PlaceLimitOrder(pair TradingPair, price float64, order *Order) error

func (*TradingPlatform) PlaceMarketOrder

func (platform *TradingPlatform) PlaceMarketOrder(pair TradingPair, order *Order) ([]Match, error)

func (*TradingPlatform) Reset

func (platform *TradingPlatform) Reset()

func (*TradingPlatform) SeedData

func (platform *TradingPlatform) SeedData()

Jump to

Keyboard shortcuts

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