bybitapi

package
v1.56.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: AGPL-3.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	RestBaseURL         = "https://api.bybit.com"
	WsSpotPublicSpotUrl = "wss://stream.bybit.com/v5/public/spot"
	WsSpotPrivateUrl    = "wss://stream.bybit.com/v5/private"
)
View Source
const KLinesArrayLen = 7

Variables

View Source
var (
	SupportedIntervals = map[types.Interval]int{
		types.Interval1m:  1 * 60,
		types.Interval3m:  3 * 60,
		types.Interval5m:  5 * 60,
		types.Interval15m: 15 * 60,
		types.Interval30m: 30 * 60,
		types.Interval1h:  60 * 60,
		types.Interval2h:  60 * 60 * 2,
		types.Interval4h:  60 * 60 * 4,
		types.Interval6h:  60 * 60 * 6,
		types.Interval12h: 60 * 60 * 12,
		types.Interval1d:  60 * 60 * 24,
		types.Interval1w:  60 * 60 * 24 * 7,
		types.Interval1mo: 60 * 60 * 24 * 30,
	}

	ToGlobalInterval = map[string]types.Interval{
		"1":   types.Interval1m,
		"3":   types.Interval3m,
		"5":   types.Interval5m,
		"15":  types.Interval15m,
		"30":  types.Interval30m,
		"60":  types.Interval1h,
		"120": types.Interval2h,
		"240": types.Interval4h,
		"360": types.Interval6h,
		"720": types.Interval12h,
		"D":   types.Interval1d,
		"W":   types.Interval1w,
		"M":   types.Interval1mo,
	}
)

Functions

func Sign added in v1.52.0

func Sign(payload string, secret string) string

Types

type APIResponse

type APIResponse struct {
	// Success/Error code
	RetCode uint `json:"retCode"`
	// Success/Error msg. OK, success, SUCCESS indicate a successful response
	RetMsg string `json:"retMsg"`
	// Business data result
	Result json.RawMessage `json:"result"`
	// Extend info. Most of the time, it is {}
	RetExtInfo json.RawMessage `json:"retExtInfo"`
	// Time is current timestamp (ms)
	Time types.MillisecondTimestamp `json:"time"`
}

func (APIResponse) Error added in v1.53.0

func (a APIResponse) Error() error

func (APIResponse) Validate added in v1.53.0

func (a APIResponse) Validate() error

type AccountInfo

type AccountInfo struct {
	MarginMode          string `json:"marginMode"`
	UpdatedTime         string `json:"updatedTime"`
	UnifiedMarginStatus int    `json:"unifiedMarginStatus"`
	DcpStatus           string `json:"dcpStatus"`
	TimeWindow          int    `json:"timeWindow"`
	SmpGroup            int    `json:"smpGroup"`
}

type AccountType added in v1.52.0

type AccountType string
const AccountTypeSpot AccountType = "SPOT"

type CancelOrderRequest added in v1.51.1

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

func (*CancelOrderRequest) Category added in v1.51.1

func (p *CancelOrderRequest) Category(category Category) *CancelOrderRequest

func (*CancelOrderRequest) Do added in v1.51.1

Do generates the request object and send the request object to the API endpoint

func (*CancelOrderRequest) GetParameters added in v1.51.1

func (p *CancelOrderRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*CancelOrderRequest) GetParametersJSON added in v1.51.1

func (p *CancelOrderRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*CancelOrderRequest) GetParametersQuery added in v1.51.1

func (p *CancelOrderRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*CancelOrderRequest) GetPath added in v1.53.0

func (p *CancelOrderRequest) GetPath() string

GetPath returns the request path of the API

func (*CancelOrderRequest) GetQueryParameters added in v1.51.1

func (p *CancelOrderRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*CancelOrderRequest) GetSlugParameters added in v1.51.1

func (p *CancelOrderRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*CancelOrderRequest) GetSlugsMap added in v1.51.1

func (p *CancelOrderRequest) GetSlugsMap() (map[string]string, error)

func (*CancelOrderRequest) OrderFilter added in v1.51.1

func (p *CancelOrderRequest) OrderFilter(orderFilter string) *CancelOrderRequest

func (*CancelOrderRequest) OrderId added in v1.51.1

func (p *CancelOrderRequest) OrderId(orderId string) *CancelOrderRequest

func (*CancelOrderRequest) OrderLinkId added in v1.51.1

func (p *CancelOrderRequest) OrderLinkId(orderLinkId string) *CancelOrderRequest

func (*CancelOrderRequest) Symbol added in v1.51.1

func (p *CancelOrderRequest) Symbol(symbol string) *CancelOrderRequest

type CancelOrderResponse added in v1.51.1

type CancelOrderResponse struct {
	OrderId     string `json:"orderId"`
	OrderLinkId string `json:"orderLinkId"`
}

