sdk

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmendOrderRequest

type AmendOrderRequest struct {
	Category    string `json:"category"`
	Symbol      string `json:"symbol"`
	OrderID     string `json:"orderId,omitempty"`
	OrderLinkID string `json:"orderLinkId,omitempty"`
	Qty         string `json:"qty,omitempty"`
	Price       string `json:"price,omitempty"`
}

type CancelAllOrdersRequest

type CancelAllOrdersRequest struct {
	Category   string `json:"category"`
	Symbol     string `json:"symbol,omitempty"`
	BaseCoin   string `json:"baseCoin,omitempty"`
	SettleCoin string `json:"settleCoin,omitempty"`
}

type CancelOrderRequest

type CancelOrderRequest struct {
	Category    string `json:"category"`
	Symbol      string `json:"symbol"`
	OrderID     string `json:"orderId,omitempty"`
	OrderLinkID string `json:"orderLinkId,omitempty"`
}

type Candle

type Candle [7]NumberString

func (*Candle) UnmarshalJSON

func (c *Candle) UnmarshalJSON(data []byte) error

type Client

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

func NewClient

func NewClient() *Client

func (*Client) AmendOrder

func (c *Client) AmendOrder(ctx context.Context, req AmendOrderRequest) (*OrderActionResponse, error)

func (*Client) CancelAllOrders

func (c *Client) CancelAllOrders(ctx context.Context, req CancelAllOrdersRequest) error

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context, req CancelOrderRequest) (*OrderActionResponse, error)

func (*Client) GetFeeRates

func (c *Client) GetFeeRates(ctx context.Context, category, symbol string) ([]FeeRateRecord, error)

func (*Client) GetInstruments

func (c *Client) GetInstruments(ctx context.Context, category string) ([]Instrument, error)

func (*Client) GetKlines

func (c *Client) GetKlines(ctx context.Context, category, symbol, interval string, start, end int64, limit int) ([]Candle, error)

func (*Client) GetOpenOrders

func (c *Client) GetOpenOrders(ctx context.Context, category, symbol string) ([]OrderRecord, error)

func (*Client) GetOrderBook

func (c *Client) GetOrderBook(ctx context.Context, category, symbol string, limit int) (*OrderBook, error)

func (*Client) GetOrderHistory

func (c *Client) GetOrderHistory(ctx context.Context, category, symbol string) ([]OrderRecord, error)

func (*Client) GetOrderHistoryFiltered

func (c *Client) GetOrderHistoryFiltered(ctx context.Context, category, symbol, orderID, orderLinkID string) ([]OrderRecord, error)

func (*Client) GetPositions

func (c *Client) GetPositions(ctx context.Context, category, symbol, settleCoin string) ([]PositionRecord, error)

func (*Client) GetRealtimeOrders

func (c *Client) GetRealtimeOrders(ctx context.Context, category, symbol, settleCoin, orderID, orderLinkID string, openOnly int) ([]OrderRecord, error)

func (*Client) GetRecentTrades

func (c *Client) GetRecentTrades(ctx context.Context, category, symbol string, limit int) ([]PublicTrade, error)

func (*Client) GetTicker

func (c *Client) GetTicker(ctx context.Context, category, symbol string) (*Ticker, error)

func (*Client) GetWalletBalance

func (c *Client) GetWalletBalance(ctx context.Context, accountType, coin string) (*WalletBalanceResult, error)

func (*Client) HasCredentials

func (c *Client) HasCredentials() bool

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (*OrderActionResponse, error)

func (*Client) SetLeverage

func (c *Client) SetLeverage(ctx context.Context, req SetLeverageRequest) error

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) *Client

func (*Client) WithCredentials

func (c *Client) WithCredentials(apiKey, secretKey string) *Client

func (*Client) WithHTTPClient

func (c *Client) WithHTTPClient(httpClient *http.Client) *Client

type ExecutionRecord

type ExecutionRecord struct {
	ExecID      string `json:"execId"`
	OrderID     string `json:"orderId"`
	OrderLinkID string `json:"orderLinkId"`
	Symbol      string `json:"symbol"`
	Side        string `json:"side"`
	ExecPrice   string `json:"execPrice"`
	ExecQty     string `json:"execQty"`
	ExecFee     string `json:"execFee"`
	FeeCurrency string `json:"feeCurrency"`
	IsMaker     bool   `json:"isMaker"`
	ExecTime    string `json:"execTime"`
}

type FeeRateRecord

type FeeRateRecord struct {
	Symbol       string `json:"symbol"`
	MakerFeeRate string `json:"makerFeeRate"`
	TakerFeeRate string `json:"takerFeeRate"`
	BaseCoin     string `json:"baseCoin"`
}

type FeeRatesResult

type FeeRatesResult struct {
	List []FeeRateRecord `json:"list"`
}

type Instrument

type Instrument struct {
	Symbol        string        `json:"symbol"`
	BaseCoin      string        `json:"baseCoin"`
	QuoteCoin     string        `json:"quoteCoin"`
	Status        string        `json:"status"`
	PriceScale    string        `json:"priceScale"`
	PriceFilter   PriceFilter   `json:"priceFilter"`
	LotSizeFilter LotSizeFilter `json:"lotSizeFilter"`
}

