store

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePairSymbol

func ValidatePairSymbol(symbol string) error

ValidatePairSymbol validates the given trading pair.

Types

type OpenOrder

type OpenOrder struct {
	Id                   string       `json:"id"`
	Symbol               string       `json:"symbol"`
	Price                utils.Fixed8 `json:"price"`
	Quantity             utils.Fixed8 `json:"quantity"`
	CumQty               utils.Fixed8 `json:"cumQty"`
	CreatedHeight        int64        `json:"createdHeight"`
	CreatedTimestamp     int64        `json:"createdTimestamp"`
	LastUpdatedHeight    int64        `json:"lastUpdatedHeight"`
	LastUpdatedTimestamp int64        `json:"lastUpdatedTimestamp"`
}

func DecodeOpenOrders

func DecodeOpenOrders(cdc *wire.Codec, bz *[]byte) ([]OpenOrder, error)

func GetOpenOrders

func GetOpenOrders(cdc *wire.Codec, ctx context.CLIContext, pair string, addr string) ([]OpenOrder, error)

type OrderBook

type OrderBook struct {
	Height       int64
	Levels       []OrderBookLevel
	PendingMatch bool
}

OrderBook represents an order book at the current point block height, which is included in its struct.

func GetOrderBook

func GetOrderBook(cdc *wire.Codec, ctx context.CLIContext, pair string, levels int) (*OrderBook, error)

GetOrderBook decodes the order book from the serialized store

type OrderBookLevel

type OrderBookLevel struct {
	BuyQty    utils.Fixed8 `json:"buyQty"`
	BuyPrice  utils.Fixed8 `json:"buyPrice"`
	SellQty   utils.Fixed8 `json:"sellQty"`
	SellPrice utils.Fixed8 `json:"sellPrice"`
}

OrderBookLevel represents a single order book level.

type RecentPrice

type RecentPrice struct {
	Pair  []string
	Price []int64
}

type TradingPairMapper

type TradingPairMapper interface {
	AddTradingPair(ctx sdk.Context, pair types.TradingPair) error
	Exists(ctx sdk.Context, baseAsset, quoteAsset string) bool
	GetTradingPair(ctx sdk.Context, baseAsset, quoteAsset string) (types.TradingPair, error)
	DeleteTradingPair(ctx sdk.Context, baseAsset, quoteAsset string) error
	ListAllTradingPairs(ctx sdk.Context) []types.TradingPair
	UpdateRecentPrices(ctx sdk.Context, pricesStoreEvery, numPricesStored int64, lastTradePrices map[string]int64)
	GetRecentPrices(ctx sdk.Context, pricesStoreEvery, numPricesStored int64) map[string]*utils.FixedSizeRing
	DeleteRecentPrices(ctx sdk.Context, symbol string)
}

func NewTradingPairMapper

func NewTradingPairMapper(cdc *wire.Codec, key sdk.StoreKey) TradingPairMapper

Jump to

Keyboard shortcuts

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