okexapi

package
v1.60.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: AGPL-3.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LiquidityTypeMaker = "M"
	LiquidityTypeTaker = "T"
)
View Source
const PrivateWebSocketURL = "wss://wsaws.okx.com:8443/ws/v5/private"
View Source
const PublicBusinessWebSocketURL = "wss://wsaws.okx.com:8443/ws/v5/business"
View Source
const PublicWebSocketURL = "wss://wsaws.okx.com:8443/ws/v5/public"
View Source
const RestBaseURL = "https://aws.okx.com/"

Variables

View Source
var GetThreeDaysTransactionHistoryRequestLimiter = rate.NewLimiter(30.000000300000004, 1)
View Source
var GetTransactionHistoryRequestLimiter = rate.NewLimiter(5, 1)

Functions

func Sign

func Sign(payload string, secret string) string

Types

type APIResponse added in v1.52.0

type APIResponse struct {
	Code    string          `json:"code"`
	Message string          `json:"msg"`
	Data    json.RawMessage `json:"data"`
}

func (APIResponse) Error added in v1.57.0

func (a APIResponse) Error() error

func (APIResponse) Validate added in v1.57.0

func (a APIResponse) Validate() error

type Account

type Account struct {
	TotalEquityInUSD fixedpoint.Value           `json:"totalEq"`
	UpdateTime       types.MillisecondTimestamp `json:"uTime"`
	Details          []BalanceDetail            `json:"details"`
}

type AssetBalance

type AssetBalance struct {
	Currency  string           `json:"ccy"`
	Balance   fixedpoint.Value `json:"bal"`
	Frozen    fixedpoint.Value `json:"frozenBal,omitempty"`
	Available fixedpoint.Value `json:"availBal,omitempty"`
}

type AssetBalanceList

type AssetBalanceList []AssetBalance

type AssetCurrency

type AssetCurrency struct {
	Currency               string           `json:"ccy"`
	Name                   string           `json:"name"`
	Chain                  string           `json:"chain"`
	CanDeposit             bool             `json:"canDep"`
	CanWithdraw            bool             `json:"canWd"`
	CanInternal            bool             `json:"canInternal"`
	MinWithdrawalFee       fixedpoint.Value `json:"minFee"`
	MaxWithdrawalFee       fixedpoint.Value `json:"maxFee"`
	MinWithdrawalThreshold fixedpoint.Value `json:"minWd"`
}

type BalanceDetail

type BalanceDetail struct {
	Currency                string                     `json:"ccy"`
	Available               fixedpoint.Value           `json:"availEq"`
	CashBalance             fixedpoint.Value           `json:"cashBal"`
	OrderFrozen             fixedpoint.Value           `json:"ordFrozen"`
	Frozen                  fixedpoint.Value           `json:"frozenBal"`
	Equity                  fixedpoint.Value           `json:"eq"`
	EquityInUSD             fixedpoint.Value           `json:"eqUsd"`
	UpdateTime              types.MillisecondTimestamp `json:"uTime"`
	UnrealizedProfitAndLoss fixedpoint.Value           `json:"upl"`
}

type BatchCancelOrderRequest

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

func (*BatchCancelOrderRequest) Add

func (*BatchCancelOrderRequest) Do

type BatchPlaceOrderRequest

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

func (*BatchPlaceOrderRequest) Add

func (*BatchPlaceOrderRequest) Do

type CancelOrderRequest

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

func (*CancelOrderRequest) ClientOrderID

func (c *CancelOrderRequest) ClientOrderID(clientOrderID string) *CancelOrderRequest

func (*CancelOrderRequest) Do

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

func (*CancelOrderRequest) GetParameters added in v1.21.0

func (c *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.21.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*CancelOrderRequest) GetParametersQuery added in v1.21.0

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

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

func (*CancelOrderRequest) GetPath added in v1.56.0

func (c *CancelOrderRequest) GetPath() string

GetPath returns the request path of the API

func (*CancelOrderRequest) GetQueryParameters added in v1.56.0

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

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

func (*CancelOrderRequest) GetSlugParameters added in v1.56.0

func (c *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.56.0

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

func (*CancelOrderRequest) InstrumentID

func (c *CancelOrderRequest) InstrumentID(instrumentID string) *CancelOrderRequest

func (*CancelOrderRequest) OrderID

func (c *CancelOrderRequest) OrderID(orderID string) *CancelOrderRequest

type FundingRate

type FundingRate struct {
	InstrumentType  string                     `json:"instType"`
	InstrumentID    string                     `json:"instId"`
	FundingRate     fixedpoint.Value           `json:"fundingRate"`
	NextFundingRate fixedpoint.Value           `json:"nextFundingRate"`
	FundingTime     types.MillisecondTimestamp `json:"fundingTime"`
}

type GetAccountInfoRequest added in v1.56.0

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

func (*GetAccountInfoRequest) Do added in v1.56.0

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

func (*GetAccountInfoRequest) GetParameters added in v1.56.0

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 added in v1.56.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetAccountInfoRequest) GetParametersQuery added in v1.56.0

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

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