type Category

type Category string
const (
	CategorySpot Category = "spot"
)

type FeeRate added in v1.52.0

type FeeRate struct {
	Symbol       string           `json:"symbol"`
	TakerFeeRate fixedpoint.Value `json:"takerFeeRate"`
	MakerFeeRate fixedpoint.Value `json:"makerFeeRate"`
}

type FeeRates added in v1.52.0

type FeeRates struct {
	List []FeeRate `json:"list"`
}

type GetAccountInfoRequest

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

func (*GetAccountInfoRequest) Do

Do generates the request object and send the request object to the API endpoint

func (*GetAccountInfoRequest) GetParameters

func (g *GetAccountInfoRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetAccountInfoRequest) GetParametersJSON

func (g *GetAccountInfoRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetAccountInfoRequest) GetParametersQuery

func (g *GetAccountInfoRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetAccountInfoRequest) GetPath added in v1.53.0

func (g *GetAccountInfoRequest) GetPath() string

GetPath returns the request path of the API

func (*GetAccountInfoRequest) GetQueryParameters

func (g *GetAccountInfoRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetAccountInfoRequest) GetSlugParameters

func (g *GetAccountInfoRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetAccountInfoRequest) GetSlugsMap

func (g *GetAccountInfoRequest) GetSlugsMap() (map[string]string, error)

type GetFeeRatesRequest added in v1.52.0

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

func (*GetFeeRatesRequest) BaseCoin added in v1.52.0

func (g *GetFeeRatesRequest) BaseCoin(baseCoin string) *GetFeeRatesRequest

func (*GetFeeRatesRequest) Category added in v1.52.0

func (g *GetFeeRatesRequest) Category(category Category) *GetFeeRatesRequest

func (*GetFeeRatesRequest) Do added in v1.52.0

Do generates the request object and send the request object to the API endpoint

func (*GetFeeRatesRequest) GetParameters added in v1.52.0

func (g *GetFeeRatesRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetFeeRatesRequest) GetParametersJSON added in v1.52.0

func (g *GetFeeRatesRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetFeeRatesRequest) GetParametersQuery added in v1.52.0

func (g *GetFeeRatesRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetFeeRatesRequest) GetPath added in v1.53.0

func (g *GetFeeRatesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetFeeRatesRequest) GetQueryParameters added in v1.52.0

func (g *GetFeeRatesRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetFeeRatesRequest) GetSlugParameters added in v1.52.0

func (g *GetFeeRatesRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetFeeRatesRequest) GetSlugsMap added in v1.52.0

func (g *GetFeeRatesRequest) GetSlugsMap() (map[string]string, error)

func (*GetFeeRatesRequest) Symbol added in v1.52.0

func (g *GetFeeRatesRequest) Symbol(symbol string) *GetFeeRatesRequest

type GetInstrumentsInfoRequest

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

func (*GetInstrumentsInfoRequest) Category

func (*GetInstrumentsInfoRequest) Cursor

func (*GetInstrumentsInfoRequest) Do

Do generates the request object and send the request object to the API endpoint

func (*GetInstrumentsInfoRequest) GetParameters

func (g *GetInstrumentsInfoRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetInstrumentsInfoRequest) GetParametersJSON

func (g *GetInstrumentsInfoRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetInstrumentsInfoRequest) GetParametersQuery

func (g *GetInstrumentsInfoRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetInstrumentsInfoRequest) GetPath added in v1.53.0

func (g *GetInstrumentsInfoRequest) GetPath() string

GetPath returns the request path of the API

func (*GetInstrumentsInfoRequest) GetQueryParameters

func (g *GetInstrumentsInfoRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetInstrumentsInfoRequest) GetSlugParameters

func (g *GetInstrumentsInfoRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetInstrumentsInfoRequest) GetSlugsMap

func (g *GetInstrumentsInfoRequest) GetSlugsMap() (map[string]string, error)

func (*GetInstrumentsInfoRequest) Limit

func (*GetInstrumentsInfoRequest) Symbol

type GetKLinesRequest added in v1.52.0

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

func (*GetKLinesRequest) Category added in v1.52.0

func (g *GetKLinesRequest) Category(category Category) *GetKLinesRequest

func (*GetKLinesRequest) Do added in v1.52.0

Do generates the request object and send the request object to the API endpoint

func (*GetKLinesRequest) EndTime added in v1.52.0

func (g *GetKLinesRequest) EndTime(endTime time.Time) *GetKLinesRequest

func (*GetKLinesRequest) GetParameters added in v1.52.0

func (g *GetKLinesRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetKLinesRequest) GetParametersJSON added in v1.52.0

func (g *GetKLinesRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetKLinesRequest) GetParametersQuery added in v1.52.0

func (g *GetKLinesRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetKLinesRequest) GetPath added in v1.53.0

