bybitapi

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 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

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

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

func (a APIResponse) Error() error

func (APIResponse) Validate

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

type AccountType string
const AccountTypeSpot AccountType = "SPOT"

type CancelOrderRequest

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

func (*CancelOrderRequest) Category

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

func (*CancelOrderRequest) Do

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

func (*CancelOrderRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*CancelOrderRequest) GetParametersQuery

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

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

func (*CancelOrderRequest) GetPath

func (p *CancelOrderRequest) GetPath() string

GetPath returns the request path of the API

func (*CancelOrderRequest) GetQueryParameters

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

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

func (*CancelOrderRequest) GetSlugParameters

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

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

func (*CancelOrderRequest) OrderFilter

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

func (*CancelOrderRequest) OrderId

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

func (*CancelOrderRequest) OrderLinkId

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

func (*CancelOrderRequest) Symbol

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

type CancelOrderResponse

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

type Category

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

type FeeRate

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

type FeeRates

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

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

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

func (*GetFeeRatesRequest) BaseCoin

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

func (*GetFeeRatesRequest) Category

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

func (*GetFeeRatesRequest) Do

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

func (*GetFeeRatesRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetFeeRatesRequest) GetParametersQuery

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

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

func (*GetFeeRatesRequest) GetPath

func (g *GetFeeRatesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetFeeRatesRequest) GetQueryParameters

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

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

func (*GetFeeRatesRequest) GetSlugParameters

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

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

func (*GetFeeRatesRequest) Symbol

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

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

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

func (*GetKLinesRequest) Category

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

func (*GetKLinesRequest) Do

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

func (*GetKLinesRequest) EndTime

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

func (*GetKLinesRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetKLinesRequest) GetParametersQuery

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

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

func (*GetKLinesRequest) GetPath

func (g *GetKLinesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetKLinesRequest) GetQueryParameters

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

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

func (*GetKLinesRequest) GetSlugParameters

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

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

func (*GetKLinesRequest) Interval

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

func (*GetKLinesRequest) Limit

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

func (*GetKLinesRequest) StartTime

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

func (*GetKLinesRequest) Symbol

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

type GetOpenOrdersRequest

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

func (*GetOpenOrdersRequest) BaseCoin

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

func (*GetOpenOrdersRequest) Category

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

func (*GetOpenOrdersRequest) Cursor

func (*GetOpenOrdersRequest) Do

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

func (*GetOpenOrdersRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetOpenOrdersRequest) GetParametersQuery

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

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

func (*GetOpenOrdersRequest) GetPath

func (g *GetOpenOrdersRequest) GetPath() string

GetPath returns the request path of the API

func (*GetOpenOrdersRequest) GetQueryParameters

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

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

func (*GetOpenOrdersRequest) GetSlugParameters

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

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

func (*GetOpenOrdersRequest) Limit

func (*GetOpenOrdersRequest) OpenOnly

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

func (*GetOpenOrdersRequest) OrderFilter

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

func (*GetOpenOrdersRequest) OrderId

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

func (*GetOpenOrdersRequest) OrderLinkId

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

func (*GetOpenOrdersRequest) SettleCoin

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

func (*GetOpenOrdersRequest) Symbol

type GetOrderHistoriesRequest

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

func (*GetOrderHistoriesRequest) Category

func (*GetOrderHistoriesRequest) Cursor

func (*GetOrderHistoriesRequest) Do

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

func (*GetOrderHistoriesRequest) EndTime

func (*GetOrderHistoriesRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetOrderHistoriesRequest) GetParametersQuery

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

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

func (*GetOrderHistoriesRequest) GetPath

func (g *GetOrderHistoriesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetOrderHistoriesRequest) GetQueryParameters

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

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

func (*GetOrderHistoriesRequest) GetSlugParameters

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

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

func (*GetOrderHistoriesRequest) Limit

func (*GetOrderHistoriesRequest) OrderFilter

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

func (*GetOrderHistoriesRequest) OrderId

func (*GetOrderHistoriesRequest) OrderLinkId

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

func (*GetOrderHistoriesRequest) OrderStatus

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

func (*GetOrderHistoriesRequest) StartTime

func (*GetOrderHistoriesRequest) Symbol

type GetTickersRequest

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

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

func (*GetTickersRequest) Do

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

func (*GetTickersRequest) DoWithResponseTime

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

func (*GetTickersRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetTickersRequest) GetParametersQuery

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

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

func (*GetTickersRequest) GetPath

