sdk

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 17 Imported by: ? 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 AccountInfo

type AccountInfo struct {
	UnifiedMarginStatus UnifiedMarginStatus `json:"unifiedMarginStatus"`
	MarginMode          string              `json:"marginMode"`
	IsMasterTrader      bool                `json:"isMasterTrader"`
	SpotHedgingStatus   string              `json:"spotHedgingStatus"`
	UpdatedTime         string              `json:"updatedTime"`
	DCPStatus           string              `json:"dcpStatus"`
	TimeWindow          int                 `json:"timeWindow"`
	SMPGroup            int                 `json:"smpGroup"`
}

func (AccountInfo) AccountMode

func (a AccountInfo) AccountMode() AccountMode

type AccountMode

type AccountMode string
const (
	AccountModeUnknown AccountMode = ""
	AccountModeClassic AccountMode = "CLASSIC"
	AccountModeUTA1    AccountMode = "UTA1"
	AccountModeUTA2    AccountMode = "UTA2"
)

func (AccountMode) IsUnified

func (m AccountMode) IsUnified() bool

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) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context) (*AccountInfo, error)

func (*Client) GetFeeRates

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

func (*Client) GetFundingHistory

func (c *Client) GetFundingHistory(ctx context.Context, category, symbol string, startMillis, endMillis int64, limit int) ([]FundingHistoryEntry, error)

GetFundingHistory retrieves historical funding rates. category: "linear" | "inverse". symbol required. startMillis / endMillis optional (pass 0 to omit). limit <=0 uses exchange default (200). Docs: https://bybit-exchange.github.io/docs/v5/market/history-fund-rate

func (*Client) GetInstruments

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

func (*Client) GetInstrumentsForBase

func (c *Client) GetInstrumentsForBase(ctx context.Context, category, baseCoin 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) GetOpenInterest

func (c *Client) GetOpenInterest(ctx context.Context, category, symbol, intervalTime string, startMillis, endMillis int64, limit int, cursor string) (*OpenInterestResult, error)

GetOpenInterest retrieves open-interest history. category: "linear" | "inverse". intervalTime: "5min" | "15min" | "30min" | "1h" | "4h" | "1d". startMillis / endMillis optional (pass 0 to omit). limit <=0 uses exchange default. cursor optional. Docs: https://bybit-exchange.github.io/docs/v5/market/open-interest

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) GetPrivateRaw

func (c *Client) GetPrivateRaw(ctx context.Context, path string, query map[string]string, out any) error

GetPrivateRaw executes an authenticated GET request for official Bybit V5 endpoints that are SDK-covered by the raw fallback before a typed method is introduced.

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) PostPrivateRaw

func (c *Client) PostPrivateRaw(ctx context.Context, path string, body any, out any) error

PostPrivateRaw executes an authenticated POST request for official Bybit V5 endpoints that are SDK-covered by the raw fallback before a typed method is introduced.

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 FundingHistoryEntry

type FundingHistoryEntry struct {
	Symbol               string `json:"symbol"`
	FundingRate          string `json:"fundingRate"`
	FundingRateTimestamp string `json:"fundingRateTimestamp"`
}

FundingHistoryEntry matches one row of /v5/market/funding/history result.list.

type FundingHistoryResult

type FundingHistoryResult struct {
	Category string                `json:"category"`
	List     []FundingHistoryEntry `json:"list"`
}

FundingHistoryResult is the result payload of /v5/market/funding/history.

type Instrument

type Instrument struct {
	Symbol        string        `json:"symbol"`
	BaseCoin      string        `json:"baseCoin"`
	QuoteCoin     string        `json:"quoteCoin"`
	SettleCoin    string        `json:"settleCoin"`
	Status        string        `json:"status"`
	OptionsType   string        `json:"optionsType"`
	LaunchTime    string        `json:"launchTime"`
	DeliveryTime  string        `json:"deliveryTime"`
	DisplayName   string        `json:"displayName"`
	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 OpenInterestEntry

type OpenInterestEntry struct {
	OpenInterest string `json:"openInterest"`
	Timestamp    string `json:"timestamp"`
}

OpenInterestEntry is one row of the open-interest history list.

type OpenInterestResult

type OpenInterestResult struct {
	Category       string              `json:"category"`
	Symbol         string              `json:"symbol"`
	List           []OpenInterestEntry `json:"list"`
	NextPageCursor string              `json:"nextPageCursor,omitempty"`
}

OpenInterestResult is the result payload of /v5/market/open-interest.

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 UnifiedMarginStatus

type UnifiedMarginStatus int
const (
	UnifiedMarginStatusClassic UnifiedMarginStatus = 1
	UnifiedMarginStatusUTA1    UnifiedMarginStatus = 3
	UnifiedMarginStatusUTA1Pro UnifiedMarginStatus = 4
	UnifiedMarginStatusUTA2    UnifiedMarginStatus = 5
	UnifiedMarginStatusUTA2Pro UnifiedMarginStatus = 6
)

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