func (g *GetKLinesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetKLinesRequest) GetQueryParameters added in v1.52.0

func (g *GetKLinesRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetKLinesRequest) GetSlugParameters added in v1.52.0

func (g *GetKLinesRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetKLinesRequest) GetSlugsMap added in v1.52.0

func (g *GetKLinesRequest) GetSlugsMap() (map[string]string, error)

func (*GetKLinesRequest) Interval added in v1.52.0

func (g *GetKLinesRequest) Interval(interval string) *GetKLinesRequest

func (*GetKLinesRequest) Limit added in v1.52.0

func (g *GetKLinesRequest) Limit(limit uint64) *GetKLinesRequest

func (*GetKLinesRequest) StartTime added in v1.52.0

func (g *GetKLinesRequest) StartTime(startTime time.Time) *GetKLinesRequest

func (*GetKLinesRequest) Symbol added in v1.52.0

func (g *GetKLinesRequest) Symbol(symbol string) *GetKLinesRequest

type GetOpenOrdersRequest added in v1.51.1

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

func (*GetOpenOrdersRequest) BaseCoin added in v1.51.1

func (g *GetOpenOrdersRequest) BaseCoin(baseCoin string) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) Category added in v1.51.1

func (g *GetOpenOrdersRequest) Category(category Category) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) Cursor added in v1.51.1

func (*GetOpenOrdersRequest) Do added in v1.51.1

Do generates the request object and send the request object to the API endpoint

func (*GetOpenOrdersRequest) GetParameters added in v1.51.1

func (g *GetOpenOrdersRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetOpenOrdersRequest) GetParametersJSON added in v1.51.1

func (g *GetOpenOrdersRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetOpenOrdersRequest) GetParametersQuery added in v1.51.1

func (g *GetOpenOrdersRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetOpenOrdersRequest) GetPath added in v1.53.0

func (g *GetOpenOrdersRequest) GetPath() string

GetPath returns the request path of the API

func (*GetOpenOrdersRequest) GetQueryParameters added in v1.51.1

func (g *GetOpenOrdersRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetOpenOrdersRequest) GetSlugParameters added in v1.51.1

func (g *GetOpenOrdersRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetOpenOrdersRequest) GetSlugsMap added in v1.51.1

func (g *GetOpenOrdersRequest) GetSlugsMap() (map[string]string, error)

func (*GetOpenOrdersRequest) Limit added in v1.51.1

func (*GetOpenOrdersRequest) OpenOnly added in v1.51.1

func (g *GetOpenOrdersRequest) OpenOnly(openOnly OpenOnly) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) OrderFilter added in v1.51.1

func (g *GetOpenOrdersRequest) OrderFilter(orderFilter string) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) OrderId added in v1.51.1

func (g *GetOpenOrdersRequest) OrderId(orderId string) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) OrderLinkId added in v1.51.1

func (g *GetOpenOrdersRequest) OrderLinkId(orderLinkId string) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) SettleCoin added in v1.51.1

func (g *GetOpenOrdersRequest) SettleCoin(settleCoin string) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) Symbol added in v1.51.1

type GetOrderHistoriesRequest added in v1.51.1

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

func (*GetOrderHistoriesRequest) Category added in v1.51.1

func (*GetOrderHistoriesRequest) Cursor added in v1.51.1

func (*GetOrderHistoriesRequest) Do added in v1.51.1

Do generates the request object and send the request object to the API endpoint

func (*GetOrderHistoriesRequest) EndTime added in v1.51.1

func (*GetOrderHistoriesRequest) GetParameters added in v1.51.1

func (g *GetOrderHistoriesRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetOrderHistoriesRequest) GetParametersJSON added in v1.51.1

func (g *GetOrderHistoriesRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetOrderHistoriesRequest) GetParametersQuery added in v1.51.1

func (g *GetOrderHistoriesRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetOrderHistoriesRequest) GetPath added in v1.53.0

func (g *GetOrderHistoriesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetOrderHistoriesRequest) GetQueryParameters added in v1.51.1

func (g *GetOrderHistoriesRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetOrderHistoriesRequest) GetSlugParameters added in v1.51.1

func (g *GetOrderHistoriesRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetOrderHistoriesRequest) GetSlugsMap added in v1.51.1

func (g *GetOrderHistoriesRequest) GetSlugsMap() (map[string]string, error)

func (*GetOrderHistoriesRequest) Limit added in v1.51.1

func (*GetOrderHistoriesRequest) OrderFilter added in v1.51.1

func (g *GetOrderHistoriesRequest) OrderFilter(orderFilter string) *GetOrderHistoriesRequest

func (*GetOrderHistoriesRequest) OrderId added in v1.51.1

func (*GetOrderHistoriesRequest) OrderLinkId added in v1.52.0

func (g *GetOrderHistoriesRequest) OrderLinkId(orderLinkId string) *GetOrderHistoriesRequest