func (*GetAccountInfoRequest) GetPath added in v1.56.0

func (g *GetAccountInfoRequest) GetPath() string

GetPath returns the request path of the API

func (*GetAccountInfoRequest) GetQueryParameters added in v1.56.0

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

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

func (*GetAccountInfoRequest) GetSlugParameters added in v1.56.0

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 added in v1.56.0

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

type GetCandlesRequest added in v1.57.0

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

func (*GetCandlesRequest) After added in v1.57.0

func (g *GetCandlesRequest) After(after time.Time) *GetCandlesRequest

func (*GetCandlesRequest) Bar added in v1.57.0

func (*GetCandlesRequest) Before added in v1.57.0

func (g *GetCandlesRequest) Before(before time.Time) *GetCandlesRequest

func (*GetCandlesRequest) Do added in v1.57.0

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

func (*GetCandlesRequest) GetParameters added in v1.57.0

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

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

func (*GetCandlesRequest) GetParametersJSON added in v1.57.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetCandlesRequest) GetParametersQuery added in v1.57.0

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

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

func (*GetCandlesRequest) GetPath added in v1.57.0

func (g *GetCandlesRequest) GetPath() string

GetPath returns the request path of the API

func (*GetCandlesRequest) GetQueryParameters added in v1.57.0

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

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

func (*GetCandlesRequest) GetSlugParameters added in v1.57.0

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

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

func (*GetCandlesRequest) GetSlugsMap added in v1.57.0

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

func (*GetCandlesRequest) InstrumentID added in v1.57.0

func (g *GetCandlesRequest) InstrumentID(instrumentID string) *GetCandlesRequest

func (*GetCandlesRequest) Limit added in v1.57.0

func (g *GetCandlesRequest) Limit(limit int) *GetCandlesRequest

type GetFundingRateRequest

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

func (*GetFundingRateRequest) Do

func (*GetFundingRateRequest) InstrumentID

func (r *GetFundingRateRequest) InstrumentID(instId string) *GetFundingRateRequest

type GetInstrumentsInfoRequest added in v1.56.0

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

func (*GetInstrumentsInfoRequest) Do added in v1.56.0

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

func (*GetInstrumentsInfoRequest) GetParameters added in v1.56.0

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 added in v1.56.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetInstrumentsInfoRequest) GetParametersQuery added in v1.56.0

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

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

func (*GetInstrumentsInfoRequest) GetPath added in v1.56.0

func (g *GetInstrumentsInfoRequest) GetPath() string

GetPath returns the request path of the API

func (*GetInstrumentsInfoRequest) GetQueryParameters added in v1.56.0

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

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

func (*GetInstrumentsInfoRequest) GetSlugParameters added in v1.56.0

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 added in v1.56.0

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

func (*GetInstrumentsInfoRequest) InstId added in v1.56.0

func (*GetInstrumentsInfoRequest) InstType added in v1.56.0

type GetOpenOrdersRequest added in v1.56.0

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

func (*GetOpenOrdersRequest) After added in v1.56.0

func (*GetOpenOrdersRequest) Before added in v1.56.0

func (*GetOpenOrdersRequest) Begin added in v1.56.0

func (*GetOpenOrdersRequest) Category added in v1.56.0

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

func (*GetOpenOrdersRequest) Do added in v1.56.0

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

func (*GetOpenOrdersRequest) End added in v1.56.0

func (*GetOpenOrdersRequest) GetParameters added in v1.56.0

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.56.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetOpenOrdersRequest) GetParametersQuery added in v1.56.0

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

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

func (*GetOpenOrdersRequest) GetPath added in v1.56.0

func (g *GetOpenOrdersRequest) GetPath() string

GetPath returns the request path of the API

func (*GetOpenOrdersRequest) GetQueryParameters added in v1.56.0

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

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

func (*GetOpenOrdersRequest) GetSlugParameters added in v1.56.0

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.56.0

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

func (*GetOpenOrdersRequest) InstrumentID added in v1.56.0

func (g *GetOpenOrdersRequest) InstrumentID(instrumentID string) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) InstrumentType added in v1.56.0

