Documentation
¶
Index ¶
- type AccountInfo
- type AccountMode
- type AmendOrderRequest
- type CancelAllOrdersRequest
- type CancelOrderRequest
- type Candle
- type Client
- func (c *Client) AmendOrder(ctx context.Context, req AmendOrderRequest) (*OrderActionResponse, error)
- func (c *Client) CancelAllOrders(ctx context.Context, req CancelAllOrdersRequest) error
- func (c *Client) CancelOrder(ctx context.Context, req CancelOrderRequest) (*OrderActionResponse, error)
- func (c *Client) GetAccountInfo(ctx context.Context) (*AccountInfo, error)
- func (c *Client) GetFeeRates(ctx context.Context, category, symbol string) ([]FeeRateRecord, error)
- func (c *Client) GetFundingHistory(ctx context.Context, category, symbol string, startMillis, endMillis int64, ...) ([]FundingHistoryEntry, error)
- func (c *Client) GetInstruments(ctx context.Context, category string) ([]Instrument, error)
- func (c *Client) GetInstrumentsForBase(ctx context.Context, category, baseCoin string) ([]Instrument, error)
- func (c *Client) GetKlines(ctx context.Context, category, symbol, interval string, start, end int64, ...) ([]Candle, error)
- func (c *Client) GetOpenInterest(ctx context.Context, category, symbol, intervalTime string, ...) (*OpenInterestResult, error)
- func (c *Client) GetOpenOrders(ctx context.Context, category, symbol string) ([]OrderRecord, error)
- func (c *Client) GetOrderBook(ctx context.Context, category, symbol string, limit int) (*OrderBook, error)
- func (c *Client) GetOrderHistory(ctx context.Context, category, symbol string) ([]OrderRecord, error)
- func (c *Client) GetOrderHistoryFiltered(ctx context.Context, category, symbol, orderID, orderLinkID string) ([]OrderRecord, error)
- func (c *Client) GetPositions(ctx context.Context, category, symbol, settleCoin string) ([]PositionRecord, error)
- func (c *Client) GetPrivateRaw(ctx context.Context, path string, query map[string]string, out any) error
- func (c *Client) GetRealtimeOrders(ctx context.Context, category, symbol, settleCoin, orderID, orderLinkID string, ...) ([]OrderRecord, error)
- func (c *Client) GetRecentTrades(ctx context.Context, category, symbol string, limit int) ([]PublicTrade, error)
- func (c *Client) GetTicker(ctx context.Context, category, symbol string) (*Ticker, error)
- func (c *Client) GetWalletBalance(ctx context.Context, accountType, coin string) (*WalletBalanceResult, error)
- func (c *Client) HasCredentials() bool
- func (c *Client) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (*OrderActionResponse, error)
- func (c *Client) PostPrivateRaw(ctx context.Context, path string, body any, out any) error
- func (c *Client) SetLeverage(ctx context.Context, req SetLeverageRequest) error
- func (c *Client) WithBaseURL(baseURL string) *Client
- func (c *Client) WithCredentials(apiKey, secretKey string) *Client
- func (c *Client) WithHTTPClient(httpClient *http.Client) *Client
- type ExecutionRecord
- type FeeRateRecord
- type FeeRatesResult
- type FundingHistoryEntry
- type FundingHistoryResult
- type Instrument
- type InstrumentsResult
- type KlinesResult
- type LotSizeFilter
- type NumberString
- type OpenInterestEntry
- type OpenInterestResult
- type OrderActionResponse
- type OrderBook
- type OrderRecord
- type OrdersResult
- type PlaceOrderRequest
- type PositionRecord
- type PositionsResult
- type PriceFilter
- type PrivateWSClient
- func (c *PrivateWSClient) Close() error
- func (c *PrivateWSClient) Connect(ctx context.Context) error
- func (c *PrivateWSClient) Subscribe(ctx context.Context, topic string, handler func(json.RawMessage)) error
- func (c *PrivateWSClient) Unsubscribe(ctx context.Context, topic string) error
- func (c *PrivateWSClient) WithCredentials(apiKey, secretKey string) *PrivateWSClient
- type PublicTrade
- type PublicTradesResult
- type PublicWSClient
- type SetLeverageRequest
- type Ticker
- type TickersResult
- type TradeWSClient
- func (c *TradeWSClient) AmendOrder(ctx context.Context, req AmendOrderRequest) error
- func (c *TradeWSClient) CancelOrder(ctx context.Context, req CancelOrderRequest) error
- func (c *TradeWSClient) Close() error
- func (c *TradeWSClient) Connect(ctx context.Context) error
- func (c *TradeWSClient) PlaceOrder(ctx context.Context, req PlaceOrderRequest) error
- func (c *TradeWSClient) WithCredentials(apiKey, secretKey string) *TradeWSClient
- type UnifiedMarginStatus
- type WSEnvelope
- type WSExecutionMessage
- type WSOrderBookData
- type WSOrderBookMessage
- type WSOrderMessage
- type WSPositionMessage
- type WalletAccount
- type WalletBalanceResult
- type WalletCoin
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 CancelAllOrdersRequest ¶
type CancelOrderRequest ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
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 (*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 (*Client) GetInstrumentsForBase ¶
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 (*Client) GetOrderBook ¶
func (*Client) GetOrderHistory ¶
func (*Client) GetOrderHistoryFiltered ¶
func (*Client) GetPositions ¶
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 (*Client) GetRecentTrades ¶
func (*Client) GetWalletBalance ¶
func (*Client) HasCredentials ¶
func (*Client) PlaceOrder ¶
func (c *Client) PlaceOrder(ctx context.Context, req PlaceOrderRequest) (*OrderActionResponse, error)
func (*Client) PostPrivateRaw ¶
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 (*Client) WithCredentials ¶
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 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 LotSizeFilter ¶
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 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) 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 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) 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 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 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) 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 WalletBalanceResult ¶
type WalletBalanceResult struct {
List []WalletAccount `json:"list"`
}