func (*GetOrderHistoriesRequest) OrderStatus added in v1.51.1

func (g *GetOrderHistoriesRequest) OrderStatus(orderStatus OrderStatus) *GetOrderHistoriesRequest

func (*GetOrderHistoriesRequest) StartTime added in v1.51.1

func (*GetOrderHistoriesRequest) Symbol added in v1.51.1

type GetTickersRequest added in v1.51.1

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

GetTickersRequest without **-responseDataType .InstrumentsInfo** in generation command, because the caller needs the APIResponse.Time. We implemented the DoWithResponseTime to handle this.

func (*GetTickersRequest) Category added in v1.51.1

func (g *GetTickersRequest) Category(category Category) *GetTickersRequest

func (*GetTickersRequest) Do added in v1.51.1

Do generates the request object and send the request object to the API endpoint

func (*GetTickersRequest) DoWithResponseTime added in v1.51.1

func (g *GetTickersRequest) DoWithResponseTime(ctx context.Context) (*Tickers, error)

func (*GetTickersRequest) GetParameters added in v1.51.1

func (g *GetTickersRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetTickersRequest) GetParametersJSON added in v1.51.1

func (g *GetTickersRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetTickersRequest) GetParametersQuery added in v1.51.1

func (g *GetTickersRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetTickersRequest) GetPath added in v1.53.0

func (g *GetTickersRequest) GetPath() string

GetPath returns the request path of the API

func (*GetTickersRequest) GetQueryParameters added in v1.51.1

func (g *GetTickersRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetTickersRequest) GetSlugParameters added in v1.51.1

func (g *GetTickersRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetTickersRequest) GetSlugsMap added in v1.51.1

func (g *GetTickersRequest) GetSlugsMap() (map[string]string, error)

func (*GetTickersRequest) Symbol added in v1.51.1

func (g *GetTickersRequest) Symbol(symbol string) *GetTickersRequest

type GetWalletBalancesRequest added in v1.52.0

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

func (*GetWalletBalancesRequest) AccountType added in v1.52.0

func (g *GetWalletBalancesRequest) AccountType(accountType AccountType) *GetWalletBalancesRequest

func (*GetWalletBalancesRequest) Coin added in v1.52.0

func (*GetWalletBalancesRequest) Do added in v1.52.0

Do generates the request object and send the request object to the API endpoint

func (*GetWalletBalancesRequest) GetParameters added in v1.52.0

func (g *GetWalletBalancesRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*GetWalletBalancesRequest) GetParametersJSON added in v1.52.0

func (g *GetWalletBalancesRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetWalletBalancesRequest) GetParametersQuery added in v1.52.0

func (g *GetWalletBalancesRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*GetWalletBalancesRequest) GetPath added in v1.53.0

func (g *GetWalletBalancesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetWalletBalancesRequest) GetQueryParameters added in v1.52.0

func (g *GetWalletBalancesRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*GetWalletBalancesRequest) GetSlugParameters added in v1.52.0

func (g *GetWalletBalancesRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*GetWalletBalancesRequest) GetSlugsMap added in v1.52.0

func (g *GetWalletBalancesRequest) GetSlugsMap() (map[string]string, error)

type Instrument added in v1.51.1

type Instrument struct {
	Symbol        string `json:"symbol"`
	BaseCoin      string `json:"baseCoin"`
	QuoteCoin     string `json:"quoteCoin"`
	Innovation    string `json:"innovation"`
	Status        Status `json:"status"`
	MarginTrading string `json:"marginTrading"`
	LotSizeFilter struct {
		BasePrecision  fixedpoint.Value `json:"basePrecision"`
		QuotePrecision fixedpoint.Value `json:"quotePrecision"`
		MinOrderQty    fixedpoint.Value `json:"minOrderQty"`
		MaxOrderQty    fixedpoint.Value `json:"maxOrderQty"`
		MinOrderAmt    fixedpoint.Value `json:"minOrderAmt"`
		MaxOrderAmt    fixedpoint.Value `json:"maxOrderAmt"`
	} `json:"lotSizeFilter"`

	PriceFilter struct {
		TickSize fixedpoint.Value `json:"tickSize"`
	} `json:"priceFilter"`
}

type InstrumentsInfo

type InstrumentsInfo struct {
	Category Category     `json:"category"`
	List     []Instrument `json:"list"`
}

type IntervalSign added in v1.52.0

type IntervalSign string
const (
	IntervalSignDay   IntervalSign = "D"
	IntervalSignWeek  IntervalSign = "W"
	IntervalSignMonth IntervalSign = "M"
)

type KLine added in v1.52.0

