spotv3

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Account Data Endpoints (https://bybit-exchange.github.io/docs/spot/v3/#t-accountdata)

API Data Endpoints (https://bybit-exchange.github.io/docs/futuresV2/linear/#t-api)

Spot v3 (https://bybit-exchange.github.io/docs/spot/v3)

Enums Definitions (https://bybit-exchange.github.io/docs/spot/v3/#t-enums)

Market Data Endpoints (https://bybit-exchange.github.io/docs/spot/v3/#t-marketdata)

Wallet Data Endpoints (https://bybit-exchange.github.io/docs/spot/v3/#t-wallet)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](c *Client, path string, param any) (T, error)

func GetPublic

func GetPublic[T any](c *Client, path string, param any) (T, error)

func Post

func Post[T any](c *Client, path string, param any) (T, error)

func WsFunc

func WsFunc[T any, F func(T)](m []byte, f F) error

Types

type Balance

type Balance struct {
	Coin     string            `json:"coin"`
	CoinID   string            `json:"coinId"`
	CoinName string            `json:"coinName"`
	Total    transport.Float64 `json:"total"`
	Free     transport.Float64 `json:"free"`
	Locked   string            `json:"locked"`
}

Get Wallet Balance (https://bybit-exchange.github.io/docs/spot/v3/#t-balance)

type BatchCancelOrder

type BatchCancelOrder struct {
	Symbol string     `param:"symbol"`
	Side   *Side      `param:"side"`
	Type   *OrderType `param:"orderTypes"`
}

Batch Cancel Active Order (https://bybit-exchange.github.io/docs/spot/v3/#t-batchcancelactiveorder)

symbol     Required string Name of the trading pair
side                string Order direction
orderTypes          string Order type. Use commas to indicate multiple order types, eg LIMIT,LIMIT_MAKER. Default: LIMIT

func (BatchCancelOrder) Do

func (this BatchCancelOrder) Do(client *Client) (bool, error)

type BatchCancelOrderByID

type BatchCancelOrderByID struct {
	ID []string `param:"orderIds"`
}

Batch Cancel Active Order By IDs (https://bybit-exchange.github.io/docs/spot/v3/#t-batchcancelactiveorderbyids)

orderIds Required string Order ID, use commas to indicate multiple orderIds. Maximum of 100 ids.

func (BatchCancelOrderByID) Do

func (this BatchCancelOrderByID) Do(client *Client) ([]CancelOrderID, error)

type BestBidAskPrice

type BestBidAskPrice struct {
	Symbol string `param:"symbol"`
}

Best Bid/Ask Price (https://bybit-exchange.github.io/docs/spot/v3/#t-bestbidask)

func (BestBidAskPrice) Do

func (this BestBidAskPrice) Do(client *Client) (BestBidAskPriceResult, error)

type BestBidAskPriceResult

type BestBidAskPriceResult struct {
	Symbol   string `json:"symbol"`
	BidPrice string `json:"bidPrice"`
	BidQty   string `json:"bidQty"`
	AskPrice string `json:"askPrice"`
	AskQty   string `json:"askQty"`
	Time     uint64 `json:"time"`
}

type BookTickerShot

type BookTickerShot struct {
	Symbol       string            `json:"s"`  // Trading pair
	BestBidPrice transport.Float64 `json:"bp"` // Best bid price
	BidQuantity  transport.Float64 `json:"bq"` // Bid quantity
	BestAskPrice transport.Float64 `json:"ap"` // Best ask price
	AskQuantity  transport.Float64 `json:"aq"` // Ask quantity
	Timestamp    uint64            `json:"t"`  // The time that message is sent out
}

type CancelOrder

type CancelOrder struct {
	OrderID     *string `param:"orderId"`
	OrderLinkID *string `param:"orderLinkId"`
}

Cancel Active Order (https://bybit-exchange.github.io/docs/spot/v3/#t-cancelactive)

orderId     string Order ID. Required if not passing orderLinkId
orderLinkId string Unique user-set order ID. Required if not passing orderId

func (CancelOrder) Do

func (this CancelOrder) Do(client *Client) (OrderCancelled, error)

type CancelOrderID

type CancelOrderID struct {
	OrderID string `json:"orderId"`
	Code    string `json:"code"`
}

type Client

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

Spotv3 HTTP client

func NewClient

func NewClient(client *transport.Client) *Client

func (*Client) BatchCancelOrder

func (this *Client) BatchCancelOrder(v BatchCancelOrder) (bool, error)

func (*Client) BatchCancelOrderByID

func (this *Client) BatchCancelOrderByID(ID []string) ([]CancelOrderID, error)

func (*Client) BestBidAskPrice

func (this *Client) BestBidAskPrice(symbol string) (BestBidAskPriceResult, error)

func (*Client) CancelOrder

func (this *Client) CancelOrder(v CancelOrder) (OrderCancelled, error)

func (*Client) Get

func (this *Client) Get(path string, param any, ret any) error

func (*Client) GetOrder

func (this *Client) GetOrder(v GetOrder) (Order, error)

func (*Client) GetPublic

func (this *Client) GetPublic(path string, param any, ret any) error

func (*Client) LastTradedPrice

func (this *Client) LastTradedPrice(symbol string) (SymbolPrice, error)

func (*Client) MergedOrderBook

func (this *Client) MergedOrderBook(v MergedOrderBook) (OrderBookResult, error)

func (*Client) OneSymbolLatestInformation

func (this *Client) OneSymbolLatestInformation(symbol string) (i LatestInformation, err error)

func (*Client) OpenOrders

func (this *Client) OpenOrders(v OpenOrders) ([]any, error)

func (*Client) OrderBook

func (this *Client) OrderBook(v OrderBook) (OrderBookResult, error)

func (*Client) OrderHistory

func (this *Client) OrderHistory(v OrderHistory) ([]OpenedOrder, error)

func (*Client) PlaceOrder

func (this *Client) PlaceOrder(v PlaceOrder) (OrderCreated, error)

func (*Client) Post

func (this *Client) Post(path string, param any, ret any) error

func (*Client) PublicTradingRecords

func (this *Client) PublicTradingRecords(v PublicTradingRecords) ([]PublicTradingRecord, error)

func (*Client) QueryKline

func (this *Client) QueryKline(v QueryKline) ([]KlineData, error)

func (*Client) QuerySymbol

func (this *Client) QuerySymbol() ([]SymbolInfo, error)

func (*Client) QuerySymbolNames

func (this *Client) QuerySymbolNames() ([]string, error)

func (*Client) ServerTime

func (this *Client) ServerTime() (string, error)

Server Time (https://bybit-exchange.github.io/docs/spot/v3/#t-servertime)

func (*Client) SymbolLatestInformation

func (this *Client) SymbolLatestInformation(symbol *string) ([]LatestInformation, error)

func (*Client) TradeHistory

func (this *Client) TradeHistory(v TradeHistory) ([]Trade, error)

func (*Client) Transport

func (this *Client) Transport() *transport.Client

func (*Client) WalletBalance

func (this *Client) WalletBalance() ([]Balance, error)

type DepthShot

type DepthShot struct {
	Timestamp uint64     `json:"t"` // Timestamp (last update time of the order book)
	Symbol    string     `json:"s"` // Trading pair
	Bids      [][]string `json:"b"` // Best bid price, quantity
	Asks      [][]string `json:"a"` // Best ask price, quantity
}

type Error

type Error struct {
	transport.Err
}

func (*Error) InsufficientBalance

func (o *Error) InsufficientBalance() bool

func (*Error) Timeout

func (o *Error) Timeout() bool

type GetOrder

type GetOrder struct {
	OrderID     *string `param:"orderId"`
	OrderLinkID *string `param:"orderLinkId"`
}

Get Active Order (https://bybit-exchange.github.io/docs/spot/v3/#t-getactive)

orderId     string Order ID. Required if not passing orderLinkId
orderLinkId string Unique user-set order ID. Required if not passing orderId

func (GetOrder) Do

func (this GetOrder) Do(client *Client) (Order, error)

type KlineData

type KlineData struct {
	Timestamp     uint64 `json:"t"`
	Symbol        string `json:"s"`
	Alias         string `json:"sn"`
	ClosePrice    string `json:"c"`
	HighPrice     string `json:"h"`
	LowPrice      string `json:"l"`
	OpenPrice     string `json:"o"`
	TradingVolume string `json:"v"`
}

type KlineInterval

type KlineInterval string

Kline interval (interval) (https://bybit-exchange.github.io/docs/spot/v3/#kline-interval-interval)

1m - 1 minute
3m - 3 minutes
5m - 5 minutes
15m - 15 minutes
30m - 30 minutes
1h - 1 hour
2h - 2 hours
4h - 4 hours
6h - 6 hours
12h - 12 hours
1d - 1 day
1w - 1 week
1M - 1 month
const (
	Interval1m  KlineInterval = "1m"
	Interval3m  KlineInterval = "3m"
	Interval5m  KlineInterval = "5m"
	Interval15m KlineInterval = "15m"
	Interval30m KlineInterval = "30m"
	Interval1h  KlineInterval = "1h"
	Interval2h  KlineInterval = "2h"
	Interval4h  KlineInterval = "4h"
	Interval6h  KlineInterval = "6h"
	Interval12h KlineInterval = "12h"
	Interval1d  KlineInterval = "1d"
	Interval1w  KlineInterval = "1w"
	Interval1M  KlineInterval = "1M"
)

type KlineShot

type KlineShot struct {
	Timestamp     uint64 `json:"t"` // Starting time
	Symbol        string `json:"s"` // Trading pair
	ClosePrice    string `json:"c"` // Close price
	HighPrice     string `json:"h"` // High price
	LowPrice      string `json:"l"` // Low price
	OpenPrice     string `json:"o"` // Open price
	TradingVolume string `json:"v"` // Trading volume
}

type LastTradedPrice

type LastTradedPrice struct {
	Symbol string `param:"symbol"`
}

Last Traded Price (https://bybit-exchange.github.io/docs/spot/v3/#t-lasttradedprice)

func (LastTradedPrice) Do

func (this LastTradedPrice) Do(client *Client) (SymbolPrice, error)

type LatestInformation

type LatestInformation struct {
	Time               uint64            `json:"t"`
	Symbol             string            `json:"s"`
	LastTradedPrice    transport.Float64 `json:"lp"`
	HighPrice          string            `json:"h"`
	LowPrice           string            `json:"l"`
	OpenPrice          string            `json:"o"`
	BestBidPrice       transport.Float64 `json:"bp"`
	BestAskPrice       transport.Float64 `json:"ap"`
	TradingVolume      string            `json:"v"`
	TradingQuoteVolume string            `json:"qv"`
}

type LtOrderStatus

type LtOrderStatus string

LT order status (orderStatus) (https://bybit-exchange.github.io/docs/spot/v3/#lt-order-status-orderstatus)

1 - Completed
2 - In progress
3 - Failed
const (
	Completed  LtOrderStatus = "1"
	InProgress LtOrderStatus = "2"
	Failed     LtOrderStatus = "3"
)

type LtOrderType

type LtOrderType string

LT order type (orderType) (https://bybit-exchange.github.io/docs/spot/v3/#lt-order-type-ordertype)

1 - Purchase
2 - Redemption
const (
	Purchase   LtOrderType = "1"
	Redemption LtOrderType = "2"
)

type LtStatus

type LtStatus string

LT status (status) (https://bybit-exchange.github.io/docs/spot/v3/#lt-status-status)

1 - ETP can be purchased and redeemed
2 - ETP can be purchased, but not redeemed
3 - ETP can be redeemed, but not purchased
4 - ETP cannot be purchased nor redeemed

type MergedOrderBook

type MergedOrderBook struct {
	Symbol string `param:"symbol"`
	Scale  *int   `param:"scale"`
	Limit  *int   `param:"limit"`
}

Merged Order Book (https://bybit-exchange.github.io/docs/spot/v3/#t-mergedorderbook)

symbol Required string  Name of the trading pair
scale           int     Precision of the merged orderbook, 1 means 1 digit
limit           integer Default value is 100

func (MergedOrderBook) Do

func (this MergedOrderBook) Do(client *Client) (OrderBookResult, error)

type OpenOrders

type OpenOrders struct {
	Symbol  *string `param:"symbol"`
	OrderID *string `param:"orderId"`
	Limit   *int    `param:"limit"`
}

Open Orders (https://bybit-exchange.github.io/docs/spot/v3/#t-openorders)

symbol  string  Name of the trading pair
orderId string  Specify orderId to return all the orders that orderId of which are smaller than this particular one for pagination purpose
limit   integer Default value is 500, max 500

func (OpenOrders) Do

func (this OpenOrders) Do(client *Client) ([]any, error)

type OpenedOrder

type OpenedOrder struct {
	OrderBase
	ExecQty             string `json:"execQty"`
	CummulativeQuoteQty string `json:"cummulativeQuoteQty"`
	AvgPrice            string `json:"avgPrice"`
	StopPrice           string `json:"stopPrice"`
	IcebergQty          string `json:"icebergQty"`
	UpdateTime          string `json:"updateTime"`
	IsWorking           string `json:"isWorking"`
}

type Order

type Order struct {
	OpenedOrder
	Locked string `json:"locked"`
}

type OrderBase

type OrderBase struct {
	AccountID     string            `json:"accountId"`
	OrderID       string            `json:"orderId"`
	OrderLinkID   string            `json:"orderLinkId"`
	Symbol        string            `json:"symbol"`
	CreatedTime   transport.TimeMs  `json:"createTime"`
	Price         transport.Float64 `json:"orderPrice"`
	OrderQty      transport.Float64 `json:"orderQty"`
	OrderType     OrderType         `json:"orderType"`
	Side          Side              `json:"side"`
	OrderStatus   OrderStatus       `json:"status"`
	TimeInForce   TimeInForce       `json:"timeInForce"`
	ExecQty       string            `json:"execQty"`
	OrderCategory int               `json:"orderCategory"`
}

type OrderBook

type OrderBook struct {
	Symbol string `param:"symbol"`
	Limit  *int   `param:"limit"`
}

Order Book (https://bybit-exchange.github.io/docs/spot/v3/#t-orderbook)

symbol Required string  Name of the trading pair
limit           integer Default value is 100

func (OrderBook) Do

func (this OrderBook) Do(client *Client) (OrderBookResult, error)

type OrderBookResult

type OrderBookResult struct {
	Time uint64 `json:"time"`
	Bids [][]string
	Asks [][]string
}

type OrderCancelled

type OrderCancelled struct {
	OrderBase
	ExecQty string `json:"execQty"`
}

type OrderCreated

type OrderCreated struct {
	OrderBase
	OrderCategory int    `json:"orderCategory"`
	TriggerPrice  string `json:"triggerPrice"`
}

type OrderHistory

type OrderHistory struct {
	Symbol    *string `param:"symbol"`
	OrderID   *string `param:"orderId"`
	Limit     *int    `param:"limit"`
	StartTime *uint64 `param:"startTime"`
	EndTime   *uint64 `param:"endTime"`
}

Order History (https://bybit-exchange.github.io/docs/spot/v3/#t-orderhistory)

symbol    string  Name of the trading pair
orderId   string  Specify orderId to return all the orders that orderId of which are smaller than this particular one for pagination purpose
limit     integer Default value is 500, max 500
startTime long    Start time, unit in millisecond
endTime   long    End time, unit in millisecond

func (OrderHistory) Do

func (this OrderHistory) Do(client *Client) ([]OpenedOrder, error)

type OrderShot

type OrderShot struct {
	EventType           string            `json:"e"` // Event type
	EventTime           transport.TimeMs  `json:"E"` // Event time
	Symbol              string            `json:"s"` // Trading pair
	UserOrderID         string            `json:"c"` // User-generated order ID
	Side                Side              `json:"S"` // BUY indicates buy order, SELL indicates sell order
	OrderType           OrderType         `json:"o"` // Order type, LIMIT/MARKET_OF_QUOTE/MARKET_OF_BASE
	TimeInForce         TimeInForce       `json:"f"` // Time in force
	Quantity            transport.Float64 `json:"q"` // Quantity
	Price               transport.Float64 `json:"p"` // Price
	OrderStatus         OrderStatus       `json:"X"` // Order status
	OrderID             string            `json:"i"` // Order ID
	OrderIDofOpponent   string            `json:"M"` // Order ID of the opponent trader
	LastFilledQuantity  string            `json:"l"` // Last filled quantity
	TotalFilledQuantity string            `json:"z"` // Total filled quantity
	LastTradedPrice     string            `json:"L"` // Last traded price
	TradingFee          transport.Float64 `json:"n"` // Trading fee (for a single fill)
	AssetType           string            `json:"N"` // Asset type in which fee is paid
	IsNormalTrade       bool              `json:"u"` // Is normal trade. False if self-trade.
	IsWorking           bool              `json:"w"` // Is working
	IsLimitMaker        bool              `json:"m"` // Is LIMIT_MAKER
	OrderCreationTime   transport.TimeMs  `json:"O"` // Order creation time
	TotalFilledValue    string            `json:"Z"` // Total filled value
	AccountID           string            `json:"A"` // Account ID of the opponent trader
	IsClose             bool              `json:"C"` // Is close
	Leverage            string            `json:"v"` // Leverage
	Liquidation         string            `json:"d"` // NO_LIQ indicates that it is not a liquidation order. IOC indicates that it is a liquidation order.
	TradeID             string            `json:"t"` // Trade ID
}

type OrderStatus

type OrderStatus string

Order status (status) (https://bybit-exchange.github.io/docs/spot/v3/#order-status-status)

ORDER_NEW Untriggered
ORDER_FILLED Triggered
ORDER_FAILED fail to trigger
const (
	New             OrderStatus = "NEW"
	PartiallyFilled OrderStatus = "PARTIALLY_FILLED"
	Filled          OrderStatus = "FILLED"
	Canceled        OrderStatus = "CANCELED"
	PendingCancel   OrderStatus = "PENDING_CANCEL"
	PendingNew      OrderStatus = "PENDING_NEW"
	Rejected        OrderStatus = "REJECTED"
)

type OrderType

type OrderType string

Order type (type/orderTypes) (https://bybit-exchange.github.io/docs/spot/v3/#order-type-type-ordertypes)

const (
	Limit       OrderType = "LIMIT"
	Market      OrderType = "MARKET"
	LimitMarket OrderType = "LIMIT_MAKER"
)

type OutboundItem

type OutboundItem struct {
	Coin      string            `json:"a"` // Coin name
	Available transport.Float64 `json:"f"` // Available balance
	Reserved  transport.Float64 `json:"l"` // Reserved for orders
}

type OutboundShot

type OutboundShot struct {
	EventType           string         `json:"e"` // Event type
	Timestamp           string         `json:"E"` // Timestamp
	AllowTrade          bool           `json:"T"` // Allow trade
	AllowWithdraw       bool           `json:"W"` // Allow withdraw
	AllowDeposit        bool           `json:"D"` // Allow deposit
	WalletBalanceChange []OutboundItem `json:"B"` // Wallet balance change
}

type PlaceOrder

type PlaceOrder struct {
	Symbol        string       `json:"symbol"`
	Qty           float64      `json:"orderQty"`
	Side          Side         `json:"side"`
	Type          OrderType    `json:"orderType"`
	TimeInForce   *TimeInForce `json:"timeInForce"`
	Price         *float64     `json:"orderPrice"`
	OrderLinkID   *string      `json:"orderLinkId"`
	OrderCategory *int         `json:"orderCategory"`
	TriggerPrice  *string      `json:"triggerPrice"`
}

Place Active Order (https://bybit-exchange.github.io/docs/spot/v3/#t-placeactive)

symbol      Required string Name of the trading pair
qty         Required number Order quantity (for market orders: when side is Buy, this is in the quote currency.
                       Otherwise, qty is in the base currency. For example, on BTCUSDT a Buy order is in USDT, otherwise it's in BTC.
                       For limit orders, the qty is always in the base currency.)
side        Required string Order direction
type        Required string Order type
timeInForce          string Time in force
price                number Order price. When the type field is MARKET, the price field is optional. When the type field is LIMIT or LIMIT_MAKER,
                       the price field is required
orderLinkId          string User-generated order ID

func (PlaceOrder) Do

func (this PlaceOrder) Do(client *Client) (OrderCreated, error)

type PublicTradingRecord

type PublicTradingRecord struct {
	Price        string `json:"price"`
	Time         uint64 `json:"time"`
	Qty          string `json:"qty"`
	IsBuyerMaker int    `json:"isBuyerMaker"`
}

type PublicTradingRecords

type PublicTradingRecords struct {
	Symbol string `param:"symbol"`
	Limit  *int   `param:"limit"`
}

Public Trading Records (https://bybit-exchange.github.io/docs/spot/v3/#t-publictradingrecords)

symbol Required string  Name of the trading pair
limit           integer Default value is 60, max 60

func (PublicTradingRecords) Do

func (this PublicTradingRecords) Do(client *Client) ([]PublicTradingRecord, error)

type QueryKline

type QueryKline struct {
	Symbol    string        `param:"symbol"`
	Interval  KlineInterval `param:"interval"`
	Limit     *int          `param:"limit"`
	StartTime *int          `param:"startTime"`
	EndTime   *int          `param:"endTime"`
}

Query Kline (https://bybit-exchange.github.io/docs/spot/v3/#t-querykline)

symbol    Required string  Name of the trading pair
interval  Required string  Chart interval
limit              integer Default value is 1000, max 1000
startTime          number  Start time, unit in millisecond
endTime            number  End time, unit in millisecond

func (QueryKline) Do

func (this QueryKline) Do(client *Client) ([]KlineData, error)

type Request

type Request struct {
	Name  string   `json:"op"`
	Args  []string `json:"args,omitempty"`
	ReqID string   `json:"req_id,omitempty"`
}

type Responce

type Responce struct {
	Name    string `json:"op"`
	Args    []any  `json:"args"`
	ReqID   string `json:"req_id"`
	ConnID  string `json:"conn_id"`
	Success bool   `json:"success"`
	RetMsg  string `json:"ret_msg"`
	Topic   string `json:"topic"`
	Type    string `json:"type"`
}

func (*Responce) IsTopic

func (o *Responce) IsTopic() bool

type Response

type Response[T any] struct {
	RetCode int    `json:"retCode"`
	RetMsg  string `json:"retMsg"`
	Time    uint64 `json:"time"`
	Result  T      `json:"result"`
}

type Side

type Side string

Side (side) (https://bybit-exchange.github.io/docs/spot/v3/#side-side)

const (
	None Side = "None"
	Buy  Side = "Buy"
	Sell Side = "Sell"
)

type StopOrderShot

type StopOrderShot struct {
	EventType          string `json:"e"` // Event type
	EventTime          string `json:"E"` // Event time
	Symbol             string `json:"s"` // Trading pair
	UserOrderID        string `json:"c"` // User-generated order ID
	Side               string `json:"S"` // BUY indicates buy order, SELL indicates sell order
	OrderType          string `json:"o"` // Order type, LIMIT/MARKET_OF_QUOTE/MARKET_OF_BASE
	TimeInForce        string `json:"f"` // Time in force
	Quantity           string `json:"q"` // Quantity
	Price              string `json:"p"` // Price
	OrderStatus        string `json:"X"` // Order status
	OrderID            string `json:"i"` // Order ID
	OrderCreationTime  string `json:"T"` // Order creation time
	OrderTriggeredTime string `json:"t"` // Order triggered time
	OrderUpdatedTime   string `json:"C"` // Order updated time
}

type Subscription

type Subscription struct {
	Topic    TopicName
	Interval string
	Symbol   string
}

func (*Subscription) Request

func (o *Subscription) Request(operation string) Request

func (*Subscription) String

func (o *Subscription) String() string

type SubscriptionFunc

type SubscriptionFunc func(m []byte, delta bool) error

type Subscriptions

type Subscriptions map[string]SubscriptionFunc

type SymbolInfo

type SymbolInfo struct {
	Name              string            `json:"name"`
	Alias             string            `json:"alias"`
	BaseCoin          string            `json:"baseCoin"`
	QuoteCoin         string            `json:"quoteCoin"`
	BasePrecision     transport.Float64 `json:"basePrecision"`
	QuotePrecision    transport.Float64 `json:"quotePrecision"`
	MinTradeQty       transport.Float64 `json:"minTradeQty"`
	MinTradeAmt       transport.Float64 `json:"minTradeAmt"`
	MaxTradeQty       transport.Float64 `json:"maxTradeQty"`
	MaxTradeAmt       transport.Float64 `json:"maxTradeAmt"`
	MinPricePrecision transport.Float64 `json:"minPricePrecision"`
	Category          string            `json:"category"`
	ShowStatus        string            `json:"showStatus"`
	Innovation        string            `json:"innovation"`
}

Query Symbol (https://bybit-exchange.github.io/docs/spot/v3/#t-spot_querysymbol)

type SymbolLatestInformation

type SymbolLatestInformation struct {
	Symbol *string `param:"symbol"`
}

Latest Information for Symbol (https://bybit-exchange.github.io/docs/spot/v3/#t-spot_latestsymbolinfo)

func (SymbolLatestInformation) Do

func (this SymbolLatestInformation) Do(client *Client) ([]LatestInformation, error)

type SymbolPrice

type SymbolPrice struct {
	Symbol string `json:"symbol"`
	Price  string `json:"price"`
}

type TickersShot

type TickersShot struct {
	Timestamp          uint64 `json:"t"`  // Starting time
	Symbol             string `json:"s"`  // Trading pair
	OpenPrice          string `json:"o"`  // Open price
	HighPrice          string `json:"h"`  // High price
	LowPrice           string `json:"l"`  // Low price
	ClosePrice         string `json:"c"`  // Close price
	TradingVolume      string `json:"v"`  // Trading volume
	TradingQuoteVolume string `json:"qv"` // Trading quote volume
	Change             string `json:"m"`  // Change
}

type TicketShot

type TicketShot struct {
	EventType           string `json:"e"` // Event type
	EventTime           string `json:"E"` // Event time
	Symbol              string `json:"s"` // Trading pair
	Quantity            string `json:"q"` // Quantity
	Timestamp           string `json:"t"` // Timestamp
	Price               string `json:"p"` // Price
	TradeID             string `json:"T"` // Trade ID
	OrderID             string `json:"o"` // Order ID
	OrderIDofOpponent   string `json:"O"` // Order ID of the opponent trader
	AccountID           string `json:"a"` // Account ID
	AccountIDofOpponent string `json:"A"` // Account ID of the opponent trader
	IsLimitMaker        bool   `json:"m"` // Is LIMIT_MAKER
	Side                string `json:"S"` // BUY indicates buy order, SELL indicates sell order
}

type TimeInForce

type TimeInForce string

Time in force (time_in_force) (https://bybit-exchange.github.io/docs/spot/v3/#time-in-force-timeinforce)

GTC - Good Till Canceled
FOK - Fill or Kill
IOC - Immediate or Cancel
const (
	GoodTillCanceled  TimeInForce = "GTC"
	FillOrKill        TimeInForce = "FOK"
	ImmediateOrCancel TimeInForce = "IOC"
)

type Topic

type Topic[T any] struct {
	Name      string `json:"topic"`
	Type      string `json:"type"`
	Data      T      `json:"data"`
	Timestamp any    `json:"ts"`
}

type TopicMessage

type TopicMessage struct {
	Topic string
	Delta bool
	Bin   []byte
}

type TopicName

type TopicName string
const (
	// public
	TopicDepth      TopicName = "orderbook"
	TopicTrade      TopicName = "trade"
	TopicKline      TopicName = "kline"
	TopicTickers    TopicName = "tickers"
	TopicBookTicker TopicName = "bookticker"
	// private
	TopicOrder     TopicName = "order"
	TopicStopOrder TopicName = "stopOrder"
	TopicTicket    TopicName = "ticketInfo"
	TopicOutbound  TopicName = "outboundAccountInfo"
)

type Trade

type Trade struct {
	ID            string `json:"id"`
	Symbol        string `json:"symbol"`
	OrderID       string `json:"orderId"`
	TradeID       string `json:"tradeId"`
	Price         string `json:"orderPrice"`
	Qty           string `json:"orderQty"`
	ExecFee       string `json:"execFee"`
	FeeTokenId    string `json:"feeTokenId"`
	CreatedTime   string `json:"createdTime"`
	IsBuyer       string `json:"isBuyer"`
	IsMaker       string `json:"isMaker"`
	MatchOrderID  string `json:"matchOrderId"`
	MakerRebate   string `json:"makerRebate"`
	ExecutionTime string `json:"executionTime"`
}

type TradeHistory

type TradeHistory struct {
	Symbol       *string `param:"symbol"`
	Limit        *int    `param:"limit"`
	FromTicketID *int    `param:"fromTicketId"`
	ToTicketID   *int    `param:"toTicketId"`
	OrderID      *string `param:"orderId"`
	StartTime    *uint64 `param:"startTime"`
	EndTime      *uint64 `param:"endTime"`
}

Trade History (https://bybit-exchange.github.io/docs/spot/v3/#t-tradehistory)

symbol       string  Name of the trading pair
limit        integer Default value is 50, max 50
fromTicketId integer Query greater than the trade ID. (fromTicketId < trade ID)
toTicketId   integer Query smaller than the trade ID. (trade ID < toTicketId)
orderId      integer Order ID
startTime    long    Start time, unit in millisecond
endTime      long    End time, unit in millisecond

func (TradeHistory) Do

func (this TradeHistory) Do(client *Client) ([]Trade, error)

type TradeShot

type TradeShot struct {
	TradeID   string `json:"v"` // Trade ID
	Timestamp uint64 `json:"t"` // Timestamp (trading time in the match box)
	Price     string `json:"p"` // Price
	Quantity  string `json:"q"` // Quantity
	M         bool   `json:"m"` // True indicates buy side is taker, false indicates sell side is taker
}

type WsClient

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

func NewWsClient

func NewWsClient(url string) *WsClient

func (*WsClient) Conf

func (o *WsClient) Conf() *transport.WsConf

func (*WsClient) Connected

func (o *WsClient) Connected() bool

func (*WsClient) Run

func (o *WsClient) Run()

func (*WsClient) Send

func (o *WsClient) Send(cmd any) bool

/////

func (*WsClient) SetOnAuth

func (o *WsClient) SetOnAuth(onAuth func(bool))

func (*WsClient) SetOnConnected

func (o *WsClient) SetOnConnected(onConnected func())

func (*WsClient) SetOnDialError

func (o *WsClient) SetOnDialError(onDialError func(error) bool)

func (*WsClient) SetOnDisconnected

func (o *WsClient) SetOnDisconnected(onConnected func())

func (*WsClient) SetOnTopicMessage

func (o *WsClient) SetOnTopicMessage(onTopicMessage func(TopicMessage) error)

func (*WsClient) Shutdown

func (o *WsClient) Shutdown()

func (*WsClient) Subscribe

func (o *WsClient) Subscribe(s Subscription) bool

func (*WsClient) Unsubscribe

func (o *WsClient) Unsubscribe(s Subscription) bool

func (*WsClient) WithByTickUrl

func (o *WsClient) WithByTickUrl() *WsClient

func (*WsClient) WithLog

func (o *WsClient) WithLog(log *ulog.Log) *WsClient

func (*WsClient) WithProxy

func (o *WsClient) WithProxy(proxy string) *WsClient

func (*WsClient) WithUrl

func (o *WsClient) WithUrl(url string) *WsClient

type WsExecutor

type WsExecutor[T any] struct {
	// contains filtered or unexported fields
}

func NewWsExecutor

func NewWsExecutor[T any](section *WsSection, subscription Subscription) *WsExecutor[T]

func (*WsExecutor[T]) Init

func (o *WsExecutor[T]) Init(section *WsSection, subscription Subscription)

func (*WsExecutor[T]) Subscribe

func (o *WsExecutor[T]) Subscribe(onShot func(T))

func (*WsExecutor[T]) Unsubscribe

func (o *WsExecutor[T]) Unsubscribe()

type WsPrivate

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

func NewWsPrivate

func NewWsPrivate(key string, secret string) *WsPrivate

func (*WsPrivate) Conf

func (o *WsPrivate) Conf() *transport.WsConf

func (*WsPrivate) Connected

func (o *WsPrivate) Connected() bool

func (*WsPrivate) Order

func (o *WsPrivate) Order() *WsExecutor[[]OrderShot]

func (*WsPrivate) Outbound

func (o *WsPrivate) Outbound() *WsExecutor[[]OutboundShot]

func (*WsPrivate) Ready

func (o *WsPrivate) Ready() bool

func (*WsPrivate) Run

func (o *WsPrivate) Run()

func (*WsPrivate) SetOnDialError

func (o *WsPrivate) SetOnDialError(onDialError func(error) bool)

func (*WsPrivate) Shutdown

func (o *WsPrivate) Shutdown()

func (*WsPrivate) StopOrder

func (o *WsPrivate) StopOrder() *WsExecutor[[]StopOrderShot]

func (*WsPrivate) Ticket

func (o *WsPrivate) Ticket() *WsExecutor[[]TicketShot]

func (*WsPrivate) WithByTickUrl

func (o *WsPrivate) WithByTickUrl() *WsPrivate

func (*WsPrivate) WithLog

func (o *WsPrivate) WithLog(log *ulog.Log) *WsPrivate

func (*WsPrivate) WithProxy

func (o *WsPrivate) WithProxy(proxy string) *WsPrivate

type WsPublic

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

func NewWsPublic

func NewWsPublic() *WsPublic

func (*WsPublic) BookTicker

func (o *WsPublic) BookTicker(symbol string) *WsExecutor[BookTickerShot]

func (*WsPublic) Conf

func (o *WsPublic) Conf() *transport.WsConf

func (*WsPublic) Connected

func (o *WsPublic) Connected() bool

func (*WsPublic) Depth

func (o *WsPublic) Depth(symbol string) *WsExecutor[DepthShot]

func (*WsPublic) Kline

func (o *WsPublic) Kline(symbol string, interval KlineInterval) *WsExecutor[KlineShot]

func (*WsPublic) Ready

func (o *WsPublic) Ready() bool

func (*WsPublic) Run

func (o *WsPublic) Run()

func (*WsPublic) SetOnDialError

func (o *WsPublic) SetOnDialError(onDialError func(error) bool)

func (*WsPublic) Shutdown

func (o *WsPublic) Shutdown()

func (*WsPublic) Tickers

func (o *WsPublic) Tickers(symbol string) *WsExecutor[TickersShot]

func (*WsPublic) Trade

func (o *WsPublic) Trade(symbol string) *WsExecutor[TradeShot]

func (*WsPublic) WithByTickUrl

func (o *WsPublic) WithByTickUrl() *WsPublic

func (*WsPublic) WithLog

func (o *WsPublic) WithLog(log *ulog.Log) *WsPublic

func (*WsPublic) WithProxy

func (o *WsPublic) WithProxy(proxy string) *WsPublic

type WsSection

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

func NewWsSection

func NewWsSection(ws WsSectionClient) *WsSection

type WsSectionClient

type WsSectionClient interface {
	Ready() bool
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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