ws

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainnetWSURL = "wss://api.mainnet.aptoslabs.com/decibel/ws"
	TestnetWSURL = "wss://api.testnet.aptoslabs.com/decibel/ws"
)

Variables

This section is empty.

Functions

func NormalizeOrderStatus

func NormalizeOrderStatus(status string) exchanges.OrderStatus

Types

type Client

type Client struct {
	URL                  string
	Origin               string
	APIKey               string
	ReconnectWait        time.Duration
	PingInterval         time.Duration
	MaxReconnectAttempts int
	StatusNormalizer     func(string) exchanges.OrderStatus
	// contains filtered or unexported fields
}

func NewClient

func NewClient(parent context.Context, apiKey string) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Subscribe

func (c *Client) Subscribe(topic string, handler func(MarketDepthMessage)) error

func (*Client) SubscribeOrderUpdates

func (c *Client) SubscribeOrderUpdates(userAddr string, handler func(OrderUpdateMessage)) error

func (*Client) SubscribeUserOrderHistory

func (c *Client) SubscribeUserOrderHistory(userAddr string, handler func(UserOrderHistoryMessage)) error

func (*Client) SubscribeUserPositions

func (c *Client) SubscribeUserPositions(userAddr string, handler func(UserPositionsMessage)) error

type DepthLevel

type DepthLevel struct {
	Price decimal.Decimal `json:"price"`
	Size  decimal.Decimal `json:"size"`
}

type DepthUpdateType

type DepthUpdateType string
const (
	DepthUpdateSnapshot DepthUpdateType = "snapshot"
	DepthUpdateDelta    DepthUpdateType = "delta"
)

type MarketDepthMessage

type MarketDepthMessage struct {
	Topic      string          `json:"topic"`
	Market     string          `json:"market"`
	UpdateType DepthUpdateType `json:"update_type,omitempty"`
	Bids       []DepthLevel    `json:"bids"`
	Asks       []DepthLevel    `json:"asks"`
	Timestamp  int64           `json:"timestamp,omitempty"`
}

func (MarketDepthMessage) IsDelta

func (m MarketDepthMessage) IsDelta() bool

type OrderHistoryItem

type OrderHistoryItem struct {
	OrderID          string                `json:"order_id,omitempty"`
	ClientOrderID    string                `json:"client_order_id,omitempty"`
	Status           string                `json:"status,omitempty"`
	NormalizedStatus exchanges.OrderStatus `json:"-"`
	OrderType        string                `json:"order_type,omitempty"`
	Side             string                `json:"side,omitempty"`
	Price            decimal.Decimal       `json:"price,omitempty"`
	OrigSize         decimal.Decimal       `json:"orig_size,omitempty"`
	RemainingSize    decimal.Decimal       `json:"remaining_size,omitempty"`
	SizeDelta        decimal.Decimal       `json:"size_delta,omitempty"`
	UnixMS           int64                 `json:"unix_ms,omitempty"`
}

type OrderUpdateItem

type OrderUpdateItem struct {
	ClientOrderID      string          `json:"client_order_id,omitempty"`
	Market             string          `json:"market,omitempty"`
	OrderID            string          `json:"order_id,omitempty"`
	OrderType          string          `json:"order_type,omitempty"`
	OrderDirection     string          `json:"order_direction,omitempty"`
	Side               string          `json:"side,omitempty"`
	IsBuy              bool            `json:"is_buy,omitempty"`
	Status             string          `json:"status,omitempty"`
	Details            string          `json:"details,omitempty"`
	CancellationReason string          `json:"cancellation_reason,omitempty"`
	IsReduceOnly       bool            `json:"is_reduce_only,omitempty"`
	UnixMS             int64           `json:"unix_ms,omitempty"`
	OrigSize           decimal.Decimal `json:"orig_size,omitempty"`
	Price              decimal.Decimal `json:"price,omitempty"`
	RemainingSize      decimal.Decimal `json:"remaining_size,omitempty"`
	SizeDelta          decimal.Decimal `json:"size_delta,omitempty"`
}

type OrderUpdateMessage

type OrderUpdateMessage struct {
	Topic string            `json:"topic"`
	Order OrderUpdateRecord `json:"order"`
}

type OrderUpdateRecord

type OrderUpdateRecord struct {
	Status           string                `json:"status,omitempty"`
	Details          string                `json:"details,omitempty"`
	NormalizedStatus exchanges.OrderStatus `json:"-"`
	Order            OrderUpdateItem       `json:"order"`
}

type Position

type Position struct {
	Market     string          `json:"market,omitempty"`
	Size       decimal.Decimal `json:"size,omitempty"`
	EntryPrice decimal.Decimal `json:"entry_price,omitempty"`
	Side       string          `json:"side,omitempty"`
}

type UserOrderHistoryMessage

type UserOrderHistoryMessage struct {
	Topic  string             `json:"topic"`
	Market string             `json:"market,omitempty"`
	Orders []OrderHistoryItem `json:"orders,omitempty"`
}

type UserPositionsMessage

type UserPositionsMessage struct {
	Topic     string     `json:"topic"`
	Positions []Position `json:"positions,omitempty"`
}

Jump to

Keyboard shortcuts

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