type KLine struct {
	// list[0]: startTime, Start time of the candle (ms)
	StartTime types.MillisecondTimestamp
	// list[1]: openPrice
	Open fixedpoint.Value
	// list[2]: highPrice
	High fixedpoint.Value
	// list[3]: lowPrice
	Low fixedpoint.Value
	// list[4]: closePrice
	Close fixedpoint.Value
	// list[5]: volume, Trade volume. Unit of contract: pieces of contract. Unit of spot: quantity of coins
	Volume fixedpoint.Value
	// list[6]: turnover, Turnover. Unit of figure: quantity of quota coin
	TurnOver fixedpoint.Value
}

func (*KLine) UnmarshalJSON added in v1.52.0

func (k *KLine) UnmarshalJSON(data []byte) error

type KLinesResponse added in v1.52.0

type KLinesResponse struct {
	Symbol string `json:"symbol"`
	// An string array of individual candle
	// Sort in reverse by startTime
	List     []KLine  `json:"list"`
	Category Category `json:"category"`
}

type OpenOnly added in v1.51.1

type OpenOnly int
const (
	OpenOnlyOrder OpenOnly = 0
)

type Order added in v1.51.1

type Order struct {
	OrderId     string                     `json:"orderId"`
	OrderLinkId string                     `json:"orderLinkId"`
	Symbol      string                     `json:"symbol"`
	Side        Side                       `json:"side"`
	OrderStatus OrderStatus                `json:"orderStatus"`
	OrderType   OrderType                  `json:"orderType"`
	TimeInForce TimeInForce                `json:"timeInForce"`
	Price       fixedpoint.Value           `json:"price"`
	CreatedTime types.MillisecondTimestamp `json:"createdTime"`
	UpdatedTime types.MillisecondTimestamp `json:"updatedTime"`

	// Qty represents **quote coin** if order is market buy
	Qty fixedpoint.Value `json:"qty"`

	// AvgPrice is supported in both RESTful API and WebSocket.
	//
	// For websocket must notice that:
	// - Normal account is not supported.
	// - For normal account USDT Perp and Inverse derivatives trades, if a partially filled order, and the
	// final orderStatus is Cancelled, then avgPrice is "0"
	AvgPrice fixedpoint.Value `json:"avgPrice"`

	// CumExecQty is supported in both RESTful API and WebSocket.
	CumExecQty fixedpoint.Value `json:"cumExecQty"`

	// CumExecValue is supported in both RESTful API and WebSocket.
	// However, it's **not** supported for **normal accounts** in RESTful API.
	CumExecValue fixedpoint.Value `json:"cumExecValue"`

	// CumExecFee is supported in both RESTful API and WebSocket.
	// However, it's **not** supported for **normal accounts** in RESTful API.
	// For websocket normal spot, it is the execution fee per single fill.
	CumExecFee fixedpoint.Value `json:"cumExecFee"`

	BlockTradeId       string           `json:"blockTradeId"`
	IsLeverage         string           `json:"isLeverage"`
	PositionIdx        int              `json:"positionIdx"`
	CancelType         string           `json:"cancelType"`
	RejectReason       string           `json:"rejectReason"`
	LeavesQty          fixedpoint.Value `json:"leavesQty"`
	LeavesValue        fixedpoint.Value `json:"leavesValue"`
	StopOrderType      string           `json:"stopOrderType"`
	OrderIv            string           `json:"orderIv"`
	TriggerPrice       fixedpoint.Value `json:"triggerPrice"`
	TakeProfit         fixedpoint.Value `json:"takeProfit"`
	StopLoss           fixedpoint.Value `json:"stopLoss"`
	TpTriggerBy        string           `json:"tpTriggerBy"`
	SlTriggerBy        string           `json:"slTriggerBy"`
	TriggerDirection   int              `json:"triggerDirection"`
	TriggerBy          string           `json:"triggerBy"`
	LastPriceOnCreated string           `json:"lastPriceOnCreated"`
	ReduceOnly         bool             `json:"reduceOnly"`
	CloseOnTrigger     bool             `json:"closeOnTrigger"`
	SmpType            string           `json:"smpType"`
	SmpGroup           int              `json:"smpGroup"`
	SmpOrderId         string           `json:"smpOrderId"`
	TpslMode           string           `json:"tpslMode"`
	TpLimitPrice       string           `json:"tpLimitPrice"`
	SlLimitPrice       string           `json:"slLimitPrice"`
	PlaceType          string           `json:"placeType"`
}

type OrderStatus added in v1.51.1