type InstrumentsResult

type InstrumentsResult struct {
	Category       string       `json:"category"`
	List           []Instrument `json:"list"`
	NextPageCursor string       `json:"nextPageCursor"`
}

type KlinesResult

type KlinesResult struct {
	Category string   `json:"category"`
	Symbol   string   `json:"symbol"`
	List     []Candle `json:"list"`
}

type LotSizeFilter

type LotSizeFilter struct {
	BasePrecision    string `json:"basePrecision"`
	QtyStep          string `json:"qtyStep"`
	MinOrderQty      string `json:"minOrderQty"`
	MinOrderAmt      string `json:"minOrderAmt"`
	MinNotionalValue string `json:"minNotionalValue"`
}

type NumberString

type NumberString string

func (*NumberString) UnmarshalJSON

func (n *NumberString) UnmarshalJSON(data []byte) error

type OrderActionResponse

type OrderActionResponse struct {
	OrderID     string `json:"orderId"`
	OrderLinkID string `json:"orderLinkId"`
}

type OrderBook

type OrderBook struct {
	Symbol string           `json:"s"`
	Bids   [][]NumberString `json:"b"`
	Asks   [][]NumberString `json:"a"`
	TS     int64            `json:"ts"`
	U      int64            `json:"u"`
}

type OrderRecord

type OrderRecord struct {
	OrderID            string `json:"orderId"`
	OrderLinkID        string `json:"orderLinkId"`
	Symbol             string `json:"symbol"`
	Side               string `json:"side"`
	OrderType          string `json:"orderType"`
	TimeInForce        string `json:"timeInForce"`
	Price              string `json:"price"`
	Qty                string `json:"qty"`
	CumExecQty         string `json:"cumExecQty"`
	AvgPrice           string `json:"avgPrice"`
	OrderStatus        string `json:"orderStatus"`
	ReduceOnly         bool   `json:"reduceOnly"`
	CreatedTime        string `json:"createdTime"`
	UpdatedTime        string `json:"updatedTime"`
	CumExecFee         string `json:"cumExecFee"`
	ClosedPnl          string `json:"closedPnl"`
	TriggerPrice       string `json:"triggerPrice"`
	LastPriceOnCreated string `json:"lastPriceOnCreated"`
}

type OrdersResult

type OrdersResult struct {
	List           []OrderRecord `json:"list"`
	NextPageCursor string        `json:"nextPageCursor"`
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	Category              string `json:"category"`
	Symbol                string `json:"symbol"`
	Side                  string `json:"side"`
	OrderType             string `json:"orderType"`
	Qty                   string `json:"qty"`
	Price                 string `json:"price,omitempty"`
	TimeInForce           string `json:"timeInForce,omitempty"`
	ReduceOnly            bool   `json:"reduceOnly,omitempty"`
	OrderLinkID           string `json:"orderLinkId,omitempty"`
	MarketUnit            string `json:"marketUnit,omitempty"`
	SlippageToleranceType string `json:"slippageToleranceType,omitempty"`
	SlippageTolerance     string `json:"slippageTolerance,omitempty"`
}

type PositionRecord

type PositionRecord struct {
	Symbol         string `json:"symbol"`
	Side           string `json:"side"`
	Size           string `json:"size"`
	AvgPrice       string `json:"avgPrice"`
	Leverage       string `json:"leverage"`
	UnrealisedPnl  string `json:"unrealisedPnl"`
	CumRealisedPnl string `json:"cumRealisedPnl"`
	LiqPrice       string `json:"liqPrice"`
}

type PositionsResult

type PositionsResult struct {
	NextPageCursor string           `json:"nextPageCursor"`
	List           []PositionRecord `json:"list"`
}

type PriceFilter

type PriceFilter struct {
	TickSize string `json:"tickSize"`
}

type PrivateWSClient

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

func NewPrivateWSClient

func NewPrivateWSClient() *PrivateWSClient

func (*PrivateWSClient) Close

func (c *PrivateWSClient) Close() error

func (*PrivateWSClient) Connect

func (c *PrivateWSClient) Connect(ctx context.Context) error

func (*PrivateWSClient) Subscribe

func (c *PrivateWSClient) Subscribe(ctx context.Context, topic string, handler func(json.RawMessage)) error

func (*PrivateWSClient) Unsubscribe

func (c *PrivateWSClient) Unsubscribe(ctx context.Context, topic string) error

func (*PrivateWSClient) WithCredentials

func (c *PrivateWSClient) WithCredentials(apiKey, secretKey string) *PrivateWSClient

type PublicTrade

type PublicTrade struct {
	ExecID string `json:"execId"`
	Symbol string `json:"symbol"`
	Price  string `json:"price"`
	Size   string `json:"size"`
	Side   string `json:"side"`
	Time   string `json:"time"`
}

type PublicTradesResult

type PublicTradesResult struct {
	Category string        `json:"category"`
	List     []PublicTrade `json:"list"`
}

type PublicWSClient

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

