bitget_models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProductTypeUSDTFutures  = "USDT-FUTURES"
	ProductTypeCOINFutures  = "COIN-FUTURES"
	ProductTypeUSDCFutures  = "USDC-FUTURES"
	ProductTypeSUSDTFutures = "SUSDT-FUTURES"
	ProductTypeSCOINFutures = "SCOIN-FUTURES"
	ProductTypeSUSDCFutures = "SUSDC-FUTURES"
)

Product types available.

View Source
const (
	MarginModeIsolated = "isolated"
	MarginModeCrossed  = "crossed"
)

Margin modes.

View Source
const (
	SideBuy  = "buy"
	SideSell = "sell"
)

Trade sides.

View Source
const (
	TradeSideOpen  = "open"
	TradeSideClose = "close"
)

Hedge mode trade sides.

View Source
const (
	OrderTypeLimit  = "limit"
	OrderTypeMarket = "market"
)

Order types.

View Source
const (
	ForceGTC      = "gtc"
	ForceIOC      = "ioc"
	ForceFOK      = "fok"
	ForcePostOnly = "post_only"
)

Force options for limit orders.

View Source
const (
	ReduceOnlyYes = "YES"
	ReduceOnlyNo  = "NO"
)

Reduce only options.

View Source
const (
	STPModeNone        = "none"
	STPModeCancelTaker = "cancel_taker"
	STPModeCancelMaker = "cancel_maker"
	STPModeCancelBoth  = "cancel_both"
)

STP Modes (Self Trade Prevention).

View Source
const (
	// hold side simbol long or short
	HoldSideLong  = "long"
	HoldSideShort = "short"
)
View Source
const (
	OrderStateLive            = "live"
	OrderStatePartiallyFilled = "partially_filled"
	OrderStateFilled          = "filled"
	OrderStateCanceled        = "canceled"
)
View Source
const (
	TriggerTypeFillPrice = "fill_price"
	TriggerTypeMarkPrice = "mark_price"
)
View Source
const (
	// DefaultMarginCoin is the default margin coin.
	DefaultMarginCoin = "usdt"
)

Variables

View Source
var Symbols = struct {
	Name    string
	Tickers []string
}{
	Name: "",
	Tickers: []string{
		"1000000MOGUSDT",
		"1000BONKUSDT",
		"1000CATUSDT",
		"1000RATSUSDT",
		"1000XECUSDT",
		"1INCHUSDT",
		"AAVEUSDT",
		"ACEUSDT",
		"ACHUSDT",
		"ACTUSDT",
		"ACXUSDT",
		"ADAUSDT",
		"AERGOUSDT",
		"AEROUSDT",
		"AEVOUSDT",
		"AGLDUSDT",
		"AI16ZUSDT",
		"AIUSDT",
		"AIXBTUSDT",
		"AKTUSDT",
		"ALCHUSDT",
		"ALGOUSDT",
		"ALICEUSDT",
		"ALPACAUSDT",
		"ALPHAUSDT",
		"ALTUSDT",
		"ANIMEUSDT",
		"ANKRUSDT",
		"APEUSDT",
		"API3USDT",
		"APTUSDT",
		"ARBUSDT",
		"ARCUSDT",
		"ARKMUSDT",
		"ARKUSDT",
		"ARPAUSDT",
		"ARUSDT",
		"ASTRUSDT",
		"ATAUSDT",
		"ATOMUSDT",
		"AUCTIONUSDT",
		"AVAAIUSDT",
		"AVAUSDT",
		"AVAXUSDT",
		"AXLUSDT",
		"AXSUSDT",
		"B3USDT",
		"BAKEUSDT",
		"BANANAUSDT",
		"BANDUSDT",
		"BANUSDT",
		"BATUSDT",
		"BBUSDT",
		"BCHUSDT",
		"BELUSDT",
		"BERAUSDT",
		"BICOUSDT",
		"BIGTIMEUSDT",
		"BIOUSDT",
		"BLURUSDT",
		"BMTUSDT",
		"BNBUSDT",
		"BNTUSDT",
		"BOMEUSDT",
		"BRETTUSDT",
		"BRUSDT",
		"BSVUSDT",
		"BSWUSDT",
		"BTCUSDT",
		"C98USDT",
		"CAKEUSDT",
		"CATIUSDT",
		"CELOUSDT",
		"CELRUSDT",
		"CETUSUSDT",
		"CFXUSDT",
		"CGPTUSDT",
		"CHESSUSDT",
		"CHILLGUYUSDT",
		"CHRUSDT",
		"CHZUSDT",
		"CKBUSDT",
		"COMPUSDT",
		"COOKIEUSDT",
		"COSUSDT",
		"COTIUSDT",
		"COWUSDT",
		"CRVUSDT",
		"CTSIUSDT",
		"CVCUSDT",
		"CVXUSDT",
		"CYBERUSDT",
		"DEGENUSDT",
		"DENTUSDT",
		"DEXEUSDT",
		"DOGEUSDT",
		"DOGSUSDT",
		"DOTUSDT",
		"DRIFTUSDT",
		"DYDXUSDT",
		"DYMUSDT",
		"EGLDUSDT",
		"EIGENUSDT",
		"ENAUSDT",
		"ENJUSDT",
		"ENSUSDT",
		"EOSUSDT",
		"EPICUSDT",
		"ETCUSDT",
		"ETHFIUSDT",
		"ETHUSDT",
		"ETHWUSDT",
		"FARTCOINUSDT",
		"FIDAUSDT",
		"FILUSDT",
		"FIOUSDT",
		"FLMUSDT",
		"FLOWUSDT",
		"FLUXUSDT",
		"FORMUSDT",
		"FXSUSDT",
		"GALAUSDT",
		"GASUSDT",
		"GLMUSDT",
		"GMTUSDT",
		"GMXUSDT",
		"GOATUSDT",
		"GPSUSDT",
		"GRASSUSDT",
		"GRIFFAINUSDT",
		"GRTUSDT",
		"GTCUSDT",
		"GUSDT",
		"HBARUSDT",
		"HEIUSDT",
		"HIFIUSDT",
		"HIPPOUSDT",
		"HIVEUSDT",
		"HMSTRUSDT",
		"HOOKUSDT",
		"HOTUSDT",
		"ICPUSDT",
		"ICXUSDT",
		"IDUSDT",
		"IMXUSDT",
		"INJUSDT",
		"IOSTUSDT",
		"IOTAUSDT",
		"IOTXUSDT",
		"IOUSDT",
		"IPUSDT",
		"JASMYUSDT",
		"JOEUSDT",
		"JTOUSDT",
		"JUPUSDT",
		"KAIAUSDT",
		"KAITOUSDT",
		"KASUSDT",
		"KAVAUSDT",
		"KDAUSDT",
		"KMNOUSDT",
		"KNCUSDT",
		"KOMAUSDT",
		"KSMUSDT",
		"LDOUSDT",
		"LEVERUSDT",
		"LINKUSDT",
		"LISTAUSDT",
		"LPTUSDT",
		"LQTYUSDT",
		"LRCUSDT",
		"LSKUSDT",
		"LTCUSDT",
		"LUMIAUSDT",
		"MAGICUSDT",
		"MANAUSDT",
		"MANTAUSDT",
		"MASKUSDT",
		"MAVUSDT",
		"MBOXUSDT",
		"MELANIAUSDT",
		"MEMEUSDT",
		"METISUSDT",
		"MEUSDT",
		"MEWUSDT",
		"MINAUSDT",
		"MKRUSDT",
		"MOCAUSDT",
		"MOODENGUSDT",
		"MORPHOUSDT",
		"MOVEUSDT",
		"MOVRUSDT",
		"MTLUSDT",
		"MUBARAKUSDT",
		"MYROUSDT",
		"NEARUSDT",
		"NEIROETHUSDT",
		"NEOUSDT",
		"NFPUSDT",
		"NKNUSDT",
		"NMRUSDT",
		"NOTUSDT",
		"NTRNUSDT",
		"NULSUSDT",
		"OGNUSDT",
		"OMUSDT",
		"ONDOUSDT",
		"ONEUSDT",
		"ONGUSDT",
		"ONTUSDT",
		"OPUSDT",
		"ORCAUSDT",
		"ORDIUSDT",
		"OXTUSDT",
		"PENDLEUSDT",
		"PENGUUSDT",
		"PEOPLEUSDT",
		"PHAUSDT",
		"PHBUSDT",
		"PIPPINUSDT",
		"PIXELUSDT",
		"PLUMEUSDT",
		"PNUTUSDT",
		"POLUSDT",
		"POLYXUSDT",
		"PONKEUSDT",
		"POPCATUSDT",
		"PORTALUSDT",
		"POWRUSDT",
		"PROMUSDT",
		"PYTHUSDT",
		"QNTUSDT",
		"QTUMUSDT",
		"QUICKUSDT",
		"RADUSDT",
		"RAREUSDT",
		"RDNTUSDT",
		"REDUSDT",
		"RENDERUSDT",
		"REZUSDT",
		"ROSEUSDT",
		"RPLUSDT",
		"RSRUSDT",
		"RUNEUSDT",
		"RVNUSDT",
		"SAFEUSDT",
		"SAGAUSDT",
		"SANDUSDT",
		"SCRTUSDT",
		"SCRUSDT",
		"SEIUSDT",
		"SFPUSDT",
		"SHELLUSDT",
		"SIRENUSDT",
		"SKLUSDT",
		"SLERFUSDT",
		"SNTUSDT",
		"SNXUSDT",
		"SOLUSDT",
		"SOLVUSDT",
		"SONICUSDT",
		"SPELLUSDT",
		"SPXUSDT",
		"SSVUSDT",
		"STEEMUSDT",
		"STGUSDT",
		"STORJUSDT",
		"STPTUSDT",
		"STRKUSDT",
		"STXUSDT",
		"SUIUSDT",
		"SUNUSDT",
		"SUPERUSDT",
		"SUSDT",
		"SUSHIUSDT",
		"SWARMSUSDT",
		"SWELLUSDT",
		"SXPUSDT",
		"SYNUSDT",
		"SYSUSDT",
		"TAOUSDT",
		"THETAUSDT",
		"THEUSDT",
		"TIAUSDT",
		"TLMUSDT",
		"TNSRUSDT",
		"TONUSDT",
		"TRBUSDT",
		"TROYUSDT",
		"TRUMPUSDT",
		"TRUUSDT",
		"TRXUSDT",
		"TUSDT",
		"TUTUSDT",
		"UMAUSDT",
		"UNIUSDT",
		"USDCUSDT",
		"USTCUSDT",
		"USUALUSDT",
		"UXLINKUSDT",
		"VANAUSDT",
		"VANRYUSDT",
		"VELODROMEUSDT",
		"VETUSDT",
		"VICUSDT",
		"VIDTUSDT",
		"VINEUSDT",
		"VIRTUALUSDT",
		"VOXELUSDT",
		"VTHOUSDT",
		"VVVUSDT",
		"WAVESUSDT",
		"WAXPUSDT",
		"WIFUSDT",
		"WLDUSDT",
		"WOOUSDT",
		"WUSDT",
		"XAIUSDT",
		"XLMUSDT",
		"XRPUSDT",
		"XTZUSDT",
		"XVGUSDT",
		"XVSUSDT",
		"YGGUSDT",
		"ZENUSDT",
		"ZEREBROUSDT",
		"ZETAUSDT",
		"ZILUSDT",
		"ZKUSDT",
		"ZROUSDT",
		"ZRXUSDT",
	},
}