type OrderStatus string
const (
	// OrderStatusCreated order has been accepted by the system but not yet put through the matching engine
	OrderStatusCreated OrderStatus = "Created"
	// OrderStatusNew is order has been placed successfully.
	OrderStatusNew             OrderStatus = "New"
	OrderStatusRejected        OrderStatus = "Rejected"
	OrderStatusPartiallyFilled OrderStatus = "PartiallyFilled"
	// OrderStatusPartiallyFilledCanceled means that the order has been partially filled but not all then cancel.
	OrderStatusPartiallyFilledCanceled OrderStatus = "PartiallyFilledCanceled"
	OrderStatusFilled                  OrderStatus = "Filled"
	OrderStatusCancelled               OrderStatus = "Cancelled"

	// Following statuses is stop orders
	// OrderStatusDeactivated is an order status for stopOrders.
	//e.g. when you place a conditional order, then you cancel it, this order status is "Deactivated"
	OrderStatusDeactivated OrderStatus = "Deactivated"

	// OrderStatusActive order has been triggered and the new active order has been successfully placed. Is the final
	// state of a successful conditional order
	OrderStatusActive OrderStatus = "Active"
)

type OrderType added in v1.51.1

type OrderType string
const (
	OrderTypeMarket OrderType = "Market"
	OrderTypeLimit  OrderType = "Limit"
)

type OrdersResponse added in v1.51.1

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

type PlaceOrderRequest added in v1.51.1

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

func (*PlaceOrderRequest) Category added in v1.51.1

func (p *PlaceOrderRequest) Category(category Category) *PlaceOrderRequest

func (*PlaceOrderRequest) CloseOnTrigger added in v1.51.1

func (p *PlaceOrderRequest) CloseOnTrigger(closeOnTrigger bool) *PlaceOrderRequest

func (*PlaceOrderRequest) Do added in v1.51.1

Do generates the request object and send the request object to the API endpoint

func (*PlaceOrderRequest) GetParameters added in v1.51.1

func (p *PlaceOrderRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*PlaceOrderRequest) GetParametersJSON added in v1.51.1

func (p *PlaceOrderRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*PlaceOrderRequest) GetParametersQuery added in v1.51.1

func (p *PlaceOrderRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*PlaceOrderRequest) GetPath added in v1.53.0

func (p *PlaceOrderRequest) GetPath() string

GetPath returns the request path of the API

func (*PlaceOrderRequest) GetQueryParameters added in v1.51.1

func (p *PlaceOrderRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*PlaceOrderRequest) GetSlugParameters added in v1.51.1

func (p *PlaceOrderRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*PlaceOrderRequest) GetSlugsMap added in v1.51.1

func (p *PlaceOrderRequest) GetSlugsMap() (map[string]string, error)

func (*PlaceOrderRequest) IsLeverage added in v1.51.1

func (p *PlaceOrderRequest) IsLeverage(isLeverage bool) *PlaceOrderRequest

func (*PlaceOrderRequest) Mmp added in v1.51.1

func (*PlaceOrderRequest) OrderFilter added in v1.51.1

func (p *PlaceOrderRequest) OrderFilter(orderFilter string) *PlaceOrderRequest

func (*PlaceOrderRequest) OrderIv added in v1.51.1

func (p *PlaceOrderRequest) OrderIv(orderIv string) *PlaceOrderRequest

func (*PlaceOrderRequest) OrderLinkId added in v1.51.1

func (p *PlaceOrderRequest) OrderLinkId(orderLinkId string) *PlaceOrderRequest

func (*PlaceOrderRequest) OrderType added in v1.51.1

func (p *PlaceOrderRequest) OrderType(orderType OrderType) *PlaceOrderRequest

func (*PlaceOrderRequest) PositionIdx added in v1.51.1

func (p *PlaceOrderRequest) PositionIdx(positionIdx string) *PlaceOrderRequest

func (*PlaceOrderRequest) Price added in v1.51.1

func (p *PlaceOrderRequest) Price(price string) *PlaceOrderRequest

func (*PlaceOrderRequest) Qty added in v1.51.1

func (*PlaceOrderRequest) ReduceOnly added in v1.51.1

func (p *PlaceOrderRequest) ReduceOnly(reduceOnly bool) *PlaceOrderRequest

func (*PlaceOrderRequest) Side added in v1.51.1

func (p *PlaceOrderRequest) Side(side Side) *PlaceOrderRequest

func (*PlaceOrderRequest) SlLimitPrice added in v1.51.1

func (p *PlaceOrderRequest) SlLimitPrice(slLimitPrice string) *PlaceOrderRequest

func (*PlaceOrderRequest) SlOrderType added in v1.51.1

func (p *PlaceOrderRequest) SlOrderType(slOrderType string) *PlaceOrderRequest

func (*PlaceOrderRequest) SlTriggerBy added in v1.51.1

func (p *PlaceOrderRequest) SlTriggerBy(slTriggerBy string) *PlaceOrderRequest

func (*PlaceOrderRequest) SmpType added in v1.51.1

func (p *PlaceOrderRequest) SmpType(smpType string) *PlaceOrderRequest

func (*PlaceOrderRequest) StopLoss added in v1.51.1

func (p *PlaceOrderRequest) StopLoss(stopLoss string) *PlaceOrderRequest