func (g *GetOpenOrdersRequest) InstrumentType(instrumentType InstrumentType) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) Limit added in v1.56.0

func (*GetOpenOrdersRequest) OrderType added in v1.56.0

func (g *GetOpenOrdersRequest) OrderType(orderType OrderType) *GetOpenOrdersRequest

func (*GetOpenOrdersRequest) State added in v1.56.0

type GetOrderDetailsRequest

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

func (*GetOrderDetailsRequest) ClientOrderID

func (r *GetOrderDetailsRequest) ClientOrderID(clientOrderID string) *GetOrderDetailsRequest

func (*GetOrderDetailsRequest) Do

func (*GetOrderDetailsRequest) InstrumentID

func (r *GetOrderDetailsRequest) InstrumentID(instId string) *GetOrderDetailsRequest

func (*GetOrderDetailsRequest) OrderID

func (*GetOrderDetailsRequest) QueryParameters

func (r *GetOrderDetailsRequest) QueryParameters() url.Values

type GetOrderHistoryRequest added in v1.53.0

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

func (*GetOrderHistoryRequest) After added in v1.53.0

func (*GetOrderHistoryRequest) Before added in v1.53.0

func (*GetOrderHistoryRequest) Do added in v1.53.0

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

func (*GetOrderHistoryRequest) EndTime added in v1.53.0

func (*GetOrderHistoryRequest) GetParameters added in v1.53.0

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

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

func (*GetOrderHistoryRequest) GetParametersJSON added in v1.53.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetOrderHistoryRequest) GetParametersQuery added in v1.53.0

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

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

func (*GetOrderHistoryRequest) GetPath added in v1.56.0

func (g *GetOrderHistoryRequest) GetPath() string

GetPath returns the request path of the API

func (*GetOrderHistoryRequest) GetQueryParameters added in v1.53.0

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

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

func (*GetOrderHistoryRequest) GetSlugParameters added in v1.53.0

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

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

func (*GetOrderHistoryRequest) GetSlugsMap added in v1.53.0

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

func (*GetOrderHistoryRequest) InstrumentFamily added in v1.53.0

func (g *GetOrderHistoryRequest) InstrumentFamily(instrumentFamily string) *GetOrderHistoryRequest

func (*GetOrderHistoryRequest) InstrumentID added in v1.53.0

func (g *GetOrderHistoryRequest) InstrumentID(instrumentID string) *GetOrderHistoryRequest

func (*GetOrderHistoryRequest) InstrumentType added in v1.53.0

func (g *GetOrderHistoryRequest) InstrumentType(instrumentType InstrumentType) *GetOrderHistoryRequest

func (*GetOrderHistoryRequest) Limit added in v1.53.0

func (*GetOrderHistoryRequest) OrderType added in v1.53.0

func (g *GetOrderHistoryRequest) OrderType(orderType OrderType) *GetOrderHistoryRequest

func (*GetOrderHistoryRequest) StartTime added in v1.53.0

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

func (*GetOrderHistoryRequest) State added in v1.53.0

func (*GetOrderHistoryRequest) Underlying added in v1.53.0

func (g *GetOrderHistoryRequest) Underlying(underlying string) *GetOrderHistoryRequest

type GetThreeDaysTransactionHistoryRequest added in v1.58.0

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

func (*GetThreeDaysTransactionHistoryRequest) After added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) Before added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) Do added in v1.58.0

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

func (*GetThreeDaysTransactionHistoryRequest) EndTime added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) GetParameters added in v1.58.0

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

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

func (*GetThreeDaysTransactionHistoryRequest) GetParametersJSON added in v1.58.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetThreeDaysTransactionHistoryRequest) GetParametersQuery added in v1.58.0

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

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

func (*GetThreeDaysTransactionHistoryRequest) GetPath added in v1.58.0

GetPath returns the request path of the API

func (*GetThreeDaysTransactionHistoryRequest) GetQueryParameters added in v1.58.0

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

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

func (*GetThreeDaysTransactionHistoryRequest) GetSlugParameters added in v1.58.0

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

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

func (*GetThreeDaysTransactionHistoryRequest) GetSlugsMap added in v1.58.0

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

func (*GetThreeDaysTransactionHistoryRequest) InstrumentFamily added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) InstrumentID added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) InstrumentType added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) Limit added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) OrderID added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) StartTime added in v1.58.0

func (*GetThreeDaysTransactionHistoryRequest) Underlying added in v1.58.0

type GetTickerRequest added in v1.56.0

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

func (*GetTickerRequest) Do added in v1.56.0

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

func (*GetTickerRequest) GetParameters added in v1.56.0

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

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