Symbols holds the list of available trading tickers. Although declared as a variable, this list should be treated as constant.

Functions

This section is empty.

Types

type AccountData

type AccountData struct {
	MarginCoin            string         `json:"marginCoin"`            // Margin coin.
	Locked                string         `json:"locked"`                // Locked quantity.
	Available             string         `json:"available"`             // Available balance.
	CrossedMaxAvailable   string         `json:"crossedMaxAvailable"`   // Max available under cross margin.
	IsolatedMaxAvailable  string         `json:"isolatedMaxAvailable"`  // Max available under isolated margin.
	MaxTransferOut        string         `json:"maxTransferOut"`        // Max transferable amount.
	AccountEquity         string         `json:"accountEquity"`         // Account equity (includes unrealized PnL).
	UsdtEquity            string         `json:"usdtEquity"`            // Equity in USDT.
	BtcEquity             string         `json:"btcEquity"`             // Equity in BTC.
	CrossedRiskRate       string         `json:"crossedRiskRate"`       // Risk rate in cross margin mode.
	CrossedMarginLeverage StringOrNumber `json:"crossedMarginLeverage"` // Leverage for cross margin.
	IsolatedLongLever     StringOrNumber `json:"isolatedLongLever"`     // Leverage for isolated long positions.
	IsolatedShortLever    StringOrNumber `json:"isolatedShortLever"`    // Leverage for isolated short positions.
	MarginMode            string         `json:"marginMode"`            // Margin mode: "isolated" or "crossed".
	PosMode               string         `json:"posMode"`               // Position mode: "one_way_mode" or "hedge_mode".
	UnrealizedPL          string         `json:"unrealizedPL"`          // Unrealized profit and loss.
	Coupon                string         `json:"coupon"`                // Trading bonus.
	CrossedUnrealizedPL   string         `json:"crossedUnrealizedPL"`   // Unrealized PnL in cross margin.
	IsolatedUnrealizedPL  string         `json:"isolatedUnrealizedPL"`  // Unrealized PnL in isolated margin.
	AssetMode             string         `json:"assetMode"`             // Assets mode ("union" or "single").
}

AccountData holds the actual account information.

func (*AccountData) AvailableFloat64

func (a *AccountData) AvailableFloat64() float64

func (*AccountData) CrossedMaxAvailableFloat64

func (a *AccountData) CrossedMaxAvailableFloat64() float64

func (*AccountData) LockedFloat64

func (a *AccountData) LockedFloat64() float64

func (*AccountData) ToParams

func (d *AccountData) ToParams() map[string]string

func (*AccountData) UsdtEquityFloat64

func (a *AccountData) UsdtEquityFloat64() float64

usdtEquity float64

type AccountRequest

type AccountRequest struct {
	// Trading pair, e.g. "btcusdt"
	Symbol string `json:"symbol"`
	// Product type, e.g. "USDT-FUTURES", "COIN-FUTURES", etc.
	ProductType string `json:"productType"`
	// Margin coin, e.g. "usdt"
	MarginCoin string `json:"marginCoin"`
}

AccountRequest holds the query parameters for the account details endpoint.

func (*AccountRequest) ToParams

func (r *AccountRequest) ToParams() map[string]string

func (*AccountRequest) ToQueryString

func (req *AccountRequest) ToQueryString() string

type AccountResponse

type AccountResponse struct {
	Code        string      `json:"code"`        // "00000" indicates success.
	Data        AccountData `json:"data"`        // Account details.
	Msg         string      `json:"msg"`         // Response message.
	RequestTime int64       `json:"requestTime"` // Request timestamp.
}

AccountResponse represents the API response for the account details.

func (*AccountResponse) ToParams

func (r *AccountResponse) ToParams() map[string]string

type BatchCancelOrderData

type BatchCancelOrderData struct {
	SuccessList []OrderCancelSuccess `json:"successList"` // Successfully canceled orders.
	FailureList []OrderCancelFailure `json:"failureList"` // Orders that failed to cancel.
}

type BatchCancelOrderRequest

type BatchCancelOrderRequest struct {
	// Trading pair, e.g. "BTCUSDT". It is required when orderIdList is set.
	Symbol string `json:"symbol,omitempty"`
	// Product type (e.g. "USDT-FUTURES", "COIN-FUTURES", etc.).
	ProductType string `json:"productType"`
	// Margin coin, must be capitalized (e.g. "USDT").
	MarginCoin string `json:"marginCoin,omitempty"`
	// List of orders to cancel (maximum length: 50). Each order can be identified by orderId or clientOid.
	OrderIdList []OrderCancelID `json:"orderIdList,omitempty"`
}

BatchCancelOrderRequest represents the payload for a batch cancel order request.

type BatchCancelOrderResponse

type BatchCancelOrderResponse struct {
	Code        string               `json:"code"`        // "00000" indicates success.
	Msg         string               `json:"msg"`         // Response message.
	RequestTime int64                `json:"requestTime"` // Timestamp of the request.
	Data        BatchCancelOrderData `json:"data"`        // Contains lists of successes and failures.
}

type BatchOrderFailure

type BatchOrderFailure struct {
	OrderId   string `json:"orderId"`   // Order ID (if available).
	ClientOid string `json:"clientOid"` // Custom order ID.
	ErrorMsg  string `json:"errorMsg"`  // Failure reason.
	ErrorCode string `json:"errorCode"` // Failure code.
}