func NewPublicWSClient

func NewPublicWSClient(category string) *PublicWSClient

func (*PublicWSClient) Close

func (c *PublicWSClient) Close() error

func (*PublicWSClient) Connect

func (c *PublicWSClient) Connect(ctx context.Context) error

func (*PublicWSClient) Subscribe

func (c *PublicWSClient) Subscribe(ctx context.Context, topic string, handler func(json.RawMessage)) error

func (*PublicWSClient) Unsubscribe

func (c *PublicWSClient) Unsubscribe(ctx context.Context, topic string) error

type SetLeverageRequest

type SetLeverageRequest struct {
	Category     string `json:"category"`
	Symbol       string `json:"symbol"`
	BuyLeverage  string `json:"buyLeverage"`
	SellLeverage string `json:"sellLeverage"`
}

type Ticker

type Ticker struct {
	Symbol       string `json:"symbol"`
	LastPrice    string `json:"lastPrice"`
	Bid1Price    string `json:"bid1Price"`
	Ask1Price    string `json:"ask1Price"`
	Volume24h    string `json:"volume24h"`
	Turnover24h  string `json:"turnover24h"`
	HighPrice24h string `json:"highPrice24h"`
	LowPrice24h  string `json:"lowPrice24h"`
	IndexPrice   string `json:"indexPrice"`
	MarkPrice    string `json:"markPrice"`
	Time         string `json:"time"`
	TS           string `json:"ts"`
}

type TickersResult

type TickersResult struct {
	Category string   `json:"category"`
	List     []Ticker `json:"list"`
}

type TradeWSClient

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

func NewTradeWSClient

func NewTradeWSClient() *TradeWSClient

func (*TradeWSClient) AmendOrder

func (c *TradeWSClient) AmendOrder(ctx context.Context, req AmendOrderRequest) error

func (*TradeWSClient) CancelOrder

func (c *TradeWSClient) CancelOrder(ctx context.Context, req CancelOrderRequest) error

func (*TradeWSClient) Close

func (c *TradeWSClient) Close() error

func (*TradeWSClient) Connect

func (c *TradeWSClient) Connect(ctx context.Context) error

func (*TradeWSClient) PlaceOrder

func (c *TradeWSClient) PlaceOrder(ctx context.Context, req PlaceOrderRequest) error

func (*TradeWSClient) WithCredentials

func (c *TradeWSClient) WithCredentials(apiKey, secretKey string) *TradeWSClient

type WSEnvelope

type WSEnvelope struct {
	Topic string          `json:"topic"`
	Type  string          `json:"type"`
	TS    int64           `json:"ts"`
	Data  json.RawMessage `json:"data"`
}

type WSExecutionMessage

type WSExecutionMessage struct {
	Topic string            `json:"topic"`
	Data  []ExecutionRecord `json:"data"`
}

func DecodeExecutionMessage

func DecodeExecutionMessage(payload []byte) (*WSExecutionMessage, error)

type WSOrderBookData

type WSOrderBookData struct {
	Symbol   string           `json:"s"`
	Bids     [][]NumberString `json:"b"`
	Asks     [][]NumberString `json:"a"`
	UpdateID int64            `json:"u"`
	Seq      int64            `json:"seq"`
	CTS      int64            `json:"cts"`
}

type WSOrderBookMessage

type WSOrderBookMessage struct {
	Topic string          `json:"topic"`
	Type  string          `json:"type"`
	TS    int64           `json:"ts"`
	Data  WSOrderBookData `json:"data"`
}

func DecodeOrderBookMessage

func DecodeOrderBookMessage(payload []byte) (*WSOrderBookMessage, error)

type WSOrderMessage

type WSOrderMessage struct {
	Topic string        `json:"topic"`
	Data  []OrderRecord `json:"data"`
}

func DecodeOrderMessage

func DecodeOrderMessage(payload []byte) (*WSOrderMessage, error)

type WSPositionMessage

type WSPositionMessage struct {
	Topic string           `json:"topic"`
	Data  []PositionRecord `json:"data"`
}

func DecodePositionMessage

func DecodePositionMessage(payload []byte) (*WSPositionMessage, error)

type WalletAccount

type WalletAccount struct {
	AccountType           string       `json:"accountType"`
	TotalEquity           string       `json:"totalEquity"`
	TotalAvailableBalance string       `json:"totalAvailableBalance"`
	TotalPerpUPL          string       `json:"totalPerpUPL"`
	TotalWalletBalance    string       `json:"totalWalletBalance"`
	Coin                  []WalletCoin `json:"coin"`
}

type WalletBalanceResult

type WalletBalanceResult struct {
	List []WalletAccount `json:"list"`
}

type WalletCoin

type WalletCoin struct {
	Coin           string `json:"coin"`
	Equity         string `json:"equity"`
	WalletBalance  string `json:"walletBalance"`
	Locked         string `json:"locked"`
	UnrealisedPnl  string `json:"unrealisedPnl"`
	CumRealisedPnl string `json:"cumRealisedPnl"`
	UsdValue       string `json:"usdValue"`
}

Jump to

Keyboard shortcuts

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