func (*PlaceOrderRequest) Symbol added in v1.51.1

func (p *PlaceOrderRequest) Symbol(symbol string) *PlaceOrderRequest

func (*PlaceOrderRequest) TakeProfit added in v1.51.1

func (p *PlaceOrderRequest) TakeProfit(takeProfit string) *PlaceOrderRequest

func (*PlaceOrderRequest) TimeInForce added in v1.51.1

func (p *PlaceOrderRequest) TimeInForce(timeInForce TimeInForce) *PlaceOrderRequest

func (*PlaceOrderRequest) TpLimitPrice added in v1.51.1

func (p *PlaceOrderRequest) TpLimitPrice(tpLimitPrice string) *PlaceOrderRequest

func (*PlaceOrderRequest) TpOrderType added in v1.51.1

func (p *PlaceOrderRequest) TpOrderType(tpOrderType string) *PlaceOrderRequest

func (*PlaceOrderRequest) TpTriggerBy added in v1.51.1

func (p *PlaceOrderRequest) TpTriggerBy(tpTriggerBy string) *PlaceOrderRequest

func (*PlaceOrderRequest) TpslMode added in v1.51.1

func (p *PlaceOrderRequest) TpslMode(tpslMode string) *PlaceOrderRequest

func (*PlaceOrderRequest) TriggerBy added in v1.51.1

func (p *PlaceOrderRequest) TriggerBy(triggerBy string) *PlaceOrderRequest

func (*PlaceOrderRequest) TriggerDirection added in v1.51.1

func (p *PlaceOrderRequest) TriggerDirection(triggerDirection int) *PlaceOrderRequest

func (*PlaceOrderRequest) TriggerPrice added in v1.51.1

func (p *PlaceOrderRequest) TriggerPrice(triggerPrice string) *PlaceOrderRequest

type PlaceOrderResponse added in v1.51.1

type PlaceOrderResponse struct {
	OrderId     string `json:"orderId"`
	OrderLinkId string `json:"orderLinkId"`
}

type RestClient

type RestClient struct {
	requestgen.BaseAPIClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*RestClient, error)

func (*RestClient) Auth

func (c *RestClient) Auth(key, secret string)

func (*RestClient) NewAuthenticatedRequest

func (c *RestClient) NewAuthenticatedRequest(ctx context.Context, method, refURL string, params url.Values, payload interface{}) (*http.Request, error)

newAuthenticatedRequest creates new http request for authenticated routes.

func (*RestClient) NewCancelOrderRequest added in v1.51.1

func (c *RestClient) NewCancelOrderRequest() *CancelOrderRequest

func (*RestClient) NewGetAccountRequest

func (c *RestClient) NewGetAccountRequest() *GetAccountInfoRequest

func (*RestClient) NewGetFeeRatesRequest added in v1.52.0

func (c *RestClient) NewGetFeeRatesRequest() *GetFeeRatesRequest

func (*RestClient) NewGetInstrumentsInfoRequest

func (c *RestClient) NewGetInstrumentsInfoRequest() *GetInstrumentsInfoRequest

func (*RestClient) NewGetKLinesRequest added in v1.52.0

func (c *RestClient) NewGetKLinesRequest() *GetKLinesRequest

func (*RestClient) NewGetOpenOrderRequest added in v1.51.1

func (c *RestClient) NewGetOpenOrderRequest() *GetOpenOrdersRequest

NewGetOpenOrderRequest queries unfilled or partially filled orders in real-time. To query older order records, please use the order history interface.

func (*RestClient) NewGetOrderHistoriesRequest added in v1.51.1

func (c *RestClient) NewGetOrderHistoriesRequest() *GetOrderHistoriesRequest

NewGetOrderHistoriesRequest is descending order by createdTime

func (*RestClient) NewGetTickersRequest added in v1.51.1

func (c *RestClient) NewGetTickersRequest() *GetTickersRequest

func (*RestClient) NewGetWalletBalancesRequest added in v1.52.0

func (c *RestClient) NewGetWalletBalancesRequest() *GetWalletBalancesRequest

func (*RestClient) NewPlaceOrderRequest added in v1.51.1

func (c *RestClient) NewPlaceOrderRequest() *PlaceOrderRequest

type Side added in v1.51.1

type Side string
const (
	SideBuy  Side = "Buy"
	SideSell Side = "Sell"
)

type Status

type Status string
const (
	// StatusTrading is only include the "Trading" status for `spot` category.
	StatusTrading Status = "Trading"
)

type Ticker added in v1.51.1