type BatchOrderOrderItem

type BatchOrderOrderItem struct {
	Size                   string `json:"size"`                             // Order amount
	Price                  string `json:"price,omitempty"`                  // Order price (required for limit orders)
	Side                   string `json:"side"`                             // "buy" or "sell"
	TradeSide              string `json:"tradeSide,omitempty"`              // "open" or "close" (only required in hedge-mode)
	OrderType              string `json:"orderType"`                        // "limit" or "market"
	Force                  string `json:"force,omitempty"`                  // Order expiration: "gtc", "ioc", "fok", "post_only"
	ClientOid              string `json:"clientOid,omitempty"`              // Customized order ID
	ReduceOnly             string `json:"reduceOnly,omitempty"`             // "YES" or "NO" (applicable only in one-way mode)
	PresetStopSurplusPrice string `json:"presetStopSurplusPrice,omitempty"` // Take-profit value (optional)
	PresetStopLossPrice    string `json:"presetStopLossPrice,omitempty"`    // Stop-loss value (optional)
	StpMode                string `json:"stpMode,omitempty"`                // STP mode (optional)
}

type BatchOrderRequest

type BatchOrderRequest struct {
	Symbol      string                `json:"symbol"`      // Trading pair, e.g. BTCUSDT
	ProductType string                `json:"productType"` // e.g. "USDT-FUTURES"
	MarginMode  string                `json:"marginMode"`  // "isolated" or "crossed"
	MarginCoin  string                `json:"marginCoin"`  // e.g. "USDT"
	OrderList   []BatchOrderOrderItem `json:"orderList"`   // List of orders (max length: 50)
}

BatchOrderRequest represents the payload for batch placing orders.

type BatchOrderSuccess

type BatchOrderSuccess struct {
	OrderId   string `json:"orderId"`   // Exchange-assigned order ID.
	ClientOid string `json:"clientOid"` // Custom order ID from the request.
}

type BatchPlaceOrderData

type BatchPlaceOrderData struct {
	SuccessList []BatchOrderSuccess `json:"successList"` // List of successful orders.
	FailureList []BatchOrderFailure `json:"failureList"` // List of failed orders.
}

type BatchPlaceOrderResponse

type BatchPlaceOrderResponse struct {
	Code        string              `json:"code"`        // "00000" indicates success.
	Data        BatchPlaceOrderData `json:"data"`        // Contains successList and failureList.
	Msg         string              `json:"msg"`         // Response message.
	RequestTime int64               `json:"requestTime"` // Timestamp of the request.
}

type CancelAllOrdersData

type CancelAllOrdersData struct {
	SuccessList []CancelAllOrdersSuccess `json:"successList"` // Successfully canceled orders.
	FailureList []CancelAllOrdersFailure `json:"failureList"` // Orders that failed to cancel.
}

CancelAllOrdersData holds the response data.

type CancelAllOrdersFailure

type CancelAllOrdersFailure struct {
	OrderId   string `json:"orderId"`   // Order ID.
	ClientOid string `json:"clientOid"` // Customized order ID.
	ErrorMsg  string `json:"errorMsg"`  // Failure reason.
	ErrorCode string `json:"errorCode"` // Error code.
}

CancelAllOrdersFailure represents an order that failed to cancel.

type CancelAllOrdersRequest

type CancelAllOrdersRequest struct {
	// Required: Product type (e.g., "USDT-FUTURES", "COIN-FUTURES", etc.)
	ProductType string `json:"productType"`
	// Optional: Margin coin, must be capitalized (e.g., "USDT").
	MarginCoin string `json:"marginCoin,omitempty"`
	// Optional: Request time as a Unix millisecond timestamp.
	RequestTime string `json:"requestTime,omitempty"`
	// Optional: Valid window period as a Unix millisecond timestamp.
	ReceiveWindow string `json:"receiveWindow,omitempty"`
}

CancelAllOrdersRequest represents the payload for canceling all orders.

type CancelAllOrdersResponse

type CancelAllOrdersResponse struct {
	Code        string              `json:"code"`        // "00000" indicates success.
	Msg         string              `json:"msg"`         // Response message.
	RequestTime int64               `json:"requestTime"` // Timestamp of the request.
	Data        CancelAllOrdersData `json:"data"`        // Payload data.
}

CancelAllOrdersResponse represents the API response.

type CancelAllOrdersSuccess

type CancelAllOrdersSuccess struct {
	OrderId   string `json:"orderId"`   // Order ID.
	ClientOid string `json:"clientOid"` // Customized order ID.
}

CancelAllOrdersSuccess represents a successfully canceled order.

type CancelOrderData

type CancelOrderData struct {
	OrderId   string `json:"orderId"`   // Order ID.
	ClientOid string `json:"clientOid"` // Client customized order ID.
}

CancelOrderData holds the details of the canceled order.

type CancelOrderRequest

type CancelOrderRequest struct {
	OrderId     string `json:"orderId,omitempty"`    // Optional: Order ID.
	ClientOid   string `json:"clientOid,omitempty"`  // Optional: Customized order ID.
	Symbol      string `json:"symbol"`               // Required: Trading pair, e.g. "BTCUSDT".
	ProductType string `json:"productType"`          // Required: Product type (e.g. "USDT-FUTURES").
	MarginCoin  string `json:"marginCoin,omitempty"` // Optional: Margin coin (capitalized), e.g. "USDT".
}

CancelOrderRequest represents the payload for canceling an order. Either orderId or clientOid must be provided. If both are present, orderId takes precedence.

type CancelOrderResponse

type CancelOrderResponse struct {
	Code        string          `json:"code"`        // "00000" indicates success.
	Msg         string          `json:"msg"`         // Response message.
	RequestTime int64           `json:"requestTime"` // Timestamp of the request.
	Data        CancelOrderData `json:"data"`        // Data containing order details.
}

CancelOrderResponse represents the response from a cancel order request.

type CandlePushData

type CandlePushData struct {
	Action string `json:"action"` // e.g. "snapshot" or "update"
	Arg    struct {
		InstType string `json:"instType"` // Product type.
		Channel  string `json:"channel"`  // Channel name.
		InstId   string `json:"instId"`   // Product ID.
	} `json:"arg"`
	Data [][]string `json:"data"` // Each inner array contains: [timestamp, open, high, low, close, volume, quoteVolume, usdtVolume]
	Ts   int64      `json:"ts"`   // Server timestamp.
}

CandlePushData represents the pushed candlestick data.

type CandleSubscriptionArg

type CandleSubscriptionArg struct {
	InstType string `json:"instType"` // e.g. "USDT-FUTURES"
	Channel  string `json:"channel"`  // e.g. "candle1m", "candle5m", etc.
	InstId   string `json:"instId"`   // e.g. "BTCUSDT"
}

type CandleSubscriptionRequest

type CandleSubscriptionRequest struct {
	Op   string                  `json:"op"`   // "subscribe" or "unsubscribe"
	Args []CandleSubscriptionArg `json:"args"` // List of channels to subscribe
}

CandleSubscriptionRequest is the request format for subscribing.

type ClosePositionsData

type ClosePositionsData struct {
	SuccessList []ClosePositionsSuccess `json:"successList"` // Successfully closed orders.
	FailureList []ClosePositionsFailure `json:"failureList"` // Orders that failed to close.
}

type ClosePositionsFailure

type ClosePositionsFailure struct {
	OrderId   string `json:"orderId"`   // Order ID.
	ClientOid string `json:"clientOid"` // Customized order ID.
	Symbol    string `json:"symbol"`    // Trading pair.
	ErrorMsg  string `json:"errorMsg"`  // Failure reason.
	ErrorCode string `json:"errorCode"` // Failure code.
}

type ClosePositionsRequest

type ClosePositionsRequest struct {
	// Trading pair, e.g. "BTCUSDT". In one-way mode this field can be omitted.
	Symbol string `json:"symbol,omitempty"`
	// Product type, e.g. "USDT-FUTURES", "COIN-FUTURES", etc.
	ProductType string `json:"productType"`
	// Position direction: "long" for long positions, "short" for short positions.
	// In one-way mode this field is ignored; if left blank in hedge-mode, all positions will be closed.
	HoldSide string `json:"holdSide,omitempty"`
}

ClosePositionsRequest represents the payload for closing positions at market price.

type ClosePositionsResponse