func (*GetTickerRequest) GetParametersJSON added in v1.56.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetTickerRequest) GetParametersQuery added in v1.56.0

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

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

func (*GetTickerRequest) GetPath added in v1.56.0

func (g *GetTickerRequest) GetPath() string

GetPath returns the request path of the API

func (*GetTickerRequest) GetQueryParameters added in v1.56.0

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

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

func (*GetTickerRequest) GetSlugParameters added in v1.56.0

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

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

func (*GetTickerRequest) GetSlugsMap added in v1.56.0

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

func (*GetTickerRequest) InstId added in v1.56.0

func (g *GetTickerRequest) InstId(instId string) *GetTickerRequest

type GetTickersRequest added in v1.56.0

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

func (*GetTickersRequest) Do added in v1.56.0

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

func (*GetTickersRequest) GetParameters added in v1.56.0

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.56.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetTickersRequest) GetParametersQuery added in v1.56.0

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

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

func (*GetTickersRequest) GetPath added in v1.56.0

func (g *GetTickersRequest) GetPath() string

GetPath returns the request path of the API

func (*GetTickersRequest) GetQueryParameters added in v1.56.0

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

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

func (*GetTickersRequest) GetSlugParameters added in v1.56.0

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.56.0

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

func (*GetTickersRequest) InstType added in v1.56.0

func (g *GetTickersRequest) InstType(instType InstrumentType) *GetTickersRequest

type GetTransactionDetailsRequest

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

func (*GetTransactionDetailsRequest) Do

func (*GetTransactionDetailsRequest) InstrumentID

func (*GetTransactionDetailsRequest) InstrumentType

func (*GetTransactionDetailsRequest) OrderID

func (*GetTransactionDetailsRequest) Parameters

func (r *GetTransactionDetailsRequest) Parameters() map[string]interface{}

type GetTransactionHistoryRequest added in v1.53.0

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

func (*GetTransactionHistoryRequest) After added in v1.53.0

func (*GetTransactionHistoryRequest) Before added in v1.53.0

func (*GetTransactionHistoryRequest) Do added in v1.53.0

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

func (*GetTransactionHistoryRequest) EndTime added in v1.53.0

func (*GetTransactionHistoryRequest) GetParameters added in v1.53.0

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

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

func (*GetTransactionHistoryRequest) GetParametersJSON added in v1.53.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*GetTransactionHistoryRequest) GetParametersQuery added in v1.53.0

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

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

func (*GetTransactionHistoryRequest) GetPath added in v1.56.0

func (g *GetTransactionHistoryRequest) GetPath() string

GetPath returns the request path of the API

func (*GetTransactionHistoryRequest) GetQueryParameters added in v1.53.0

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

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

func (*GetTransactionHistoryRequest) GetSlugParameters added in v1.53.0

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

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

func (*GetTransactionHistoryRequest) GetSlugsMap added in v1.53.0

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

func (*GetTransactionHistoryRequest) InstrumentFamily added in v1.53.0

func (g *GetTransactionHistoryRequest) InstrumentFamily(instrumentFamily string) *GetTransactionHistoryRequest

func (*GetTransactionHistoryRequest) InstrumentID added in v1.53.0

func (g *GetTransactionHistoryRequest) InstrumentID(instrumentID string) *GetTransactionHistoryRequest

func (*GetTransactionHistoryRequest) InstrumentType added in v1.53.0

func (*GetTransactionHistoryRequest) Limit added in v1.53.0

func (*GetTransactionHistoryRequest) OrderID added in v1.53.0

func (*GetTransactionHistoryRequest) StartTime added in v1.53.0

func (*GetTransactionHistoryRequest) Underlying added in v1.53.0

type InstrumentInfo added in v1.56.0

type InstrumentInfo struct {
	InstrumentType        string                     `json:"instType"`
	InstrumentID          string                     `json:"instId"`
	BaseCurrency          string                     `json:"baseCcy"`
	QuoteCurrency         string                     `json:"quoteCcy"`
	SettleCurrency        string                     `json:"settleCcy"`
	ContractValue         string                     `json:"ctVal"`
	ContractMultiplier    string                     `json:"ctMult"`
	ContractValueCurrency string                     `json:"ctValCcy"`
	ListTime              types.MillisecondTimestamp `json:"listTime"`
	ExpiryTime            types.MillisecondTimestamp `json:"expTime"`
	TickSize              fixedpoint.Value           `json:"tickSz"`
	LotSize               fixedpoint.Value           `json:"lotSz"`

	// MinSize = min order size
	MinSize fixedpoint.Value `json:"minSz"`

	// instrument status
	State string `json:"state"`
}