func (g *GetTickersRequest) GetPath() string

GetPath returns the request path of the API

func (*GetTickersRequest) GetQueryParameters

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

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

func (*GetTickersRequest) GetSlugParameters

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

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

func (*GetTickersRequest) Symbol

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

type GetWalletBalancesRequest

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

func (*GetWalletBalancesRequest) AccountType

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

func (*GetWalletBalancesRequest) Coin

func (*GetWalletBalancesRequest) Do

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

func (*GetWalletBalancesRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetWalletBalancesRequest) GetParametersQuery

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

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

func (*GetWalletBalancesRequest) GetPath

func (g *GetWalletBalancesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetWalletBalancesRequest) GetQueryParameters

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

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

func (*GetWalletBalancesRequest) GetSlugParameters

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

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

type Instrument

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

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

type KLine

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

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

type KLinesResponse

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

type OpenOnly int
const (
	OpenOnlyOrder OpenOnly = 0
)

type Order

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

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

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

type OrdersResponse

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

type PlaceOrderRequest

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

func (*PlaceOrderRequest) Category

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

func (*PlaceOrderRequest) CloseOnTrigger

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

func (*PlaceOrderRequest) Do

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

func (*PlaceOrderRequest) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*PlaceOrderRequest) GetParametersQuery

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

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

func (*PlaceOrderRequest) GetPath

func (p *PlaceOrderRequest) GetPath() string

GetPath returns the request path of the API

func (*PlaceOrderRequest) GetQueryParameters

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

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

func (*PlaceOrderRequest) GetSlugParameters

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

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

func (*PlaceOrderRequest) IsLeverage

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

func (*PlaceOrderRequest) Mmp

func (*PlaceOrderRequest) OrderFilter

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

func (*PlaceOrderRequest) OrderIv

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

func (*PlaceOrderRequest) OrderLinkId

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

func (*PlaceOrderRequest) OrderType

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

func (*PlaceOrderRequest) PositionIdx

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

func (*PlaceOrderRequest) Price

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

func (*PlaceOrderRequest) Qty

func (*PlaceOrderRequest) ReduceOnly

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

func (*PlaceOrderRequest) Side

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

func (*PlaceOrderRequest) SlLimitPrice

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

func (*PlaceOrderRequest) SlOrderType

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

func (*PlaceOrderRequest) SlTriggerBy

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

func (*PlaceOrderRequest) SmpType

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

func (*PlaceOrderRequest) StopLoss

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

func (*PlaceOrderRequest) Symbol

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

func (*PlaceOrderRequest) TakeProfit

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

func (*PlaceOrderRequest) TimeInForce

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

func (*PlaceOrderRequest) TpLimitPrice

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

func (*PlaceOrderRequest) TpOrderType

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

func (*PlaceOrderRequest) TpTriggerBy

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

func (*PlaceOrderRequest) TpslMode

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

func (*PlaceOrderRequest) TriggerBy

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

func (*PlaceOrderRequest) TriggerDirection

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

func (*PlaceOrderRequest) TriggerPrice

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

type PlaceOrderResponse

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

func (c *RestClient) NewCancelOrderRequest() *CancelOrderRequest

func (*RestClient) NewGetAccountRequest

func (c *RestClient) NewGetAccountRequest() *GetAccountInfoRequest

func (*RestClient) NewGetFeeRatesRequest

func (c *RestClient) NewGetFeeRatesRequest() *GetFeeRatesRequest

func (*RestClient) NewGetInstrumentsInfoRequest

func (c *RestClient) NewGetInstrumentsInfoRequest() *GetInstrumentsInfoRequest

func (*RestClient) NewGetKLinesRequest

func (c *RestClient) NewGetKLinesRequest() *GetKLinesRequest

func (*RestClient) NewGetOpenOrderRequest

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

func (c *RestClient) NewGetOrderHistoriesRequest() *GetOrderHistoriesRequest

NewGetOrderHistoriesRequest is descending order by createdTime

func (*RestClient) NewGetTickersRequest

func (c *RestClient) NewGetTickersRequest() *GetTickersRequest

func (*RestClient) NewGetWalletBalancesRequest

func (c *RestClient) NewGetWalletBalancesRequest() *GetWalletBalancesRequest

func (*RestClient) NewPlaceOrderRequest

func (c *RestClient) NewPlaceOrderRequest() *PlaceOrderRequest

type Side

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

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

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

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

type WalletBalances

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

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