Versions in this module Expand all Collapse all v1 v1.0.0 Jun 16, 2026 Changes in this version + const ArgChannel + const ArgInstId + const ArgInstType + const BaseURL + const ReadTimeout + const ReconnectWait + const WSBaseURL + const WSPrivateBaseURL + func Request[T any](c *Client, ctx context.Context, method Method, path string, ...) ([]T, error) + type APIError struct + Code string + Message string + func (e *APIError) Error() string + type AccountConfig struct + AcctLv string + AcctStpMode string + AutoLoan bool + CtIsoMode string + EnableSpotBorrow bool + FeeType string + GreeksType string + Ip string + KycLv string + Label string + Level string + LevelTmp string + LiquidationGear string + MainUid string + MgnIsoMode string + OpAuth string + Perm string + PosMode string + RoleType string + SettleCcy string + SettleCcyList []string + SpotBorrowAutoRepay bool + SpotOffsetType string + SpotRoleType string + SpotTraderInsts []string + StgyType string + TraderInsts []string + Type string + Uid string + func (c AccountConfig) AccountLevel() AccountLevel + type AccountLevel string + const AccountLevelMultiCurrencyMargin + const AccountLevelPortfolioMargin + const AccountLevelSimple + const AccountLevelSingleCurrencyMargin + const AccountLevelUnknown + type Announcement struct + AnnType string + BusinessTime string + PublishTime string + Title string + URL string + type Balance struct + AdjEq string + AvailEq string + BorrowFroz string + Delta string + DeltaLever string + DeltaNeutralStatus string + Details []BalanceDetail + Imr string + IsoEq string + MgnRatio string + Mmr string + NotionalUsd string + NotionalUsdForBorrow string + NotionalUsdForFutures string + NotionalUsdForOption string + NotionalUsdForSwap string + OrdFroz string + TotalEq string + UTime string + Upl string + type BalanceDetail struct + AccAvgPx string + AutoLendMtAmt string + AutoLendStatus string + AvailBal string + AvailEq string + BorrowFroz string + CashBal string + Ccy string + ClSpotInUseAmt string + ColBorrAutoConversion string + ColRes string + CollateralEnabled bool + CollateralRestrict bool + CrossLiab string + DisEq string + Eq string + EqUsd string + FixedBal string + FrozenBal string + FrpType string + Imr string + Interest string + IsoEq string + IsoLiab string + IsoUpl string + Liab string + MaxLoan string + MaxSpotInUse string + MgnRatio string + Mmr string + NotionalLever string + OpenAvgPx string + OrdFrozen string + RewardBal string + SmtSyncEq string + SpotBal string + SpotCopyTradingEq string + SpotInUseAmt string + SpotIsoBal string + SpotUpl string + SpotUplRatio string + StgyEq string + TotalPnl string + TotalPnlRatio string + Twap string + UTime string + Upl string + UplLiab string + type BaseResponse struct + Code string + Data []T + Message string + type CancelOrderRequest struct + ClOrdId *string + InstId string + InstIdCode *int64 + OrdId *string + type Candle [9]string + type Client struct + ApiKey string + BaseURL string + HTTPClient *http.Client + Passphrase string + SecretKey string + Signer *Signer + func NewClient() *Client + func (c *Client) CancelOrder(ctx context.Context, instId, ordId, clOrdId string) ([]OrderId, error) + func (c *Client) CancelOrders(ctx context.Context, reqs []CancelOrderRequest) ([]OrderId, error) + func (c *Client) ClosePosition(ctx context.Context, instId, mgnMode string) ([]ClosePosition, error) + func (c *Client) Do(ctx context.Context, method Method, path string, payload interface{}, ...) ([]byte, error) + func (c *Client) GetAccountBalance(ctx context.Context, ccy *string) ([]Balance, error) + func (c *Client) GetAccountConfig(ctx context.Context) ([]AccountConfig, error) + func (c *Client) GetAllFundingRates(ctx context.Context) ([]FundingRateData, error) + func (c *Client) GetAnnouncements(ctx context.Context, annType string) ([]Announcement, error) + func (c *Client) GetCandles(ctx context.Context, instId string, bar *string, after *string, before *string, ...) ([]Candle, error) + func (c *Client) GetFundingRate(ctx context.Context, instId string) (*FundingRateData, error) + func (c *Client) GetFundingRateHistory(ctx context.Context, instId string, beforeMillis, afterMillis int64, limit int) ([]FundingRateHistoryEntry, error) + func (c *Client) GetHistoryTrades(ctx context.Context, instId string, typ int, before, after string, limit int) ([]HistoryTrade, error) + func (c *Client) GetInstruments(ctx context.Context, instType string) ([]Instrument, error) + func (c *Client) GetInstrumentsByFamily(ctx context.Context, instType, instFamily string) ([]Instrument, error) + func (c *Client) GetOpenInterest(ctx context.Context, instId string) (*OpenInterest, error) + func (c *Client) GetOrder(ctx context.Context, instId, ordId, clOrdId string) ([]Order, error) + func (c *Client) GetOrderBook(ctx context.Context, instId string, sz *int) ([]OrderBook, error) + func (c *Client) GetOrders(ctx context.Context, instType, instId *string) ([]Order, error) + func (c *Client) GetPositions(ctx context.Context, instType, instId *string) ([]Position, error) + func (c *Client) GetTicker(ctx context.Context, instId string) ([]Ticker, error) + func (c *Client) GetTickers(ctx context.Context, instType string, instFamily *string) ([]Ticker, error) + func (c *Client) GetTradeFee(ctx context.Context, instType string, instId *string) ([]TradeFee, error) + func (c *Client) GetTrades(ctx context.Context, instId string, limit *int) ([]PublicTrade, error) + func (c *Client) ModifyOrder(ctx context.Context, req *ModifyOrderRequest) ([]OrderId, error) + func (c *Client) PlaceOrder(ctx context.Context, req *OrderRequest) ([]OrderId, error) + func (c *Client) SetLeverage(ctx context.Context, params SetLeverage) ([]SetLeverage, error) + func (c *Client) SetPositionMode(ctx context.Context, posMode string) ([]PositionMode, error) + func (c *Client) WithCredentials(apiKey, secretKey, passphrase string) *Client + func (c *Client) WithHTTPClient(httpClient *http.Client) *Client + type ClosePosition struct + ClOrdId string + InstId string + PosSide string + Tag string + type Environment string + const Production + const Simulated + type FeeGroup struct + GroupId string + Maker string + Taker string + type FundingRate struct + FundingRate string + FundingTime string + InstrumentID string + InstrumentType string + NextFundingRate string + NextFundingTime string + Premium string + SettFundingRate string + SettState string + Ts string + type FundingRateData struct + FundingIntervalHours int64 + FundingRate string + FundingTime string + HourlyFundingRate string + NextFundingTime string + Symbol string + type FundingRateHistoryEntry struct + FundingRate string + FundingTime string + InstId string + InstType string + Method string + RealizedRate string + type HistoryTrade struct + InstId string + Px string + Side string + Sz string + TradeId string + Ts string + type Instrument struct + BaseCcy string + CtMult string + CtVal string + CtValCcy string + ExpTime string + GroupId string + InstCategory string + InstFamily string + InstId string + InstIdCode *int64 + InstType string + Leverage string + ListTime string + LotSz string + MinSz string + OptType string + QuoteCcy string + RuleType string + SettCcy string + SettleCcy string + State string + Stk string + TickSz string + TradeQuoteCcyList []string + Uly string + type LinkedAlgoOrder struct + AlgoId string + type Method string + const MethodGet + const MethodPost + type MgnMode string + const MgnModeCash + const MgnModeCross + const MgnModeIsolated + type ModifyOrderRequest struct + ClOrdId *string + CxlOnFail *bool + InstId string + InstIdCode *int64 + NewPx *string + NewSz *string + OrdId *string + ReqId *string + type OpenInterest struct + InstId string + InstType string + OI string + OICcy string + OIUsd string + Ts string + type Order struct + AccFillSz string + AlgoClOrdId string + AlgoId string + AttachAlgoClOrdId string + AttachAlgoOrds []int + AvgPx string + CTime string + CancelSource string + CancelSourceReason string + Category string + Ccy string + ClOrdId string + ExecType string + Fee string + FeeCcy string + FillPx string + FillSz string + FillTime string + InstId string + InstType string + IsTpLimit string + Lever string + LinkedAlgoOrder LinkedAlgoOrder + OrdId string + OrdType OrderType + Pnl string + PosSide PosSide + Px string + PxType string + PxUsd string + PxVol string + QuickMgnType string + Rebate string + RebateCcy string + ReduceOnly string + Side Side + SlOrdPx string + SlTriggerPx string + SlTriggerPxType string + Source string + State OrderStatus + StpId string + StpMode string + Sz string + Tag string + TdMode TdMode + TgtCcy string + TpOrdPx string + TpTriggerPx string + TpTriggerPxType string + TradeId string + TradeQuoteCcy string + UTime string + type OrderBook struct + Asks [][]string + Bids [][]string + Ts string + type OrderId struct + ClOrdId string + OrdId string + SCode string + SMsg string + SubCode string + Tag *string + Ts string + type OrderRequest struct + Ccy *string + ClOrdId *string + InstId string + InstIdCode *int64 + OrdType string + PosSide *string + Px *string + ReduceOnly *bool + Side string + Sz string + Tag *string + TdMode string + TgtCcy *string + type OrderStatus string + const OrderStatusCanceled + const OrderStatusFilled + const OrderStatusLive + const OrderStatusMmpCanceled + const OrderStatusPartiallyFilled + type OrderType string + const OrderTypeFok + const OrderTypeIoc + const OrderTypeLimit + const OrderTypeMarket + const OrderTypeOptimalLimitIoc + const OrderTypePostOnly + type PendingRequest struct + Error chan []byte + Success chan []byte + type PosSide string + const PosSideLong + const PosSideNet + const PosSideShort + type Position struct + Adl string + AvailPos string + AvgPx string + BaseBal string + BaseBorrowed string + BaseInterest string + BePx string + BizRefId string + BizRefType string + CTime string + Ccy string + ClSpotInUseAmt string + CloseOrderAlgo []interface{} + DeltaBS string + DeltaPA string + Fee string + FundingFee string + GammaBS string + GammaPA string + HedgedPos string + IdxPx string + Imr string + InstId string + InstType string + Interest string + Last string + Lever string + Liab string + LiabCcy string + LiqPenalty string + LiqPx string + Margin string + MarkPx string + MaxSpotInUseAmt string + MgnMode MgnMode + MgnRatio string + Mmr string + NonSettleAvgPx string + NotionalUsd string + OptVal string + PendingCloseOrdLiabVal string + Pnl string + Pos string + PosCcy string + PosId string + PosSide PosSide + QuoteBal string + QuoteBorrowed string + QuoteInterest string + RealizedPnl string + SettledPnl string + SpotInUseAmt string + SpotInUseCcy string + ThetaBS string + ThetaPA string + TradeId string + UTime string + Upl string + UplLastPx string + UplRatio string + UplRatioLastPx string + UsdPx string + VegaBS string + VegaPA string + type PositionMode struct + PosMode string + type PublicTrade struct + InstId string + Px string + Side string + Sz string + TradeId string + Ts string + type SetLeverage struct + InstId string + Lever int + MgnMode string + PosSide string + type Side string + const SideBuy + const SideSell + type Signer struct + SecretKey string + func NewSigner(secretKey string) *Signer + func (s *Signer) SignRequest(req *http.Request, method, path, body string, apiKey, passphrase string) + type TdMode string + const TdModeCash + const TdModeCross + const TdModeIsolated + type Ticker struct + AskPx string + AskSz string + BidPx string + BidSz string + High24h string + InstId string + InstType string + Last string + LastSz string + Low24h string + Open24h string + SodUtc0 string + SodUtc8 string + Ts string + Vol24h string + VolCcy24h string + type TradeFee struct + Category string + FeeGroups []FeeGroup + InstType string + Ts string + type WSClient struct + ApiKey string + Conn *websocket.Conn + Connected chan bool + Dialer *websocket.Dialer + IsPrivate bool + Logger *zap.SugaredLogger + Passphrase string + PendingReqs map[int64]*PendingRequest + SecretKey string + Subs map[WsSubscribeArgs]func([]byte) + URL string + WriteMu sync.Mutex + func NewWSClient(ctx context.Context) *WSClient + func NewWsClient(ctx context.Context) *WSClient + func (c *WSClient) AddPendingRequest(id int64) (chan []byte, chan []byte) + func (c *WSClient) CancelOrderWS(instIdCode int64, ordId, clOrdId *string) (*OrderId, error) + func (c *WSClient) CancelOrdersWS(reqs []CancelOrderRequest) ([]OrderId, error) + func (c *WSClient) Connect() error + func (c *WSClient) Login() error + func (c *WSClient) ModifyOrderWS(req *ModifyOrderRequest) (*OrderId, error) + func (c *WSClient) PlaceOrderWS(req *OrderRequest) (*OrderId, error) + func (c *WSClient) RemovePendingRequest(id int64) + func (c *WSClient) Subscribe(args WsSubscribeArgs, handler func(data []byte)) error + func (c *WSClient) SubscribeCandles(instId string, channel string, handler func(Candle)) error + func (c *WSClient) SubscribeOrderBook(instId string, handler func(*OrderBook, string)) error + func (c *WSClient) SubscribeOrders(instType string, instId *string, handler func(*Order)) error + func (c *WSClient) SubscribePositions(instType string, handler func(*Position)) error + func (c *WSClient) SubscribeTicker(instId string, handler func(*Ticker)) error + func (c *WSClient) SubscribeTrades(instId string, handler func(*PublicTrade)) error + func (c *WSClient) Unsubscribe(args WsSubscribeArgs) error + func (c *WSClient) WithCredentials(apiKey, secretKey, passphrase string) *WSClient + type WsClient = WSClient + type WsEvent struct + Code string + Event string + Msg string + type WsOrderData struct + type WsOrderOp struct + Args []interface{} + Id string + Op string + type WsPositionData struct + type WsPushData struct + Action string + Arg map[string]string + Data []T + type WsSubscribeArgs struct + Channel string + InstId string + InstType string + type WsSubscribeRes struct + Arg *WsSubscribeArgs + Code *string + Data *json.RawMessage + Event *string + ID *string + Msg *string