type InstrumentType

type InstrumentType string
const (
	InstrumentTypeSpot    InstrumentType = "SPOT"
	InstrumentTypeSwap    InstrumentType = "SWAP"
	InstrumentTypeFutures InstrumentType = "FUTURES"
	InstrumentTypeOption  InstrumentType = "OPTION"
	InstrumentTypeMARGIN  InstrumentType = "MARGIN"
)

type KLine added in v1.57.0

type KLine struct {
	StartTime    types.MillisecondTimestamp
	OpenPrice    fixedpoint.Value
	HighestPrice fixedpoint.Value
	LowestPrice  fixedpoint.Value
	ClosePrice   fixedpoint.Value

	// If it is a derivatives contract, the value is the number of contracts.
	// If it is SPOT/MARGIN, the value is the quantity in base currency.
	Volume fixedpoint.Value
	// VolumeInCurrency trading volume, with a unit of currency.
	// If it is a derivatives contract, the value is the number of base currency.
	// If it is SPOT/MARGIN, the value is the quantity in quote currency.
	VolumeInCurrency fixedpoint.Value
	// VolumeInCurrencyQuote Trading volume, the value is the quantity in quote currency
	// e.g. The unit is USDT for BTC-USDT and BTC-USDT-SWAP;
	// The unit is USD for BTC-USD-SWAP
	// ** REMARK: To prevent overflow, we need to avoid unmarshaling it.  **
	//VolumeInCurrencyQuote fixedpoint.Value
	// The state of candlesticks.
	// 0 represents that it is uncompleted, 1 represents that it is completed.
	Confirm fixedpoint.Value
}

type KLineSlice added in v1.57.0

type KLineSlice []KLine

func (*KLineSlice) UnmarshalJSON added in v1.57.0

func (m *KLineSlice) UnmarshalJSON(b []byte) error

type LiquidityType added in v1.56.0

type LiquidityType string

type MarketTicker

type MarketTicker struct {
	InstrumentType string `json:"instType"`
	InstrumentID   string `json:"instId"`

	// last traded price
	Last fixedpoint.Value `json:"last"`

	// last traded size
	LastSize fixedpoint.Value `json:"lastSz"`

	AskPrice fixedpoint.Value `json:"askPx"`
	AskSize  fixedpoint.Value `json:"askSz"`

	BidPrice fixedpoint.Value `json:"bidPx"`
	BidSize  fixedpoint.Value `json:"bidSz"`

	Open24H           fixedpoint.Value `json:"open24h"`
	High24H           fixedpoint.Value `json:"high24H"`
	Low24H            fixedpoint.Value `json:"low24H"`
	Volume24H         fixedpoint.Value `json:"vol24h"`
	VolumeCurrency24H fixedpoint.Value `json:"volCcy24h"`

	// Millisecond timestamp
	Timestamp types.MillisecondTimestamp `json:"ts"`
}

type MarketTickerRequest

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

func (*MarketTickerRequest) Do

func (*MarketTickerRequest) InstrumentID

func (r *MarketTickerRequest) InstrumentID(instId string) *MarketTickerRequest

type MarketTickersRequest

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

func (*MarketTickersRequest) Do

func (*MarketTickersRequest) InstrumentType

func (r *MarketTickersRequest) InstrumentType(instType string) *MarketTickersRequest

type OpenOrder added in v1.56.0

type OpenOrder struct {
	OrderDetail
	QuickMgnType string `json:"quickMgnType"`
}

type OrderDetail added in v1.56.0

