common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBalancesJSON

func AppendBalancesJSON(dst []byte, balances []Balance) []byte

AppendBalancesJSON appends a []Balance (nil → null).

func AppendPriceLevelsJSON

func AppendPriceLevelsJSON(dst []byte, levels []PriceLevel) []byte

AppendPriceLevelsJSON appends a []PriceLevel (nil → null).

func PriceToTick

func PriceToTick(price float64, pricePrecision int) int

PriceToTick converts price to integer tick given precision. E.g. PriceToTick(71532.32, 2) = 7153232

func QuantityToTick

func QuantityToTick(quantity float64, sizePrecision int) int

QuantityToTick converts quantity to integer tick given precision. E.g. QuantityToTick(0.025, 5) = 2500

Types

type Balance

type Balance struct {
	TokenID   int
	Available float64
	Locked    float64
	Total     float64
}

func (Balance) AppendJSON

func (b Balance) AppendJSON(dst []byte) []byte

AppendJSON appends a Balance as a JSON object matching encoding/json field names.

type BookState

type BookState int
const (
	BookStateWaitForSnapshot BookState = iota
	BookStateUpdating
	BookStateReady
)

func (BookState) String

func (s BookState) String() string

type EngineType

type EngineType int
const (
	EngineData EngineType = iota
	EngineExecution
	EngineLedger
	EngineRisk
	EngineStrategy
)

func (EngineType) String

func (e EngineType) String() string

type Exchange

type Exchange int
const (
	ExchangeUnknown Exchange = iota
	ExchangeBinance          // id=1
	ExchangeBybit            // id=2
)

type Interval

type Interval int

Interval is a normalized candlestick interval shared across venues.

const (
	IntervalUnknown Interval = iota
	Interval1s
	Interval1m
	Interval3m
	Interval5m
	Interval15m
	Interval30m
	Interval1h
	Interval2h
	Interval4h
	Interval6h
	Interval8h
	Interval12h
	Interval1d
	Interval3d
	Interval1w
	Interval1M
)

func ParseInterval

func ParseInterval(s string) (Interval, error)

ParseInterval converts a config / venue interval string to Interval. Accepts Binance forms (1m, 1h, 1d) and Bybit forms (1, 60, D, W, M).

func (Interval) BinanceStream

func (i Interval) BinanceStream() string

BinanceStream returns the Binance kline stream interval suffix (e.g. "1m").

func (Interval) BybitTopic

func (i Interval) BybitTopic() (string, bool)

BybitTopic returns the Bybit kline topic interval token (e.g. "1", "60", "D").

func (Interval) String

func (i Interval) String() string

type Order

type Order struct {
	AccountID     int
	ClientOrderID int
	OrderID       int
	SymbolID      int
	Side          Side
	OrderType     OrderType
	TimeInForce   TimeInForce
	Quantity      float64
	Price         float64
	OrderStatus   OrderStatus
	ExecutedQty   float64
	CreatedAt     uint64
	UpdatedAt     uint64
}

type OrderStatus

type OrderStatus int
const (
	OrderStatusUninitialized OrderStatus = iota
	OrderStatusInitialized
	OrderStatusAccepted
	OrderStatusPartiallyFilled
	OrderStatusFilled
	OrderStatusCanceled
	OrderStatusRejected
	OrderStatusCancelling
	OrderStatusUnknown
)

func (OrderStatus) Cancellable

func (o OrderStatus) Cancellable() bool

func (OrderStatus) IsOpen

func (o OrderStatus) IsOpen() bool

func (OrderStatus) IsTerminal

func (o OrderStatus) IsTerminal() bool

type OrderType

type OrderType int
const (
	OrderTypeLimit OrderType = iota
	OrderTypeMarket
)

func (OrderType) String

func (o OrderType) String() string

type PriceLevel

type PriceLevel struct {
	Price        float64
	Quantity     float64
	PriceTick    int
	QuantityTick int
}

PriceLevel represents a single price level in an order book. PriceTick and QuantityTick are integer representations using symbol precision: PriceTick = round(Price * 10^PricePrecision), e.g. 71532.32 with precision 2 -> 7153232 QuantityTick = round(Quantity * 10^SizePrecision), e.g. 0.025 with precision 5 -> 2500

func (PriceLevel) AppendJSON

func (p PriceLevel) AppendJSON(dst []byte) []byte

AppendJSON appends a PriceLevel as a JSON object matching encoding/json field names.

type ProductType

type ProductType int
const (
	ProductTypeUnknown   ProductType = iota
	ProductTypeSpot                  // id=1
	ProductTypePerpetual             // id=2
)

type Side

type Side int
const (
	SideUnknown Side = iota
	SideBuy
	SideSell
)

func (Side) String

func (s Side) String() string

type TimeInForce

type TimeInForce int
const (
	TimeInForceGTC TimeInForce = iota
	TimeInForceIOC
	TimeInForceFOK
	TimeInForcePO
)

func (TimeInForce) String

func (t TimeInForce) String() string

type WalletType

type WalletType int
const (
	WalletTypeUnknown  WalletType = iota
	WalletTypeSpot                // id=1
	WalletTypeUMargin             // id=2 (USD Margin)
	WalletTypeCMargin             // id=3 (Coin Margin)
	WalletTypeLeverage            // id=4
	WalletTypeUnified             // id=5
)

func (WalletType) String

func (w WalletType) String() string

Jump to

Keyboard shortcuts

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