type ClosePositionsResponse struct {
	Code        string             `json:"code"`        // "00000" indicates success.
	Msg         string             `json:"msg"`         // Response message.
	RequestTime int64              `json:"requestTime"` // Timestamp of the request.
	Data        ClosePositionsData `json:"data"`        // Data containing success and failure lists.
}

ClosePositionsResponse represents the API response for closing positions.

type ClosePositionsSuccess

type ClosePositionsSuccess struct {
	OrderId   string `json:"orderId"`   // Order ID.
	ClientOid string `json:"clientOid"` // Customized order ID.
	Symbol    string `json:"symbol"`    // Trading pair.
}

type ErrorResponse

type ErrorResponse struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
}

type FeeDetail

type FeeDetail struct {
	Deduction         string `json:"deduction"`         // Whether or not fee deduction applies.
	FeeCoin           string `json:"feeCoin"`           // Crypto ticker of the fee.
	TotalDeductionFee string `json:"totalDeductionFee"` // Total fee deduction.
	TotalFee          string `json:"totalFee"`          // Total fee.
}

FeeDetail represents fee details for a fill.

type HistoryTransactionData

type HistoryTransactionData struct {
	TradeId string `json:"tradeId"` // Trade ID in descending order.
	Price   string `json:"price"`   // Price.
	Size    string `json:"size"`    // Amount (base coin).
	Side    string `json:"side"`    // Trading direction: "Sell" or "Buy".
	Ts      string `json:"ts"`      // Timestamp (Unix in ms).
	Symbol  string `json:"symbol"`  // Trading pair.
}

HistoryTransactionData represents a single transaction record.

type HistoryTransactionRequest

type HistoryTransactionRequest struct {
	// Trading pair, e.g. "BTCUSDT"
	Symbol string `json:"symbol"`
	// Product type, e.g. "usdt-futures", "coin-futures", etc.
	ProductType string `json:"productType"`
	// Optional: Number of queries (default 500, maximum 1000)
	Limit string `json:"limit,omitempty"`
	// Optional: Request older data before this ID (should be the endId of the previous page)
	IdLessThan string `json:"idLessThan,omitempty"`
	// Optional: Start timestamp (milliseconds)
	StartTime string `json:"startTime,omitempty"`
	// Optional: End timestamp (milliseconds)
	EndTime string `json:"endTime,omitempty"`
}

HistoryTransactionRequest holds the query parameters for the fills-history endpoint.

func (*HistoryTransactionRequest) ToParams

func (r *HistoryTransactionRequest) ToParams() map[string]string

ToParams converts the HistoryTransactionRequest into a map of query parameters.

func (*HistoryTransactionRequest) ToQueryString

func (r *HistoryTransactionRequest) ToQueryString() string

ToQueryString converts the request parameters to a URL query string.

type HistoryTransactionResponse

type HistoryTransactionResponse struct {
	Code        string                   `json:"code"`        // "00000" indicates success.
	Msg         string                   `json:"msg"`         // Response message.
	RequestTime int64                    `json:"requestTime"` // Request timestamp.
	Data        []HistoryTransactionData `json:"data"`        // List of transaction records.
}

HistoryTransactionResponse represents the API response for fills-history.

type LeverageData

type LeverageData struct {
	Symbol              string `json:"symbol"`              // Trading pair name.
	MarginCoin          string `json:"marginCoin"`          // Margin coin.
	LongLeverage        string `json:"longLeverage"`        // Leverage for long positions.
	ShortLeverage       string `json:"shortLeverage"`       // Leverage for short positions.
	CrossMarginLeverage string `json:"crossMarginLeverage"` // Leverage for cross margin mode.
	MarginMode          string `json:"marginMode"`          // Margin mode ("isolated" or "crossed").
}

LeverageData holds the leverage details returned by the API.

type ModifyOrderData

type ModifyOrderData struct {
	OrderId   string `json:"orderId"`   // Order ID of the modified order.
	ClientOid string `json:"clientOid"` // Customized order ID.
}

ModifyOrderData contains the order details returned by the modify order request.

type ModifyOrderRequest

type ModifyOrderRequest struct {
	OrderId                   string `json:"orderId,omitempty"`                   // Order ID (optional)
	ClientOid                 string `json:"clientOid,omitempty"`                 // Custom order ID (optional)
	Symbol                    string `json:"symbol"`                              // Trading pair, e.g. "ETHUSDT"
	ProductType               string `json:"productType"`                         // Product type (e.g. "USDT-FUTURES")
	MarginCoin                string `json:"marginCoin"`                          // Margin coin (capitalized), e.g. "USDT"
	NewClientOid              string `json:"newClientOid"`                        // New customized order ID after modification
	NewSize                   string `json:"newSize,omitempty"`                   // Modified order amount (if omitted, size stays unchanged)
	NewPrice                  string `json:"newPrice,omitempty"`                  // Modified price for new order (for limit orders)
	NewPresetStopSurplusPrice string `json:"newPresetStopSurplusPrice,omitempty"` // Modified take-profit value
	NewPresetStopLossPrice    string `json:"newPresetStopLossPrice,omitempty"`    // Modified stop-loss value
}

ModifyOrderRequest represents the payload for modifying an order. Either orderId or clientOid must be provided (if both are provided, orderId takes precedence).

type ModifyOrderResponse

type ModifyOrderResponse struct {
	Code        string          `json:"code"`        // "00000" indicates success.
	Msg         string          `json:"msg"`         // Response message.
	RequestTime int64           `json:"requestTime"` // Timestamp of the request.
	Data        ModifyOrderData `json:"data"`        // Order details.
}

ModifyOrderResponse represents the response returned after modifying an order.

type OrderCancelFailure

type OrderCancelFailure struct {
	OrderId   string `json:"orderId"`   // Order ID that failed to cancel.
	ClientOid string `json:"clientOid"` // Client customized order ID.
	ErrorMsg  string `json:"errorMsg"`  // Failure reason.
	ErrorCode string `json:"errorCode"` // Failure code.
}

type OrderCancelID

type OrderCancelID struct {
	// Order ID. If both orderId and clientOid are provided, orderId takes precedence.
	OrderId string `json:"orderId,omitempty"`
	// Customized order ID.
	ClientOid string `json:"clientOid,omitempty"`
}

OrderCancelID represents an individual order identifier.

type OrderCancelSuccess

type OrderCancelSuccess struct {
	OrderId   string `json:"orderId"`   // Successfully canceled order ID.
	ClientOid string `json:"clientOid"` // Client customized order ID.
}

type OrderData

type OrderData struct {
	OrderId   string `json:"orderId"`   // The exchange-assigned order ID.
	ClientOid string `json:"clientOid"` // The client order ID sent in the request.
}

type OrderDetailData

type OrderDetailData struct {
	Symbol                 string `json:"symbol"`                 // Trading pair
	Size                   string `json:"size"`                   // Amount
	OrderId                string `json:"orderId"`                // Order ID
	ClientOid              string `json:"clientOid"`              // Custom order ID
	BaseVolume             string `json:"baseVolume"`             // Amount of coins traded
	PriceAvg               string `json:"priceAvg"`               // Average price
	Fee                    string `json:"fee"`                    // Transaction fee
	Price                  string `json:"price"`                  // Order price
	State                  string `json:"state"`                  // Order status (live, partially_filled, filled, canceled)
	Side                   string `json:"side"`                   // Direction (buy or sell)
	Force                  string `json:"force"`                  // Order expiration date (gtc, ioc, fok, post only)
	TotalProfits           string `json:"totalProfits"`           // Total PnL
	PosSide                string `json:"posSide"`                // Position direction (long, short, net)
	MarginCoin             string `json:"marginCoin"`             // Margin coin
	PresetStopSurplusPrice string `json:"presetStopSurplusPrice"` // Set take-profit
	PresetStopLossPrice    string `json:"presetStopLossPrice"`    // Set stop-loss
	QuoteVolume            string `json:"quoteVolume"`            // Trading amount in quoting coin
	OrderType              string `json:"orderType"`              // Order type (limit or market)
	Leverage               string `json:"leverage"`               // Leverage
	MarginMode             string `json:"marginMode"`             // Margin mode (isolated, crossed)
	ReduceOnly             string `json:"reduceOnly"`             // Whether it's a reduce-only order (YES, NO)
	EnterPointSource       string `json:"enterPointSource"`       // Order source (WEB, API, SYS, ANDROID, IOS)
	TradeSide              string `json:"tradeSide"`              // Direction in open/close mode (open, close, etc.)
	PosMode                string `json:"posMode"`                // Position mode (one_way_mode, hedge_mode)
	OrderSource            string `json:"orderSource"`            // Order source (normal, market, etc.)
	CancelReason           string `json:"cancelReason"`           // Cancel reason (normal_cancel, stp_cancel)
	CTime                  string `json:"cTime"`                  // Creation time (ms)
	UTime                  string `json:"uTime"`                  // Update time (ms)
}