type OrderDetail struct {
	AccumulatedFillSize fixedpoint.Value `json:"accFillSz"`
	// If none is filled, it will return "".
	AvgPrice      fixedpoint.Value           `json:"avgPx"`
	CreatedTime   types.MillisecondTimestamp `json:"cTime"`
	Category      string                     `json:"category"`
	ClientOrderId string                     `json:"clOrdId"`
	Fee           fixedpoint.Value           `json:"fee"`
	FeeCurrency   string                     `json:"feeCcy"`
	// Last filled time
	FillTime       types.MillisecondTimestamp `json:"fillTime"`
	InstrumentID   string                     `json:"instId"`
	InstrumentType InstrumentType             `json:"instType"`
	OrderId        types.StrInt64             `json:"ordId"`
	OrderType      OrderType                  `json:"ordType"`
	Price          fixedpoint.Value           `json:"px"`
	Side           SideType                   `json:"side"`
	State          OrderState                 `json:"state"`
	Size           fixedpoint.Value           `json:"sz"`
	TargetCurrency TargetCurrency             `json:"tgtCcy"`
	UpdatedTime    types.MillisecondTimestamp `json:"uTime"`

	// Margin currency
	// Only applicable to cross MARGIN orders in Single-currency margin.
	Currency string `json:"ccy"`
	TradeId  string `json:"tradeId"`
	// Last filled price
	FillPrice fixedpoint.Value `json:"fillPx"`
	// Last filled quantity
	FillSize fixedpoint.Value `json:"fillSz"`
	// Leverage, from 0.01 to 125.
	// Only applicable to MARGIN/FUTURES/SWAP
	Lever string `json:"lever"`
	// Profit and loss, Applicable to orders which have a trade and aim to close position. It always is 0 in other conditions
	Pnl          fixedpoint.Value `json:"pnl"`
	PositionSide string           `json:"posSide"`
	// Options price in USDOnly applicable to options; return "" for other instrument types
	PriceUsd fixedpoint.Value `json:"pxUsd"`
	// Implied volatility of the options orderOnly applicable to options; return "" for other instrument types
	PriceVol fixedpoint.Value `json:"pxVol"`
	// Price type of options
	PriceType string `json:"pxType"`
	// Rebate amount, only applicable to spot and margin, the reward of placing orders from the platform (rebate)
	// given to user who has reached the specified trading level. If there is no rebate, this field is "".
	Rebate    fixedpoint.Value `json:"rebate"`
	RebateCcy string           `json:"rebateCcy"`
	// Client-supplied Algo ID when placing order attaching TP/SL.
	AttachAlgoClOrdId string           `json:"attachAlgoClOrdId"`
	SlOrdPx           fixedpoint.Value `json:"slOrdPx"`
	SlTriggerPx       fixedpoint.Value `json:"slTriggerPx"`
	SlTriggerPxType   string           `json:"slTriggerPxType"`
	AttachAlgoOrds    []interface{}    `json:"attachAlgoOrds"`
	Source            string           `json:"source"`
	// Self trade prevention ID. Return "" if self trade prevention is not applicable
	StpId string `json:"stpId"`
	// Self trade prevention mode. Return "" if self trade prevention is not applicable
	StpMode         string           `json:"stpMode"`
	Tag             string           `json:"tag"`
	TradeMode       TradeMode        `json:"tdMode"`
	TpOrdPx         fixedpoint.Value `json:"tpOrdPx"`
	TpTriggerPx     fixedpoint.Value `json:"tpTriggerPx"`
	TpTriggerPxType string           `json:"tpTriggerPxType"`
	ReduceOnly      string           `json:"reduceOnly"`
	AlgoClOrdId     string           `json:"algoClOrdId"`
	AlgoId          string           `json:"algoId"`
}

type OrderDetails

type OrderDetails struct {
	InstrumentType InstrumentType   `json:"instType"`
	InstrumentID   string           `json:"instId"`
	Tag            string           `json:"tag"`
	Price          fixedpoint.Value `json:"px"`
	Quantity       fixedpoint.Value `json:"sz"`

	OrderID       string    `json:"ordId"`
	ClientOrderID string    `json:"clOrdId"`
	OrderType     OrderType `json:"ordType"`
	Side          SideType  `json:"side"`

	// Accumulated fill quantity
	FilledQuantity fixedpoint.Value `json:"accFillSz"`

	FeeCurrency string           `json:"feeCcy"`
	Fee         fixedpoint.Value `json:"fee"`

	// trade related fields
	LastTradeID           string                     `json:"tradeId,omitempty"`
	LastFilledPrice       fixedpoint.Value           `json:"fillPx"`
	LastFilledQuantity    fixedpoint.Value           `json:"fillSz"`
	LastFilledTime        types.MillisecondTimestamp `json:"fillTime"`
	LastFilledFee         fixedpoint.Value           `json:"fillFee"`
	LastFilledFeeCurrency string                     `json:"fillFeeCcy"`
	LastFilledPnl         fixedpoint.Value           `json:"fillPnl"`
	BillID                types.StrInt64             `json:"billId"`

	// ExecutionType = liquidity (M = maker or T = taker)
	ExecutionType string `json:"execType"`

	// Average filled price. If none is filled, it will return 0.
	AveragePrice fixedpoint.Value `json:"avgPx"`

	// Currency = Margin currency
	// Only applicable to cross MARGIN orders in Single-currency margin.
	Currency string `json:"ccy"`

	// Leverage = from 0.01 to 125.
	// Only applicable to MARGIN/FUTURES/SWAP
	Leverage fixedpoint.Value `json:"lever"`

	RebateCurrency string           `json:"rebateCcy"`
	Rebate         fixedpoint.Value `json:"rebate"`

	PnL fixedpoint.Value `json:"pnl"`

	UpdateTime   types.MillisecondTimestamp `json:"uTime"`
	CreationTime types.MillisecondTimestamp `json:"cTime"`

	State OrderState `json:"state"`
}