type Ticker struct {
	Symbol        string           `json:"symbol"`
	Bid1Price     fixedpoint.Value `json:"bid1Price"`
	Bid1Size      fixedpoint.Value `json:"bid1Size"`
	Ask1Price     fixedpoint.Value `json:"ask1Price"`
	Ask1Size      fixedpoint.Value `json:"ask1Size"`
	LastPrice     fixedpoint.Value `json:"lastPrice"`
	PrevPrice24H  fixedpoint.Value `json:"prevPrice24h"`
	Price24HPcnt  fixedpoint.Value `json:"price24hPcnt"`
	HighPrice24H  fixedpoint.Value `json:"highPrice24h"`
	LowPrice24H   fixedpoint.Value `json:"lowPrice24h"`
	Turnover24H   fixedpoint.Value `json:"turnover24h"`
	Volume24H     fixedpoint.Value `json:"volume24h"`
	UsdIndexPrice fixedpoint.Value `json:"usdIndexPrice"`
}

type Tickers added in v1.51.1

type Tickers struct {
	Category Category `json:"category"`
	List     []Ticker `json:"list"`

	// ClosedTime is current timestamp (ms). This value is obtained from outside APIResponse.
	ClosedTime types.MillisecondTimestamp
}

type TimeInForce added in v1.51.1

type TimeInForce string
const (
	TimeInForceGTC TimeInForce = "GTC"
	TimeInForceIOC TimeInForce = "IOC"
	TimeInForceFOK TimeInForce = "FOK"
)

type WalletBalances added in v1.52.0

type WalletBalances struct {
	AccountType            AccountType      `json:"accountType"`
	AccountIMRate          fixedpoint.Value `json:"accountIMRate"`
	AccountMMRate          fixedpoint.Value `json:"accountMMRate"`
	TotalEquity            fixedpoint.Value `json:"totalEquity"`
	TotalWalletBalance     fixedpoint.Value `json:"totalWalletBalance"`
	TotalMarginBalance     fixedpoint.Value `json:"totalMarginBalance"`
	TotalAvailableBalance  fixedpoint.Value `json:"totalAvailableBalance"`
	TotalPerpUPL           fixedpoint.Value `json:"totalPerpUPL"`
	TotalInitialMargin     fixedpoint.Value `json:"totalInitialMargin"`
	TotalMaintenanceMargin fixedpoint.Value `json:"totalMaintenanceMargin"`
	// Account LTV: account total borrowed size / (account total equity + account total borrowed size).
	// In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
	AccountLTV fixedpoint.Value `json:"accountLTV"`
	Coins      []struct {
		Coin string `json:"coin"`
		// Equity of current coin
		Equity fixedpoint.Value `json:"equity"`
		// UsdValue of current coin. If this coin cannot be collateral, then it is 0
		UsdValue fixedpoint.Value `json:"usdValue"`
		// WalletBalance of current coin
		WalletBalance fixedpoint.Value `json:"walletBalance"`
		// Free available balance for Spot wallet. This is a unique field for Normal SPOT
		Free fixedpoint.Value
		// Locked balance for Spot wallet. This is a unique field for Normal SPOT
		Locked fixedpoint.Value
		// Available amount to withdraw of current coin
		AvailableToWithdraw fixedpoint.Value `json:"availableToWithdraw"`
		// Available amount to borrow of current coin
		AvailableToBorrow fixedpoint.Value `json:"availableToBorrow"`
		// Borrow amount of current coin
		BorrowAmount fixedpoint.Value `json:"borrowAmount"`
		// Accrued interest
		AccruedInterest fixedpoint.Value `json:"accruedInterest"`
		// Pre-occupied margin for order. For portfolio margin mode, it returns ""
		TotalOrderIM fixedpoint.Value `json:"totalOrderIM"`
		// Sum of initial margin of all positions + Pre-occupied liquidation fee. For portfolio margin mode, it returns ""
		TotalPositionIM fixedpoint.Value `json:"totalPositionIM"`
		// Sum of maintenance margin for all positions. For portfolio margin mode, it returns ""
		TotalPositionMM fixedpoint.Value `json:"totalPositionMM"`
		// Unrealised P&L
		UnrealisedPnl fixedpoint.Value `json:"unrealisedPnl"`
		// Cumulative Realised P&L
		CumRealisedPnl fixedpoint.Value `json:"cumRealisedPnl"`
		// Bonus. This is a unique field for UNIFIED account
		Bonus fixedpoint.Value `json:"bonus"`
		// Whether it can be used as a margin collateral currency (platform)
		// - When marginCollateral=false, then collateralSwitch is meaningless
		// -  This is a unique field for UNIFIED account
		CollateralSwitch bool `json:"collateralSwitch"`
		// Whether the collateral is turned on by user (user)
		// - When marginCollateral=true, then collateralSwitch is meaningful
		// - This is a unique field for UNIFIED account
		MarginCollateral bool `json:"marginCollateral"`
	} `json:"coin"`
}

type WalletBalancesResponse added in v1.52.0

type WalletBalancesResponse struct {
	List []WalletBalances `json:"list"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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