OrderDetailData holds the detailed information of an order.

type OrderDetailRequest

type OrderDetailRequest struct {
	Symbol      string `json:"symbol"`              // Required: Trading pair, must be capitalized (e.g. "ETHUSDT")
	ProductType string `json:"productType"`         // Required: Product type (e.g. "USDT-FUTURES")
	OrderId     string `json:"orderId,omitempty"`   // Optional: Order ID
	ClientOid   string `json:"clientOid,omitempty"` // Optional: Custom order ID
}

OrderDetailRequest represents the query parameters for getting order details. Either OrderId or ClientOid must be provided. If both are provided, OrderId takes precedence.

func (*OrderDetailRequest) ToParams

func (r *OrderDetailRequest) ToParams() map[string]string

type OrderDetailResponse

type OrderDetailResponse struct {
	Code        string          `json:"code"`        // "00000" indicates success.
	Msg         string          `json:"msg"`         // Response message.
	RequestTime int64           `json:"requestTime"` // Timestamp of the request.
	Data        OrderDetailData `json:"data"`        // Order detail data.
}

type OrderFill

type OrderFill struct {
	TradeId          string      `json:"tradeId"`          // Transaction ID.
	Symbol           string      `json:"symbol"`           // Trading pair.
	OrderId          string      `json:"orderId"`          // Order number.
	Price            string      `json:"price"`            // Order price.
	BaseVolume       string      `json:"baseVolume"`       // Amount of coins traded.
	FeeDetail        []FeeDetail `json:"feeDetail"`        // Transaction fee details.
	Side             string      `json:"side"`             // Transaction type (buy or sell).
	QuoteVolume      string      `json:"quoteVolume"`      // Trading amount in quote currency.
	Profit           string      `json:"profit"`           // Profit.
	EnterPointSource string      `json:"enterPointSource"` // Order source (e.g. "api").
	TradeSide        string      `json:"tradeSide"`        // Direction (e.g. "close", "open", etc.).
	PosMode          string      `json:"posMode"`          // Position mode ("one_way_mode" or "hedge_mode").
	TradeScope       string      `json:"tradeScope"`       // Trader tag ("taker" or "maker").
	CTime            string      `json:"cTime"`            // Transaction timestamp (ms).
}

OrderFill represents the details of a single fill (transaction).

type OrderFillHistory

type OrderFillHistory struct {
	TradeId          string      `json:"tradeId"`          // Transaction ID.
	Symbol           string      `json:"symbol"`           // Trading pair.
	OrderId          string      `json:"orderId"`          // Order ID.
	Price            string      `json:"price"`            // Deal price.
	BaseVolume       string      `json:"baseVolume"`       // Amount of coins traded.
	FeeDetail        []FeeDetail `json:"feeDetail"`        // Transaction fee details.
	Side             string      `json:"side"`             // Direction: "buy" or "sell".
	QuoteVolume      string      `json:"quoteVolume"`      // Trading amount in quote currency.
	Profit           string      `json:"profit"`           // Profit.
	EnterPointSource string      `json:"enterPointSource"` // Order source (e.g. "WEB", "API", "IOS").
	TradeSide        string      `json:"tradeSide"`        // Transaction direction (e.g. "close", "open", etc.).
	PosMode          string      `json:"posMode"`          // Position mode ("one_way_mode" or "hedge_mode").
	TradeScope       string      `json:"tradeScope"`       // Trader tag ("taker" or "maker").
	CTime            string      `json:"cTime"`            // Transaction timestamp (ms).
}

OrderFillHistory represents a single historical order fill.

type OrderFillHistoryData

type OrderFillHistoryData struct {
	FillList []OrderFillHistory `json:"fillList"` // List of order fills.
	EndId    string             `json:"endId"`    // Last order ID in the query.
}

OrderFillHistoryData holds the data payload for historical order fills.

type OrderFillHistoryRequest

type OrderFillHistoryRequest struct {
	// Optional: Order ID. Either orderId or clientOid is required; if both are provided, orderId takes precedence.
	OrderId string `json:"orderId,omitempty"`
	// Optional: Trading pair, e.g. "ETHUSDT".
	Symbol string `json:"symbol,omitempty"`
	// Required: Product type, e.g. "USDT-FUTURES", "COIN-FUTURES", etc.
	ProductType string `json:"productType"`
	// Optional: Start timestamp (in milliseconds). Maximum time span supported is a week.
	StartTime string `json:"startTime,omitempty"`
	// Optional: End timestamp (in milliseconds). Default is one week if not set.
	EndTime string `json:"endTime,omitempty"`
	// Optional: Requests data older than the given trade ID.
	IdLessThan string `json:"idLessThan,omitempty"`
	// Optional: Number of records to query. Default: 100; maximum: 100.
	Limit string `json:"limit,omitempty"`
}

OrderFillHistoryRequest represents the query parameters for retrieving historical order fill details.

func (*OrderFillHistoryRequest) ToParams

func (r *OrderFillHistoryRequest) ToParams() map[string]string

type OrderFillHistoryResponse

type OrderFillHistoryResponse struct {
	Code        string               `json:"code"`        // "00000" indicates success.
	Msg         string               `json:"msg"`         // Response message.
	RequestTime int64                `json:"requestTime"` // Timestamp of the request.
	Data        OrderFillHistoryData `json:"data"`        // Data payload.
}

OrderFillHistoryResponse represents the API response for historical order fill details.

func (*OrderFillHistoryResponse) UnmarshalJSON