type OrderList added in v1.52.0

type OrderList []OrderDetails

type OrderResponse

type OrderResponse struct {
	OrderID       string `json:"ordId"`
	ClientOrderID string `json:"clOrdId"`
	Tag           string `json:"tag"`
	Code          string `json:"sCode"`
	Message       string `json:"sMsg"`
}

type OrderState

type OrderState string
const (
	OrderStateCanceled        OrderState = "canceled"
	OrderStateLive            OrderState = "live"
	OrderStatePartiallyFilled OrderState = "partially_filled"
	OrderStateFilled          OrderState = "filled"
)

func (OrderState) IsWorking added in v1.56.0

func (o OrderState) IsWorking() bool

type OrderType

type OrderType string
const (
	OrderTypeMarket   OrderType = "market"
	OrderTypeLimit    OrderType = "limit"
	OrderTypePostOnly OrderType = "post_only"
	OrderTypeFOK      OrderType = "fok"
	OrderTypeIOC      OrderType = "ioc"
)

type PlaceOrderRequest

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

func (*PlaceOrderRequest) ClientOrderID

func (r *PlaceOrderRequest) ClientOrderID(clientOrderID string) *PlaceOrderRequest

func (*PlaceOrderRequest) Do

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

func (*PlaceOrderRequest) GetParameters added in v1.21.0

func (r *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.21.0

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*PlaceOrderRequest) GetParametersQuery added in v1.21.0

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

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

func (*PlaceOrderRequest) GetPath added in v1.56.0

func (r *PlaceOrderRequest) GetPath() string

GetPath returns the request path of the API

func (*PlaceOrderRequest) GetQueryParameters added in v1.56.0

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

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

func (*PlaceOrderRequest) GetSlugParameters added in v1.56.0

func (r *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.56.0

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

func (*PlaceOrderRequest) InstrumentID

func (r *PlaceOrderRequest) InstrumentID(instrumentID string) *PlaceOrderRequest

func (*PlaceOrderRequest) OrderType

func (r *PlaceOrderRequest) OrderType(orderType OrderType) *PlaceOrderRequest

func (*PlaceOrderRequest) Parameters

func (r *PlaceOrderRequest) Parameters() map[string]interface{}

func (*PlaceOrderRequest) Price

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

func (*PlaceOrderRequest) Side

func (*PlaceOrderRequest) Size added in v1.56.0

func (*PlaceOrderRequest) Tag added in v1.21.0

func (*PlaceOrderRequest) TargetCurrency added in v1.56.0

func (r *PlaceOrderRequest) TargetCurrency(targetCurrency TargetCurrency) *PlaceOrderRequest

func (*PlaceOrderRequest) TradeMode

func (r *PlaceOrderRequest) TradeMode(tradeMode TradeMode) *PlaceOrderRequest

type RestClient

type RestClient struct {
	requestgen.BaseAPIClient

	Key, Secret, Passphrase string
}

func NewClient

func NewClient() *RestClient

func (*RestClient) AssetBalances

func (c *RestClient) AssetBalances(ctx context.Context) (AssetBalanceList, error)

func (*RestClient) AssetCurrencies

func (c *RestClient) AssetCurrencies(ctx context.Context) ([]AssetCurrency, error)

func (*RestClient) Auth

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

func (*RestClient) NewAuthenticatedRequest added in v1.52.0

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) NewBatchCancelOrderRequest added in v1.52.0

func (c *RestClient) NewBatchCancelOrderRequest() *BatchCancelOrderRequest

func (*RestClient) NewBatchPlaceOrderRequest added in v1.52.0

func (c *RestClient) NewBatchPlaceOrderRequest() *BatchPlaceOrderRequest

func (*RestClient) NewCancelOrderRequest added in v1.52.0

func (c *RestClient) NewCancelOrderRequest() *CancelOrderRequest

func (*RestClient) NewGetAccountInfoRequest added in v1.56.0

func (c *RestClient) NewGetAccountInfoRequest() *GetAccountInfoRequest

func (*RestClient) NewGetCandlesRequest added in v1.57.0

func (c *RestClient) NewGetCandlesRequest() *GetCandlesRequest

func (*RestClient) NewGetFundingRate added in v1.52.0

func (s *RestClient) NewGetFundingRate() *GetFundingRateRequest