func (r *OrderFillHistoryResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON is provided to allow custom unmarshaling if needed.

type OrderFillsData

type OrderFillsData struct {
	FillList []OrderFill `json:"fillList"` // List of order fills.
	EndId    string      `json:"endId"`    // Final trade ID in the returned range.
}

OrderFillsData holds the response data for order fills.

type OrderFillsRequest

type OrderFillsRequest struct {
	OrderId     string `json:"orderId,omitempty"`    // Optional: Order ID.
	Symbol      string `json:"symbol,omitempty"`     // Optional: Trading pair, e.g. "ETHUSDT".
	ProductType string `json:"productType"`          // Required: Product type, e.g. "USDT-FUTURES".
	IdLessThan  string `json:"idLessThan,omitempty"` // Optional: Request fills older than this trade ID.
	StartTime   string `json:"startTime,omitempty"`  // Optional: Start time (timestamp in ms).
	EndTime     string `json:"endTime,omitempty"`    // Optional: End time (timestamp in ms).
	Limit       string `json:"limit,omitempty"`      // Optional: Number of records to query; default is 100, max 100.
}

OrderFillsRequest represents the query parameters for retrieving order fill details.

func (*OrderFillsRequest) ToParams

func (r *OrderFillsRequest) ToParams() map[string]string

type OrderFillsResponse

type OrderFillsResponse struct {
	Code        string         `json:"code"`        // "00000" indicates success.
	Data        OrderFillsData `json:"data"`        // Order fills data.
	Msg         string         `json:"msg"`         // Response message.
	RequestTime int64          `json:"requestTime"` // Timestamp of the request.
}

OrderFillsResponse represents the full API response for order fill details.

func (*OrderFillsResponse) UnmarshalJSON

func (r *OrderFillsResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON provides a custom unmarshal for OrderFillsResponse if needed.

type OrderHistory

type OrderHistory struct {
	Symbol                 string `json:"symbol"`                 // Trading pair.
	Size                   string `json:"size"`                   // Order amount.
	OrderId                string `json:"orderId"`                // Order ID.
	ClientOid              string `json:"clientOid"`              // Custom order ID.
	BaseVolume             string `json:"baseVolume"`             // Amount of coins traded.
	Fee                    string `json:"fee"`                    // Transaction fee.
	Price                  string `json:"price"`                  // Order price.
	PriceAvg               string `json:"priceAvg"`               // Average order price.
	Status                 string `json:"status"`                 // Order status (e.g. "filled", "canceled").
	Side                   string `json:"side"`                   // Direction ("buy" or "sell").
	Force                  string `json:"force"`                  // Order expiration type (e.g. "gtc", "ioc", "fok", "post_only").
	TotalProfits           string `json:"totalProfits"`           // Total profit and loss.
	PosSide                string `json:"posSide"`                // Position direction ("long", "short", "net").
	MarginCoin             string `json:"marginCoin"`             // Margin coin.
	QuoteVolume            string `json:"quoteVolume"`            // Trading amount in quote currency.
	Leverage               string `json:"leverage"`               // Leverage.
	MarginMode             string `json:"marginMode"`             // Margin mode ("isolated", "crossed").
	ReduceOnly             string `json:"reduceOnly"`             // Whether the order is reduce-only ("YES", "NO").
	EnterPointSource       string `json:"enterPointSource"`       // Order source (e.g. "WEB", "API", "SYS", "ANDROID", "IOS").
	TradeSide              string `json:"tradeSide"`              // Trade side (e.g. "open", "close", etc.).
	PosMode                string `json:"posMode"`                // Position mode ("one_way_mode", "hedge_mode").
	OrderType              string `json:"orderType"`              // Order type ("limit", "market").
	OrderSource            string `json:"orderSource"`            // Order source category (e.g. "normal", "market", etc.).
	CTime                  string `json:"cTime"`                  // Creation time (ms).
	UTime                  string `json:"uTime"`                  // Last updated time (ms).
	PresetStopSurplusPrice string `json:"presetStopSurplusPrice"` // Take profit trigger price.
	PresetStopLossPrice    string `json:"presetStopLossPrice"`    // Stop loss trigger price.
}

OrderHistory represents the details of a single historical order.

type OrderPending

type OrderPending struct {
	Symbol                        string `json:"symbol"`                        // Trading pair.
	Size                          string `json:"size"`                          // Order amount.
	OrderId                       string `json:"orderId"`                       // Order ID.
	ClientOid                     string `json:"clientOid"`                     // Customized order ID.
	BaseVolume                    string `json:"baseVolume"`                    // Amount of coins traded.
	Fee                           string `json:"fee"`                           // Transaction fee.
	Price                         string `json:"price"`                         // Order price.
	PriceAvg                      string `json:"priceAvg"`                      // Average order price (empty when status is live).
	Status                        string `json:"status"`                        // Order status ("live", "partially_filled").
	Side                          string `json:"side"`                          // Order direction ("buy" or "sell").
	Force                         string `json:"force"`                         // Order expiration type ("gtc", "ioc", "fok", "post_only").
	TotalProfits                  string `json:"totalProfits"`                  // Total profit and loss (empty when status is live).
	PosSide                       string `json:"posSide"`                       // Position direction (e.g. "long", "short", "net").
	MarginCoin                    string `json:"marginCoin"`                    // Margin coin.
	QuoteVolume                   string `json:"quoteVolume"`                   // Trading amount in quote currency.
	Leverage                      string `json:"leverage"`                      // Leverage.
	MarginMode                    string `json:"marginMode"`                    // Margin mode ("isolated" or "crossed").
	ReduceOnly                    string `json:"reduceOnly"`                    // Whether order is reduce-only ("YES" or "NO").
	EnterPointSource              string `json:"enterPointSource"`              // Order source ("WEB", "API", "SYS", "ANDROID", "IOS").
	TradeSide                     string `json:"tradeSide"`                     // Trade side ("open", "close", etc.).
	PosMode                       string `json:"posMode"`                       // Position mode ("one_way_mode" or "hedge_mode").
	OrderType                     string `json:"orderType"`                     // Order type ("limit" or "market").
	OrderSource                   string `json:"orderSource"`                   // Order source category (e.g., "normal", "market", "profit_market", etc.).
	CTime                         string `json:"cTime"`                         // Creation time (timestamp in ms).
	UTime                         string `json:"uTime"`                         // Last update time (timestamp in ms).
	PresetStopSurplusPrice        string `json:"presetStopSurplusPrice"`        // Take profit trigger price.
	PresetStopSurplusType         string `json:"presetStopSurplusType"`         // Take profit trigger type ("fill_price", "mark_price").
	PresetStopSurplusExecutePrice string `json:"presetStopSurplusExecutePrice"` // Take profit execution price.
	PresetStopLossPrice           string `json:"presetStopLossPrice"`           // Stop loss trigger price.
	PresetStopLossType            string `json:"presetStopLossType"`            // Stop loss trigger type ("fill_price", "mark_price").
	PresetStopLossExecutePrice    string `json:"presetStopLossExecutePrice"`    // Stop loss execution price.
}

OrderPending represents a single pending order's details.

type OrdersHistoryData

type OrdersHistoryData struct {
	EntrustedList []OrderHistory `json:"entrustedList"` // List of historical orders.
	EndId         string         `json:"endId"`         // Last order ID (for pagination).
}

OrdersHistoryData holds the payload data for historical orders.

type OrdersHistoryRequest

type OrdersHistoryRequest struct {
	// Optional: Order ID. If both OrderId and ClientOid are provided, OrderId takes precedence.
	OrderId string `json:"orderId,omitempty"`
	// Optional: Custom order ID. If both are provided, OrderId takes precedence.
	ClientOid string `json:"clientOid,omitempty"`
	// Optional: Trading pair, e.g. "ETHUSDT".
	Symbol string `json:"symbol,omitempty"`
	// Required: Product type (e.g. "USDT-FUTURES", "COIN-FUTURES", "USDC-FUTURES", etc.).
	ProductType string `json:"productType"`
	// Optional: Requests orders older than the provided order ID.
	IdLessThan string `json:"idLessThan,omitempty"`
	// Optional: Filter by order source. For example: "normal", "market", "profit_market", etc.
	OrderSource string `json:"orderSource,omitempty"`
	// Optional: Start timestamp (in milliseconds). Maximum span supported is one week.
	StartTime string `json:"startTime,omitempty"`
	// Optional: End timestamp (in milliseconds). If not set, default is one week ago.
	EndTime string `json:"endTime,omitempty"`
	// Optional: Number of records to query; default and maximum is 100.
	Limit string `json:"limit,omitempty"`
}

OrdersHistoryRequest represents the query parameters for retrieving historical orders. It only supports data within the past 90 days.

func (*OrdersHistoryRequest) ToParams

func (r *OrdersHistoryRequest) ToParams() map[string]string

type OrdersHistoryResponse

type OrdersHistoryResponse struct {
	Code        string            `json:"code"`        // "00000" indicates success.
	Msg         string            `json:"msg"`         // Response message.
	RequestTime int64             `json:"requestTime"` // Request timestamp.
	Data        OrdersHistoryData `json:"data"`        // Data payload.
}

OrdersHistoryResponse represents the API response for querying historical orders.

type OrdersPendingData

type OrdersPendingData struct {
	EntrustedList []OrderPending `json:"entrustedList"` // List of pending orders.
	EndId         string         `json:"endId"`         // The final order ID used for pagination.
}

OrdersPendingData holds the data payload for the pending orders response.

type OrdersPendingRequest

type OrdersPendingRequest struct {
	// Optional: Order ID. If both OrderId and ClientOid are provided, OrderId takes precedence.
	OrderId string `json:"orderId,omitempty"`
	// Optional: Customized order ID. If both are provided, OrderId takes precedence.
	ClientOid string `json:"clientOid,omitempty"`
	// Optional: Trading pair, e.g. "ETHUSDT".
	Symbol string `json:"symbol,omitempty"`
	// Required: Product type, e.g. "USDT-FUTURES", "COIN-FUTURES", etc.
	ProductType string `json:"productType"`
	// Optional: Order status. If not specified, all pending orders (status "live") are returned.
	Status string `json:"status,omitempty"`
	// Optional: Requests data older than the provided order ID (endId of the previous query).
	IdLessThan string `json:"idLessThan,omitempty"`
	// Optional: Start timestamp (in milliseconds). Maximum time span supported is three months.
	StartTime string `json:"startTime,omitempty"`
	// Optional: End timestamp (in milliseconds). If not set, the default is three months ago.
	EndTime string `json:"endTime,omitempty"`
	// Optional: Number of records to query. Default is 100; maximum is 100.
	Limit string `json:"limit,omitempty"`
}

OrdersPendingRequest represents the query parameters for retrieving all pending orders.

func (*OrdersPendingRequest) ToParams

func (r *OrdersPendingRequest) ToParams() map[string]string

type OrdersPendingResponse

type OrdersPendingResponse struct {
	Code        string            `json:"code"`        // "00000" indicates success.
	Data        OrdersPendingData `json:"data"`        // Data payload.
	Msg         string            `json:"msg"`         // Response message.
	RequestTime int64             `json:"requestTime"` // Request timestamp.
}

OrdersPendingResponse represents the API response for querying pending orders.

type ParamBuilder

type ParamBuilder interface {
	ToParams() map[string]string
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	Symbol                 string `json:"symbol"`                           // Trading pair, e.g. ETHUSDT
	ProductType            string `json:"productType"`                      // e.g. "USDT-FUTURES"
	MarginMode             string `json:"marginMode"`                       // "isolated" or "crossed"
	MarginCoin             string `json:"marginCoin"`                       // e.g. "USDT"
	Size                   string `json:"size"`                             // Order amount (base coin)
	Price                  string `json:"price,omitempty"`                  // Order price (required for limit orders)
	Side                   string `json:"side"`                             // "buy" or "sell"
	TradeSide              string `json:"tradeSide,omitempty"`              // "open" or "close" (only for hedge-mode)
	OrderType              string `json:"orderType"`                        // "limit" or "market"
	Force                  string `json:"force,omitempty"`                  // Order expiration (e.g., "gtc", "ioc", "fok", "post_only")
	ClientOid              string `json:"clientOid,omitempty"`              // Customized order ID
	ReduceOnly             string `json:"reduceOnly,omitempty"`             // "YES" or "NO" (only for one-way mode)
	PresetStopSurplusPrice string `json:"presetStopSurplusPrice,omitempty"` // Take-profit value (optional)
	PresetStopLossPrice    string `json:"presetStopLossPrice,omitempty"`    // Stop-loss value (optional)
	StpMode                string `json:"stpMode,omitempty"`                // Self trade prevention mode (optional)
}

PlaceOrderRequest represents the payload for placing an order.

func (PlaceOrderRequest) ToParams

func (r PlaceOrderRequest) ToParams() map[string]string

type PlaceOrderResponse

type PlaceOrderResponse struct {
	Code        string    `json:"code"`        // "00000" indicates success.
	Msg         string    `json:"msg"`         // Message, usually "success" on success.
	RequestTime int64     `json:"requestTime"` // Timestamp of the request.
	Data        OrderData `json:"data"`        // Data payload containing order details.
}

type PlacePosTpslOrderData

type PlacePosTpslOrderData struct {
	// Order ID.
	OrderId string `json:"orderId"`
}

PlacePosTpslOrderData represents an individual order's response data.

type PlacePosTpslOrderRequest

type PlacePosTpslOrderRequest struct {
	// Required: Margin currency (e.g., "USDT").
	MarginCoin string `json:"marginCoin"`
	// Required: Product type (e.g., "usdt-futures", "coin-futures", etc.).
	ProductType string `json:"productType"`
	// Required: Trading pair, e.g. "BTCUSDT".
	Symbol string `json:"symbol"`
	// Required: Take Profit Trigger price.
	StopSurplusTriggerPrice string `json:"stopSurplusTriggerPrice"`
	// Optional: Take Profit Trigger type.
	// Valid values: "fill_price" (market price), "mark_price" (mark price).
	StopSurplusTriggerType string `json:"stopSurplusTriggerType,omitempty"`
	// Optional: Take Profit Execution price.
	// If set to 0 or not provided, market price execution is assumed.
	StopSurplusExecutePrice string `json:"stopSurplusExecutePrice,omitempty"`
	// Required: Stop Loss Trigger price.
	StopLossTriggerPrice string `json:"stopLossTriggerPrice"`
	// Optional: Stop Loss Trigger type.
	// Valid values: "fill_price" (market price), "mark_price" (mark price).
	StopLossTriggerType string `json:"stopLossTriggerType,omitempty"`
	// Optional: Stop Loss Execution price.
	// If set to 0 or not provided, market price execution is assumed.
	StopLossExecutePrice string `json:"stopLossExecutePrice,omitempty"`
	// Required: Position side.
	// For two-way positions use "long" or "short"; for one-way positions use "buy" or "sell".
	HoldSide string `json:"holdSide"`
	// Optional: STP Mode.
	// Valid values: "none", "cancel_taker", "cancel_maker", "cancel_both".
	StpMode string `json:"stpMode,omitempty"`
}

PlacePosTpslOrderRequest represents the payload for placing simultaneous stop-profit and stop-loss plan orders.

type PlacePosTpslOrderResponse

type PlacePosTpslOrderResponse struct {
	// "00000" indicates success.
	Code string `json:"code"`
	// Response message.
	Msg string `json:"msg"`
	// Timestamp of the request.
	RequestTime int64 `json:"requestTime"`
	// List of order responses.
	Data []PlacePosTpslOrderData `json:"data"`
}

PlacePosTpslOrderResponse represents the API response for placing simultaneous stop-profit and stop-loss plan orders.

type PlaceTpslOrderData

type PlaceTpslOrderData struct {
	// Order ID.
	OrderId string `json:"orderId"`
	// Customized order ID.
	ClientOid string `json:"clientOid"`
}

PlaceTpslOrderData holds the order information returned in a successful response.

type PlaceTpslOrderRequest

type PlaceTpslOrderRequest struct {
	// Required: Margin currency (capitalized, e.g., "USDT").
	MarginCoin string `json:"marginCoin"`
	// Required: Product type (e.g., "usdt-futures", "coin-futures", etc.).
	ProductType string `json:"productType"`
	// Required: Trading pair, e.g., "ethusdt".
	Symbol string `json:"symbol"`
	// Required: Order plan type.
	// Valid values:
	// profit_plan: take profit plan;
	// loss_plan: stop loss plan;
	// moving_plan: trailing stop;
	// pos_profit: position take profit;
	// pos_loss: position stop loss.
	PlanType string `json:"planType"`
	// Required: Trigger price.
	TriggerPrice string `json:"triggerPrice"`
	// Optional: Trigger type.
	// fill_price: market price;
	// mark_price: mark price.
	TriggerType string `json:"triggerType,omitempty"`
	// Optional: Execution price.
	// If 0 or not provided, it means market price execution.
	ExecutePrice string `json:"executePrice,omitempty"`
	// Required: Position side.
	// For two-way positions: "long" or "short".
	HoldSide string `json:"holdSide"`
	// Required when planType is profit_plan, loss_plan or moving_plan.
	// Represents order quantity (base coin).
	Size string `json:"size,omitempty"`
	// Optional: Callback range, required only when planType is moving_plan.
	RangeRate string `json:"rangeRate,omitempty"`
	// Optional: Customized order ID.
	ClientOid string `json:"clientOid,omitempty"`
	// Optional: STP Mode.
	// Valid values: none, cancel_taker, cancel_maker, cancel_both.
	StpMode string `json:"stpMode,omitempty"`
}

PlaceTpslOrderRequest represents the payload for placing a stop-profit and stop-loss plan order.

type PlaceTpslOrderResponse

type PlaceTpslOrderResponse struct {
	// "00000" indicates success.
	Code string `json:"code"`
	// Response message.
	Msg string `json:"msg"`
	// Timestamp of the request.
	RequestTime int64 `json:"requestTime"`
	// Order details.
	Data PlaceTpslOrderData `json:"data"`
}

PlaceTpslOrderResponse represents the API response for placing a stop-profit and stop-loss plan order.

type PositionHistoryData

type PositionHistoryData struct {
	List  []PositionHistoryItem `json:"list"`
	EndId string                `json:"endId"`
}

PositionHistoryData holds the response data and pagination ID.

type PositionHistoryItem

type PositionHistoryItem struct {
	PositionId    string `json:"positionId"`
	MarginCoin    string `json:"marginCoin"`
	Symbol        string `json:"symbol"`
	HoldSide      string `json:"holdSide"` // long / short
	OpenAvgPrice  string `json:"openAvgPrice"`
	CloseAvgPrice string `json:"closeAvgPrice"`
	MarginMode    string `json:"marginMode"` // isolated / crossed
	OpenTotalPos  string `json:"openTotalPos"`
	CloseTotalPos string `json:"closeTotalPos"`
	PNL           string `json:"pnl"`
	NetProfit     string `json:"netProfit"`
	TotalFunding  string `json:"totalFunding"`
	OpenFee       string `json:"openFee"`
	CloseFee      string `json:"closeFee"`
	CTime         string `json:"cTime"` // Timestamp in ms
	UTime         string `json:"uTime"` // Timestamp in ms
}

PositionHistoryItem represents a single historical position.

type PositionHistoryRequest

type PositionHistoryRequest struct {
	Symbol      string `json:"symbol,omitempty"`
	ProductType string `json:"productType,omitempty"`
	IdLessThan  string `json:"idLessThan,omitempty"`
	StartTime   string `json:"startTime,omitempty"` // Timestamp in ms
	EndTime     string `json:"endTime,omitempty"`   // Timestamp in ms
	Limit       string `json:"limit,omitempty"`
}

PositionHistoryRequest represents the query parameters for retrieving historical positions.

func (*PositionHistoryRequest) ToParams

func (r *PositionHistoryRequest) ToParams() map[string]string

ToParams converts the PositionHistoryRequest to query parameters.

type PositionHistoryResponse

type PositionHistoryResponse struct {
	Code        string              `json:"code"`
	Msg         string              `json:"msg"`
	RequestTime int64               `json:"requestTime"`
	Data        PositionHistoryData `json:"data"`
}

PositionHistoryResponse represents the full API response for historical positions.

type SetLeverageRequest

type SetLeverageRequest struct {
	Symbol      string `json:"symbol"`             // Trading pair, e.g. "btcusdt"
	ProductType string `json:"productType"`        // Product type, e.g. "USDT-FUTURES"
	MarginCoin  string `json:"marginCoin"`         // Margin coin (must be capitalized in response, but request can be lowercase), e.g. "usdt"
	Leverage    string `json:"leverage"`           // Leverage value, e.g. "20"
	HoldSide    string `json:"holdSide,omitempty"` // Optional: Position direction ("long" or "short")
}

SetLeverageRequest represents the request parameters for adjusting leverage.

type SetLeverageResponse

type SetLeverageResponse struct {
	Code        string       `json:"code"`        // "00000" indicates success.
	Data        LeverageData `json:"data"`        // Leverage details.
	Msg         string       `json:"msg"`         // Response message.
	RequestTime int64        `json:"requestTime"` // Timestamp of the request.
}

SetLeverageResponse represents the API response for setting leverage.

type SinglePosition

type SinglePosition struct {
	MarginCoin       string `json:"marginCoin"`       // Margin coin
	Symbol           string `json:"symbol"`           // Trading pair name
	HoldSide         string `json:"holdSide"`         // Position direction ("long" or "short")
	OpenDelegateSize string `json:"openDelegateSize"` // Amount to be filled of the current order (base coin)
	MarginSize       string `json:"marginSize"`       // Margin amount (margin coin)
	Available        string `json:"available"`        // Available amount for positions (base coin)
	Locked           string `json:"locked"`           // Frozen amount (base coin)
	Total            string `json:"total"`            // Total amount (available + locked)
	Leverage         string `json:"leverage"`         // Leverage
	AchievedProfits  string `json:"achievedProfits"`  // Realized PnL (exclude fees)
	OpenPriceAvg     string `json:"openPriceAvg"`     // Average entry price
	MarginMode       string `json:"marginMode"`       // Margin mode ("isolated" or "crossed")
	PosMode          string `json:"posMode"`          // Position mode ("one_way_mode" or "hedge_mode")
	UnrealizedPL     string `json:"unrealizedPL"`     // Unrealized profit and loss
	LiquidationPrice string `json:"liquidationPrice"` // Estimated liquidation price (if <=0, no liquidation risk)
	KeepMarginRate   string `json:"keepMarginRate"`   // Tiered maintenance margin rate
	MarkPrice        string `json:"markPrice"`        // Mark price
	BreakEvenPrice   string `json:"breakEvenPrice"`   // Breakeven price
	TotalFee         string `json:"totalFee"`         // Funding fee (accumulated)
	DeductedFee      string `json:"deductedFee"`      // Deducted transaction fees
	MarginRatio      string `json:"marginRatio"`      // Maintenance margin rate (e.g. 0.1 means 10%)
	AssetMode        string `json:"assetMode"`        // Asset mode ("single" or "union")
	UTime            string `json:"uTime"`            // Last updated time (ms)
	AutoMargin       string `json:"autoMargin"`       // Auto Margin ("on" or "off")
	CTime            string `json:"cTime"`            // Creation time (ms)
}

SinglePosition represents the details of a single position.

type SinglePositionRequest

type SinglePositionRequest struct {
	// Trading pair, e.g. "btcusdt"
	Symbol string `json:"symbol"`
	// Product type, e.g. "USDT-FUTURES", "COIN-FUTURES", etc.
	ProductType string `json:"productType"`
	// Margin coin, must be capitalized, e.g. "USDT"
	MarginCoin string `json:"marginCoin"`
}

SinglePositionRequest holds the query parameters for the single-position endpoint.

func (*SinglePositionRequest) ToParams

func (r *SinglePositionRequest) ToParams() map[string]string

type SinglePositionResponse

type SinglePositionResponse struct {
	Code        string           `json:"code"`        // "00000" indicates success.
	Msg         string           `json:"msg"`         // Response message.
	RequestTime int64            `json:"requestTime"` // Request timestamp.
	Data        []SinglePosition `json:"data"`        // Slice of position information
}

SinglePositionResponse represents the API response for querying a single position.

type StringOrNumber

type StringOrNumber string

StringOrNumber can handle JSON values like "20" or 20 and store them as a string.

func (StringOrNumber) Float64

func (sn StringOrNumber) Float64() (float64, error)

Float64 is a helper method to parse the internal string as a float64.

func (*StringOrNumber) UnmarshalJSON

func (sn *StringOrNumber) UnmarshalJSON(b []byte) error

type TickerData

type TickerData struct {
	Symbol            string `json:"symbol"`            // Trading pair name.
	LastPr            string `json:"lastPr"`            // Last price.
	AskPr             string `json:"askPr"`             // Ask price.
	BidPr             string `json:"bidPr"`             // Bid price.
	BidSz             string `json:"bidSz"`             // Buying amount.
	AskSz             string `json:"askSz"`             // Selling amount.
	High24h           string `json:"high24h"`           // 24h high.
	Low24h            string `json:"low24h"`            // 24h low.
	Ts                string `json:"ts"`                // Current timestamp in milliseconds.
	Change24h         string `json:"change24h"`         // Price change in 24 hours.
	BaseVolume        string `json:"baseVolume"`        // Trading volume of the coin.
	QuoteVolume       string `json:"quoteVolume"`       // Trading volume of quote currency.
	UsdtVolume        string `json:"usdtVolume"`        // Trading volume in USDT.
	OpenUtc           string `json:"openUtc"`           // UTC opening price.
	ChangeUtc24h      string `json:"changeUtc24h"`      // UTC 24h price change.
	IndexPrice        string `json:"indexPrice"`        // Index price.
	FundingRate       string `json:"fundingRate"`       // Funding rate.
	HoldingAmount     string `json:"holdingAmount"`     // Current holding positions.
	DeliveryStartTime string `json:"deliveryStartTime"` // Delivery start time (for delivery contracts).
	DeliveryTime      string `json:"deliveryTime"`      // Delivery time (for delivery contracts).
	DeliveryStatus    string `json:"deliveryStatus"`    // Delivery status.
	Open24h           string `json:"open24h"`           // Entry price of the last 24 hours.
	MarkPrice         string `json:"markPrice"`         // Mark price.
}

TickerData holds the ticker details.

func (TickerData) AskPrice

func (td TickerData) AskPrice() float64

func (TickerData) BidPrice

func (td TickerData) BidPrice() float64

type TickerRequest

type TickerRequest struct {
	// Trading pair, e.g. "ETHUSDM24"
	Symbol string `json:"symbol"`
	// Product type, e.g. "COIN-FUTURES", "USDT-FUTURES", etc.
	ProductType string `json:"productType"`
}

TickerRequest holds the query parameters for the ticker endpoint.

func (*TickerRequest) ToParams

func (r *TickerRequest) ToParams() map[string]string

ToParams converts TickerRequest to a map of query parameters.

type TickerResponse

type TickerResponse struct {
	Code        string       `json:"code"`        // "00000" indicates success.
	Msg         string       `json:"msg"`         // Response message.
	RequestTime int64        `json:"requestTime"` // Request timestamp.
	Data        []TickerData `json:"data"`        // Array of ticker data.
}

TickerResponse represents the API response for the ticker data.

Jump to

Keyboard shortcuts

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