func (*RestClient) NewGetInstrumentsInfoRequest added in v1.56.0

func (c *RestClient) NewGetInstrumentsInfoRequest() *GetInstrumentsInfoRequest

func (*RestClient) NewGetOpenOrdersRequest added in v1.56.0

func (c *RestClient) NewGetOpenOrdersRequest() *GetOpenOrdersRequest

func (*RestClient) NewGetOrderDetailsRequest added in v1.52.0

func (c *RestClient) NewGetOrderDetailsRequest() *GetOrderDetailsRequest

func (*RestClient) NewGetOrderHistoryRequest added in v1.53.0

func (c *RestClient) NewGetOrderHistoryRequest() *GetOrderHistoryRequest

NewGetOrderHistoryRequest is descending order by createdTime

func (*RestClient) NewGetThreeDaysTransactionHistoryRequest added in v1.58.0

func (c *RestClient) NewGetThreeDaysTransactionHistoryRequest() *GetThreeDaysTransactionHistoryRequest

func (*RestClient) NewGetTickerRequest added in v1.56.0

func (c *RestClient) NewGetTickerRequest() *GetTickerRequest

func (*RestClient) NewGetTickersRequest added in v1.56.0

func (c *RestClient) NewGetTickersRequest() *GetTickersRequest

func (*RestClient) NewGetTransactionDetailsRequest added in v1.52.0

func (c *RestClient) NewGetTransactionDetailsRequest() *GetTransactionDetailsRequest

func (*RestClient) NewGetTransactionHistoryRequest added in v1.53.0

func (c *RestClient) NewGetTransactionHistoryRequest() *GetTransactionHistoryRequest

func (*RestClient) NewMarketTickerRequest added in v1.52.0

func (c *RestClient) NewMarketTickerRequest(instId string) *MarketTickerRequest

func (*RestClient) NewMarketTickersRequest added in v1.52.0

func (c *RestClient) NewMarketTickersRequest(instType string) *MarketTickersRequest

func (*RestClient) NewPlaceOrderRequest added in v1.52.0

func (c *RestClient) NewPlaceOrderRequest() *PlaceOrderRequest

type SideType

type SideType string
const (
	SideTypeBuy  SideType = "buy"
	SideTypeSell SideType = "sell"
)

type TargetCurrency added in v1.56.0

type TargetCurrency string
const (
	TargetCurrencyBase  TargetCurrency = "base_ccy"
	TargetCurrencyQuote TargetCurrency = "quote_ccy"
)

type Trade added in v1.56.0

type Trade struct {
	InstrumentType InstrumentType `json:"instType"`
	InstrumentId   string         `json:"instId"`
	TradeId        types.StrInt64 `json:"tradeId"`
	OrderId        types.StrInt64 `json:"ordId"`
	ClientOrderId  string         `json:"clOrdId"`
	// Data generation time, Unix timestamp format in milliseconds, e.g. 1597026383085.
	Timestamp     types.MillisecondTimestamp `json:"ts"`
	FillTime      types.MillisecondTimestamp `json:"fillTime"`
	FeeCurrency   string                     `json:"feeCcy"`
	Fee           fixedpoint.Value           `json:"fee"`
	BillId        types.StrInt64             `json:"billId"`
	Side          SideType                   `json:"side"`
	ExecutionType LiquidityType              `json:"execType"`

	Tag string `json:"tag"`
	// Last filled price
	FillPrice fixedpoint.Value `json:"fillPx"`
	// Last filled quantity
	FillSize fixedpoint.Value `json:"fillSz"`
	// Index price at the moment of trade execution
	//For cross currency spot pairs, it returns baseCcy-USDT index price. For example, for LTC-ETH, this field returns the index price of LTC-USDT.
	FillIndexPrice fixedpoint.Value `json:"fillIdxPx"`
	FillPnl        string           `json:"fillPnl"`

	// Only applicable to options; return "" for other instrument types
	FillPriceVolume  fixedpoint.Value `json:"fillPxVol"`
	FillPriceUsd     fixedpoint.Value `json:"fillPxUsd"`
	FillMarkVolume   fixedpoint.Value `json:"fillMarkVol"`
	FillForwardPrice fixedpoint.Value `json:"fillFwdPx"`
	FillMarkPrice    fixedpoint.Value `json:"fillMarkPx"`
	PosSide          string           `json:"posSide"`
}

type TradeMode added in v1.56.0

type TradeMode string
const (
	TradeModeCash     TradeMode = "cash"
	TradeModeIsolated TradeMode = "isolated"
	TradeModeCross    TradeMode = "cross"
)

Jump to

Keyboard shortcuts

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