sdk

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountAsset

type AccountAsset struct {
	Coin      string `json:"coin"`
	Available string `json:"available"`
	Frozen    string `json:"frozen"`
	Locked    string `json:"locked"`
	Equity    string `json:"equity"`
	USDTValue string `json:"usdtValue"`
	Bonus     string `json:"bonus"`
}

type AccountAssets

type AccountAssets struct {
	AccountEquity    string         `json:"accountEquity"`
	UsdtEquity       string         `json:"usdtEquity"`
	Available        string         `json:"available"`
	UnrealizedPL     string         `json:"unrealizedPL"`
	Coupon           string         `json:"coupon"`
	UnionTotalMargin string         `json:"unionTotalMargin"`
	Assets           []AccountAsset `json:"assets"`
}

type AccountFeeRate

type AccountFeeRate struct {
	MakerFeeRate string `json:"makerFeeRate"`
	TakerFeeRate string `json:"takerFeeRate"`
}

type AccountInfo

type AccountInfo struct {
	UserID      string   `json:"userId"`
	InviterID   string   `json:"inviterId"`
	ParentID    string   `json:"parentId"`
	ChannelCode string   `json:"channelCode"`
	Channel     string   `json:"channel"`
	IPs         string   `json:"ips"`
	PermType    string   `json:"permType"`
	Permissions []string `json:"permissions"`
	RegisTime   string   `json:"regisTime"`
}

type CancelAllOrdersRequest

type CancelAllOrdersRequest struct {
	Category string `json:"category"`
	Symbol   string `json:"symbol"`
}

type CancelOrderRequest

type CancelOrderRequest struct {
	Category  string `json:"category"`
	Symbol    string `json:"symbol"`
	OrderID   string `json:"orderId,omitempty"`
	ClientOID string `json:"clientOid,omitempty"`
}

type CancelOrderResponse

type CancelOrderResponse struct {
	OrderID   string `json:"orderId"`
	ClientOID string `json:"clientOid"`
}

type Candle

type Candle [7]NumberString

func (*Candle) UnmarshalJSON

func (c *Candle) UnmarshalJSON(data []byte) error

type ClassicFillFeeDetail

type ClassicFillFeeDetail struct {
	FeeCoin           string `json:"feeCoin"`
	Deduction         string `json:"deduction"`
	TotalDeductionFee string `json:"totalDeductionFee"`
	TotalFee          string `json:"totalFee"`
}

type ClassicMixAccount

type ClassicMixAccount struct {
	MarginCoin            string       `json:"marginCoin"`
	Locked                string       `json:"locked"`
	Available             string       `json:"available"`
	CrossedMaxAvailable   string       `json:"crossedMaxAvailable"`
	IsolatedMaxAvailable  string       `json:"isolatedMaxAvailable"`
	MaxTransferOut        string       `json:"maxTransferOut"`
	AccountEquity         string       `json:"accountEquity"`
	UsdtEquity            string       `json:"usdtEquity"`
	BtcEquity             string       `json:"btcEquity"`
	CrossedRiskRate       string       `json:"crossedRiskRate"`
	CrossedMarginLeverage NumberString `json:"crossedMarginLeverage"`
	IsolatedLongLever     NumberString `json:"isolatedLongLever"`
	IsolatedShortLever    NumberString `json:"isolatedShortLever"`
	MarginMode            string       `json:"marginMode"`
	PosMode               string       `json:"posMode"`
	UnrealizedPL          string       `json:"unrealizedPL"`
	Coupon                string       `json:"coupon"`
	CrossedUnrealizedPL   string       `json:"crossedUnrealizedPL"`
	IsolatedUnrealizedPL  string       `json:"isolatedUnrealizedPL"`
	Grant                 string       `json:"grant"`
	AssetMode             string       `json:"assetMode"`
}

type ClassicMixFillRecord

type ClassicMixFillRecord struct {
	OrderID     string                 `json:"orderId"`
	ClientOID   string                 `json:"clientOid"`
	TradeID     string                 `json:"tradeId"`
	Symbol      string                 `json:"symbol"`
	InstID      string                 `json:"instId"`
	Side        string                 `json:"side"`
	OrderType   string                 `json:"orderType"`
	PosMode     string                 `json:"posMode"`
	Price       string                 `json:"price"`
	BaseVolume  string                 `json:"baseVolume"`
	QuoteVolume string                 `json:"quoteVolume"`
	Profit      string                 `json:"profit"`
	TradeSide   string                 `json:"tradeSide"`
	TradeScope  string                 `json:"tradeScope"`
	FeeDetail   []ClassicFillFeeDetail `json:"feeDetail"`
	CTime       string                 `json:"cTime"`
	UTime       string                 `json:"uTime"`
}

type ClassicMixOrderList

type ClassicMixOrderList struct {
	EntrustedList []ClassicMixOrderRecord `json:"entrustedList"`
	EndID         string                  `json:"endId"`
}

type ClassicMixOrderRecord

type ClassicMixOrderRecord struct {
	Symbol                        string      `json:"symbol"`
	InstID                        string      `json:"instId"`
	Size                          string      `json:"size"`
	OrderID                       string      `json:"orderId"`
	ClientOID                     string      `json:"clientOid"`
	BaseVolume                    string      `json:"baseVolume"`
	AccBaseVolume                 string      `json:"accBaseVolume"`
	Fee                           string      `json:"fee"`
	Price                         string      `json:"price"`
	PriceAvg                      string      `json:"priceAvg"`
	Status                        string      `json:"status"`
	Side                          string      `json:"side"`
	Force                         string      `json:"force"`
	TotalProfits                  string      `json:"totalProfits"`
	PosSide                       string      `json:"posSide"`
	MarginCoin                    string      `json:"marginCoin"`
	QuoteVolume                   string      `json:"quoteVolume"`
	Leverage                      string      `json:"leverage"`
	MarginMode                    string      `json:"marginMode"`
	ReduceOnly                    string      `json:"reduceOnly"`
	EnterPointSource              string      `json:"enterPointSource"`
	TradeSide                     string      `json:"tradeSide"`
	PosMode                       string      `json:"posMode"`
	OrderType                     string      `json:"orderType"`
	OrderSource                   string      `json:"orderSource"`
	CTime                         string      `json:"cTime"`
	UTime                         string      `json:"uTime"`
	PresetStopSurplusPrice        string      `json:"presetStopSurplusPrice"`
	PresetStopSurplusType         string      `json:"presetStopSurplusType"`
	PresetStopSurplusExecutePrice string      `json:"presetStopSurplusExecutePrice"`
	PresetStopLossPrice           string      `json:"presetStopLossPrice"`
	PresetStopLossType            string      `json:"presetStopLossType"`
	PresetStopLossExecutePrice    string      `json:"presetStopLossExecutePrice"`
	FeeDetail                     []FeeDetail `json:"feeDetail"`
}

type ClassicMixPositionRecord

type ClassicMixPositionRecord struct {
	PosID            string `json:"posId"`
	Symbol           string `json:"symbol"`
	InstID           string `json:"instId"`
	MarginCoin       string `json:"marginCoin"`
	MarginSize       string `json:"marginSize"`
	MarginMode       string `json:"marginMode"`
	HoldSide         string `json:"holdSide"`
	PosMode          string `json:"posMode"`
	Total            string `json:"total"`
	Available        string `json:"available"`
	Frozen           string `json:"frozen"`
	OpenPriceAvg     string `json:"openPriceAvg"`
	Leverage         string `json:"leverage"`
	AchievedProfits  string `json:"achievedProfits"`
	UnrealizedPL     string `json:"unrealizedPL"`
	LiquidationPrice string `json:"liquidationPrice"`
	KeepMarginRate   string `json:"keepMarginRate"`
	MarkPrice        string `json:"markPrice"`
	MarginRate       string `json:"marginRate"`
	BreakEvenPrice   string `json:"breakEvenPrice"`
	TotalFee         string `json:"totalFee"`
	DeductedFee      string `json:"deductedFee"`
	AssetMode        string `json:"assetMode"`
	AutoMargin       string `json:"autoMargin"`
	CTime            string `json:"cTime"`
	UTime            string `json:"uTime"`
}

type ClassicSpotAsset

type ClassicSpotAsset struct {
	Coin           string `json:"coin"`
	Available      string `json:"available"`
	Frozen         string `json:"frozen"`
	Locked         string `json:"locked"`
	LimitAvailable string `json:"limitAvailable"`
	UTime          string `json:"uTime"`
}

type ClassicSpotFillRecord

type ClassicSpotFillRecord struct {
	OrderID    string                 `json:"orderId"`
	ClientOID  string                 `json:"clientOid"`
	TradeID    string                 `json:"tradeId"`
	Symbol     string                 `json:"symbol"`
	InstID     string                 `json:"instId"`
	OrderType  string                 `json:"orderType"`
	Side       string                 `json:"side"`
	PriceAvg   string                 `json:"priceAvg"`
	Size       string                 `json:"size"`
	Amount     string                 `json:"amount"`
	TradeScope string                 `json:"tradeScope"`
	FeeDetail  []ClassicFillFeeDetail `json:"feeDetail"`
	CTime      string                 `json:"cTime"`
	UTime      string                 `json:"uTime"`
}

type ClassicSpotOrderRecord

type ClassicSpotOrderRecord struct {
	UserID           string             `json:"userId"`
	Symbol           string             `json:"symbol"`
	InstID           string             `json:"instId"`
	OrderID          string             `json:"orderId"`
	ClientOID        string             `json:"clientOid"`
	Price            string             `json:"price"`
	Size             string             `json:"size"`
	NewSize          string             `json:"newSize"`
	OrderType        string             `json:"orderType"`
	Force            string             `json:"force"`
	Side             string             `json:"side"`
	Status           string             `json:"status"`
	FillPrice        string             `json:"fillPrice"`
	FillFee          string             `json:"fillFee"`
	FillFeeCoin      string             `json:"fillFeeCoin"`
	PriceAvg         string             `json:"priceAvg"`
	BasePrice        string             `json:"basePrice"`
	BaseVolume       string             `json:"baseVolume"`
	AccBaseVolume    string             `json:"accBaseVolume"`
	QuoteVolume      string             `json:"quoteVolume"`
	EnterPointSource string             `json:"enterPointSource"`
	FeeDetail        FlexibleFeeDetails `json:"feeDetail"`
	OrderSource      string             `json:"orderSource"`
	CancelReason     string             `json:"cancelReason"`
	CTime            string             `json:"cTime"`
	UTime            string             `json:"uTime"`
}

type ClassicWSFillMessage

type ClassicWSFillMessage struct {
	Arg    WSArg                  `json:"arg"`
	Action string                 `json:"action"`
	Data   []ClassicMixFillRecord `json:"data"`
}

func DecodeClassicWSFillMessage

func DecodeClassicWSFillMessage(payload []byte) (*ClassicWSFillMessage, error)

type ClassicWSOrderMessage

type ClassicWSOrderMessage struct {
	Arg    WSArg                   `json:"arg"`
	Action string                  `json:"action"`
	Data   []ClassicMixOrderRecord `json:"data"`
}

func DecodeClassicWSOrderMessage

func DecodeClassicWSOrderMessage(payload []byte) (*ClassicWSOrderMessage, error)

type ClassicWSPositionMessage

type ClassicWSPositionMessage struct {
	Arg    WSArg                      `json:"arg"`
	Action string                     `json:"action"`
	Data   []ClassicMixPositionRecord `json:"data"`
}

func DecodeClassicWSPositionMessage

func DecodeClassicWSPositionMessage(payload []byte) (*ClassicWSPositionMessage, error)

type ClassicWSSpotFillMessage

type ClassicWSSpotFillMessage struct {
	Arg    WSArg                   `json:"arg"`
	Action string                  `json:"action"`
	Data   []ClassicSpotFillRecord `json:"data"`
}

func DecodeClassicWSSpotFillMessage

func DecodeClassicWSSpotFillMessage(payload []byte) (*ClassicWSSpotFillMessage, error)

type ClassicWSSpotOrderMessage

type ClassicWSSpotOrderMessage struct {
	Arg    WSArg                    `json:"arg"`
	Action string                   `json:"action"`
	Data   []ClassicSpotOrderRecord `json:"data"`
}

func DecodeClassicWSSpotOrderMessage

func DecodeClassicWSSpotOrderMessage(payload []byte) (*ClassicWSSpotOrderMessage, error)

type Client

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

func NewClient

func NewClient() *Client

func (*Client) CancelAllClassicMixOrders

func (c *Client) CancelAllClassicMixOrders(ctx context.Context, productType, symbol, marginCoin string) error

func (*Client) CancelAllClassicSpotOrders

func (c *Client) CancelAllClassicSpotOrders(ctx context.Context, symbol string) error

func (*Client) CancelAllOrders

func (c *Client) CancelAllOrders(ctx context.Context, req *CancelAllOrdersRequest) error

func (*Client) CancelClassicMixOrder

func (c *Client) CancelClassicMixOrder(ctx context.Context, symbol, productType, marginCoin, orderID, clientOID string) (*CancelOrderResponse, error)

func (*Client) CancelClassicSpotOrder

func (c *Client) CancelClassicSpotOrder(ctx context.Context, symbol, orderID, clientOID string) (*CancelOrderResponse, error)

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context, req *CancelOrderRequest) (*CancelOrderResponse, error)

func (*Client) GetAccountAssets

func (c *Client) GetAccountAssets(ctx context.Context) (*AccountAssets, error)

func (*Client) GetAccountFeeRate

func (c *Client) GetAccountFeeRate(ctx context.Context, category, symbol string) (*AccountFeeRate, error)

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context) (*AccountInfo, error)

func (*Client) GetCandles

func (c *Client) GetCandles(ctx context.Context, category, symbol, interval, candleType string, startTime, endTime int64, limit int) ([]Candle, error)

func (*Client) GetClassicMixAccount

func (c *Client) GetClassicMixAccount(ctx context.Context, symbol, productType, marginCoin string) (*ClassicMixAccount, error)

func (*Client) GetClassicMixOpenOrders

func (c *Client) GetClassicMixOpenOrders(ctx context.Context, productType, symbol string) ([]ClassicMixOrderRecord, error)

func (*Client) GetClassicMixOrder

func (c *Client) GetClassicMixOrder(ctx context.Context, symbol, productType, orderID, clientOID string) (*ClassicMixOrderRecord, error)

func (*Client) GetClassicMixOrderHistory

func (c *Client) GetClassicMixOrderHistory(ctx context.Context, productType, symbol string) ([]ClassicMixOrderRecord, error)

func (*Client) GetClassicMixPositions

func (c *Client) GetClassicMixPositions(ctx context.Context, productType, marginCoin string) ([]ClassicMixPositionRecord, error)

func (*Client) GetClassicSpotAssets

func (c *Client) GetClassicSpotAssets(ctx context.Context, coin string) ([]ClassicSpotAsset, error)

func (*Client) GetClassicSpotOpenOrders

func (c *Client) GetClassicSpotOpenOrders(ctx context.Context, symbol string) ([]ClassicSpotOrderRecord, error)

func (*Client) GetClassicSpotOrder

func (c *Client) GetClassicSpotOrder(ctx context.Context, orderID, clientOID string) (*ClassicSpotOrderRecord, error)

func (*Client) GetClassicSpotOrderHistory

func (c *Client) GetClassicSpotOrderHistory(ctx context.Context, symbol string) ([]ClassicSpotOrderRecord, error)

func (*Client) GetCurrentPositions

func (c *Client) GetCurrentPositions(ctx context.Context, category, symbol string) ([]PositionRecord, error)

func (*Client) GetFinancialRecords

func (c *Client) GetFinancialRecords(ctx context.Context, req FinancialRecordsRequest) (*FinancialRecords, error)

func (*Client) GetFundingAssets

func (c *Client) GetFundingAssets(ctx context.Context, coin string) ([]FundingAsset, error)

func (*Client) GetHistoryFundRate

func (c *Client) GetHistoryFundRate(ctx context.Context, symbol, productType string, pageSize, pageNo int) ([]HistoryFundRateEntry, error)

GetHistoryFundRate retrieves historical funding rates. pageSize max 100; pageNo 1-based. Docs: https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate

func (*Client) GetInstruments

func (c *Client) GetInstruments(ctx context.Context, category, symbol string) ([]Instrument, error)

func (*Client) GetMaxTransferable

func (c *Client) GetMaxTransferable(ctx context.Context, coin string) (*MaxTransferable, error)

func (*Client) GetOpenInterest

func (c *Client) GetOpenInterest(ctx context.Context, symbol, productType string) (*OpenInterest, error)

GetOpenInterest retrieves current open interest for a perp symbol. productType: "USDT-FUTURES" | "COIN-FUTURES" | "USDC-FUTURES" Docs: https://www.bitget.com/api-doc/contract/market/Get-Open-Interest

func (*Client) GetOpenInterestLimit

func (c *Client) GetOpenInterestLimit(ctx context.Context, category, symbol string) (*OpenInterestLimit, error)

func (*Client) GetOpenOrders

func (c *Client) GetOpenOrders(ctx context.Context, category, symbol string) ([]OrderRecord, error)

func (*Client) GetOrder

func (c *Client) GetOrder(ctx context.Context, category, symbol, orderID, clientOID string) (*OrderRecord, error)

func (*Client) GetOrderBook

func (c *Client) GetOrderBook(ctx context.Context, category, symbol string, limit int) (*OrderBook, error)

func (*Client) GetOrderHistory

func (c *Client) GetOrderHistory(ctx context.Context, category, symbol string) ([]OrderRecord, error)

func (*Client) GetPrivateRaw

func (c *Client) GetPrivateRaw(ctx context.Context, path string, query map[string]string, out any) error

GetPrivateRaw executes an authenticated GET request for official Bitget endpoints that are SDK-covered by the raw fallback before a typed method is introduced.

func (*Client) GetRecentFills

func (c *Client) GetRecentFills(ctx context.Context, category, symbol string, limit int) ([]PublicFill, error)

func (*Client) GetSwitchStatus

func (c *Client) GetSwitchStatus(ctx context.Context) (*SwitchStatus, error)

func (*Client) GetTicker

func (c *Client) GetTicker(ctx context.Context, category, symbol string) (*Ticker, error)

func (*Client) HasCredentials

func (c *Client) HasCredentials() bool

func (*Client) ModifyClassicMixOrder

func (c *Client) ModifyClassicMixOrder(ctx context.Context, req *ModifyOrderRequest, productType, marginCoin string) (*CancelOrderResponse, error)

func (*Client) ModifyOrder

func (c *Client) ModifyOrder(ctx context.Context, req *ModifyOrderRequest) (*CancelOrderResponse, error)

func (*Client) PlaceClassicMixOrder

func (c *Client) PlaceClassicMixOrder(ctx context.Context, req *PlaceOrderRequest, productType, marginCoin string) (*PlaceOrderResponse, error)

func (*Client) PlaceClassicSpotOrder

func (c *Client) PlaceClassicSpotOrder(ctx context.Context, req *PlaceOrderRequest) (*PlaceOrderResponse, error)

func (*Client) PlaceOrder

func (c *Client) PlaceOrder(ctx context.Context, req *PlaceOrderRequest) (*PlaceOrderResponse, error)

func (*Client) PostPrivateRaw

func (c *Client) PostPrivateRaw(ctx context.Context, path string, body any, out any) error

PostPrivateRaw executes an authenticated POST request for official Bitget endpoints that are SDK-covered by the raw fallback before a typed method is introduced.

func (*Client) SetClassicMixLeverage

func (c *Client) SetClassicMixLeverage(ctx context.Context, symbol, productType, marginCoin, leverage string) error

func (*Client) SetHoldMode

func (c *Client) SetHoldMode(ctx context.Context, holdMode string) error

func (*Client) SetLeverage

func (c *Client) SetLeverage(ctx context.Context, req *SetLeverageRequest) error

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) *Client

func (*Client) WithCredentials

func (c *Client) WithCredentials(apiKey, secretKey, passphrase string) *Client

func (*Client) WithHTTPClient

func (c *Client) WithHTTPClient(httpClient *http.Client) *Client

type FeeDetail

type FeeDetail struct {
	FeeCoin string `json:"feeCoin"`
	Fee     string `json:"fee"`
}

type FillRecord

type FillRecord struct {
	Category    string      `json:"category"`
	OrderID     string      `json:"orderId"`
	ClientOID   string      `json:"clientOid"`
	ExecID      string      `json:"execId"`
	ExecLinkID  string      `json:"execLinkId"`
	Symbol      string      `json:"symbol"`
	OrderType   string      `json:"orderType"`
	Side        string      `json:"side"`
	HoldSide    string      `json:"holdSide"`
	TradeSide   string      `json:"tradeSide"`
	ExecPrice   string      `json:"execPrice"`
	ExecQty     string      `json:"execQty"`
	ExecValue   string      `json:"execValue"`
	ExecPnl     string      `json:"execPnl"`
	TradeScope  string      `json:"tradeScope"`
	FeeDetail   []FeeDetail `json:"feeDetail"`
	ExecTime    string      `json:"execTime"`
	UpdatedTime string      `json:"updatedTime"`
	IsRPI       string      `json:"isRPI"`
}

type FinancialRecord

type FinancialRecord struct {
	Category string `json:"category"`
	ID       string `json:"id"`
	Symbol   string `json:"symbol"`
	Coin     string `json:"coin"`
	Type     string `json:"type"`
	Amount   string `json:"amount"`
	Fee      string `json:"fee"`
	Balance  string `json:"balance"`
	TS       string `json:"ts"`
}

type FinancialRecords

type FinancialRecords struct {
	List   []FinancialRecord `json:"list"`
	Cursor string            `json:"cursor"`
}

type FinancialRecordsRequest

type FinancialRecordsRequest struct {
	Category  string
	Coin      string
	Type      string
	StartTime string
	EndTime   string
	Limit     string
	Cursor    string
}

type FlexibleFeeDetails

type FlexibleFeeDetails []FeeDetail

func (*FlexibleFeeDetails) UnmarshalJSON

func (f *FlexibleFeeDetails) UnmarshalJSON(data []byte) error

type FundingAsset

type FundingAsset struct {
	Coin      string `json:"coin"`
	Available string `json:"available"`
	Frozen    string `json:"frozen"`
	Balance   string `json:"balance"`
}

type HistoryFundRateEntry

type HistoryFundRateEntry struct {
	Symbol      string `json:"symbol"`
	FundingRate string `json:"fundingRate"`
	FundingTime string `json:"fundingTime"`
}

HistoryFundRateEntry matches one element of /api/v2/mix/market/history-fund-rate.

type Instrument

type Instrument struct {
	Symbol             string `json:"symbol"`
	Category           string `json:"category"`
	BaseCoin           string `json:"baseCoin"`
	QuoteCoin          string `json:"quoteCoin"`
	MinOrderQty        string `json:"minOrderQty"`
	MaxOrderQty        string `json:"maxOrderQty"`
	MinOrderAmount     string `json:"minOrderAmount"`
	PricePrecision     string `json:"pricePrecision"`
	QuantityPrecision  string `json:"quantityPrecision"`
	QuotePrecision     string `json:"quotePrecision"`
	PriceMultiplier    string `json:"priceMultiplier"`
	QuantityMultiplier string `json:"quantityMultiplier"`
	MakerFeeRate       string `json:"makerFeeRate"`
	TakerFeeRate       string `json:"takerFeeRate"`
	FundInterval       string `json:"fundInterval"`
	Status             string `json:"status"`
}

type MaxTransferable

type MaxTransferable struct {
	Coin              string `json:"coin"`
	MaxTransfer       string `json:"maxTransfer"`
	BorrowMaxTransfer string `json:"borrowMaxTransfer"`
}

type ModifyOrderRequest

type ModifyOrderRequest struct {
	Category    string `json:"category"`
	Symbol      string `json:"symbol"`
	OrderID     string `json:"orderId,omitempty"`
	ClientOID   string `json:"clientOid,omitempty"`
	NewQty      string `json:"newQty,omitempty"`
	NewPrice    string `json:"newPrice,omitempty"`
	NewClientID string `json:"newClientOid,omitempty"`
}

type NumberString

type NumberString string

func (*NumberString) UnmarshalJSON

func (n *NumberString) UnmarshalJSON(data []byte) error

type OpenInterest

type OpenInterest struct {
	List []OpenInterestEntry `json:"openInterestList"`
	TS   string              `json:"ts"`
}

OpenInterest matches /api/v2/mix/market/open-interest data.

type OpenInterestEntry

type OpenInterestEntry struct {
	Symbol string `json:"symbol"`
	Size   string `json:"size"` // base-asset units
}

type OpenInterestLimit

type OpenInterestLimit struct {
	Symbol           string `json:"symbol"`
	SingleUserLimit  string `json:"singleUserLimit"`
	MasterSubLimit   string `json:"masterSubLimit"`
	MarketMakerLimit string `json:"marketMakerLimit"`
}

type OrderBook

type OrderBook struct {
	Asks [][]NumberString `json:"a"`
	Bids [][]NumberString `json:"b"`
	TS   string           `json:"ts"`
}

type OrderList

type OrderList struct {
	List  []OrderRecord `json:"list"`
	EndID string        `json:"endId"`
}

type OrderRecord

type OrderRecord struct {
	OrderID      string      `json:"orderId"`
	ClientOID    string      `json:"clientOid"`
	Symbol       string      `json:"symbol"`
	Category     string      `json:"category"`
	Side         string      `json:"side"`
	OrderType    string      `json:"orderType"`
	TimeInForce  string      `json:"timeInForce"`
	Price        string      `json:"price"`
	Qty          string      `json:"qty"`
	Amount       string      `json:"amount"`
	BaseVolume   string      `json:"baseVolume"`
	FilledQty    string      `json:"filledQty"`
	FilledVolume string      `json:"filledVolume"`
	CumExecQty   string      `json:"cumExecQty"`
	CumExecValue string      `json:"cumExecValue"`
	OrderStatus  string      `json:"orderStatus"`
	ReduceOnly   string      `json:"reduceOnly"`
	PosSide      string      `json:"posSide"`
	HoldSide     string      `json:"holdSide"`
	HoldMode     string      `json:"holdMode"`
	TradeSide    string      `json:"tradeSide"`
	MarginMode   string      `json:"marginMode"`
	MarginCoin   string      `json:"marginCoin"`
	AvgPrice     string      `json:"avgPrice"`
	Fee          string      `json:"fee"`
	TotalProfit  string      `json:"totalProfit"`
	CreatedTime  string      `json:"cTime"`
	UpdatedTime  string      `json:"uTime"`
	DelegateType string      `json:"delegateType"`
	StpMode      string      `json:"stpMode"`
	FeeDetail    []FeeDetail `json:"feeDetail"`
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	Category    string `json:"category"`
	Symbol      string `json:"symbol"`
	Qty         string `json:"qty"`
	Price       string `json:"price,omitempty"`
	Side        string `json:"side"`
	TradeSide   string `json:"tradeSide,omitempty"`
	OrderType   string `json:"orderType"`
	TimeInForce string `json:"timeInForce,omitempty"`
	MarginMode  string `json:"marginMode,omitempty"`
	MarginCoin  string `json:"marginCoin,omitempty"`
	ClientOID   string `json:"clientOid,omitempty"`
	ReduceOnly  string `json:"reduceOnly,omitempty"`
}

type PlaceOrderResponse

type PlaceOrderResponse struct {
	OrderID   string `json:"orderId"`
	ClientOID string `json:"clientOid"`
}

type PositionList

type PositionList struct {
	List []PositionRecord `json:"list"`
}

type PositionRecord

type PositionRecord struct {
	Symbol           string `json:"symbol"`
	Category         string `json:"category"`
	PosSide          string `json:"posSide"`
	HoldSide         string `json:"holdSide"`
	Qty              string `json:"qty"`
	Total            string `json:"total"`
	Size             string `json:"size"`
	Available        string `json:"available"`
	Frozen           string `json:"frozen"`
	AverageOpenPrice string `json:"averageOpenPrice"`
	OpenPriceAvg     string `json:"openPriceAvg"`
	AvgPrice         string `json:"avgPrice"`
	MarkPrice        string `json:"markPrice"`
	LiquidationPrice string `json:"liquidationPrice"`
	LiqPrice         string `json:"liqPrice"`
	Leverage         string `json:"leverage"`
	MarginMode       string `json:"marginMode"`
	UnrealizedPL     string `json:"unrealizedPL"`
	AchievedProfits  string `json:"achievedProfits"`
	CurRealisedPnl   string `json:"curRealisedPnl"`
	PositionStatus   string `json:"positionStatus"`
	CreatedTime      string `json:"createdTime"`
	UpdatedTime      string `json:"updatedTime"`
}

type PrivateWSClient

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

func NewPrivateWSClient

func NewPrivateWSClient() *PrivateWSClient

func (*PrivateWSClient) CancelClassicPerpOrderWS

func (c *PrivateWSClient) CancelClassicPerpOrderWS(symbol, instType, marginCoin, orderID, clientOID string) (*CancelOrderResponse, error)

func (*PrivateWSClient) CancelClassicSpotOrderWS

func (c *PrivateWSClient) CancelClassicSpotOrderWS(symbol, orderID, clientOID string) (*CancelOrderResponse, error)

func (*PrivateWSClient) CancelUTAOrderWS

func (c *PrivateWSClient) CancelUTAOrderWS(req *CancelOrderRequest) (*CancelOrderResponse, error)

func (*PrivateWSClient) Close

func (c *PrivateWSClient) Close() error

func (*PrivateWSClient) Connect

func (c *PrivateWSClient) Connect(ctx context.Context) error

func (*PrivateWSClient) PlaceClassicPerpOrderWS

func (c *PrivateWSClient) PlaceClassicPerpOrderWS(req *PlaceOrderRequest, instType, marginCoin string) (*PlaceOrderResponse, error)

func (*PrivateWSClient) PlaceClassicSpotOrderWS

func (c *PrivateWSClient) PlaceClassicSpotOrderWS(req *PlaceOrderRequest) (*PlaceOrderResponse, error)

func (*PrivateWSClient) PlaceUTAOrderWS

func (c *PrivateWSClient) PlaceUTAOrderWS(req *PlaceOrderRequest) (*PlaceOrderResponse, error)

func (*PrivateWSClient) Subscribe

func (c *PrivateWSClient) Subscribe(ctx context.Context, arg WSArg, handler func(json.RawMessage)) error

func (*PrivateWSClient) Unsubscribe

func (c *PrivateWSClient) Unsubscribe(ctx context.Context, arg WSArg) error

func (*PrivateWSClient) WithClassicMode

func (c *PrivateWSClient) WithClassicMode() *PrivateWSClient

func (*PrivateWSClient) WithCredentials

func (c *PrivateWSClient) WithCredentials(apiKey, secretKey, passphrase string) *PrivateWSClient

type PublicFill

type PublicFill struct {
	ExecID     string `json:"execId"`
	ExecLinkID string `json:"execLinkId"`
	Price      string `json:"price"`
	Size       string `json:"size"`
	Side       string `json:"side"`
	Timestamp  string `json:"ts"`
}

type PublicWSClient

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

func NewPublicWSClient

func NewPublicWSClient() *PublicWSClient

func (*PublicWSClient) Close

func (c *PublicWSClient) Close() error

func (*PublicWSClient) Connect

func (c *PublicWSClient) Connect(ctx context.Context) error

func (*PublicWSClient) Subscribe

func (c *PublicWSClient) Subscribe(ctx context.Context, arg WSArg, handler func(json.RawMessage)) error

func (*PublicWSClient) Unsubscribe

func (c *PublicWSClient) Unsubscribe(ctx context.Context, arg WSArg) error

type SetLeverageRequest

type SetLeverageRequest struct {
	Symbol   string `json:"symbol"`
	Category string `json:"category"`
	Leverage string `json:"leverage"`
}

type SwitchStatus

type SwitchStatus struct {
	Status string `json:"status"`
	Reason string `json:"reason"`
}

type Ticker

type Ticker struct {
	Category     string `json:"category"`
	Symbol       string `json:"symbol"`
	Timestamp    string `json:"ts"`
	LastPrice    string `json:"lastPrice"`
	OpenPrice24h string `json:"openPrice24h"`
	HighPrice24h string `json:"highPrice24h"`
	LowPrice24h  string `json:"lowPrice24h"`
	Ask1Price    string `json:"ask1Price"`
	Bid1Price    string `json:"bid1Price"`
	Ask1Size     string `json:"ask1Size"`
	Bid1Size     string `json:"bid1Size"`
	Volume24h    string `json:"volume24h"`
	Turnover24h  string `json:"turnover24h"`
	IndexPrice   string `json:"indexPrice"`
	MarkPrice    string `json:"markPrice"`
	FundingRate  string `json:"fundingRate"`
}

type WSArg

type WSArg struct {
	InstType string `json:"instType"`
	Topic    string `json:"topic,omitempty"`
	Symbol   string `json:"symbol,omitempty"`
	Channel  string `json:"channel,omitempty"`
	InstID   string `json:"instId,omitempty"`
}

type WSEnvelope

type WSEnvelope struct {
	Event  string          `json:"event"`
	Code   NumberString    `json:"code"`
	Msg    string          `json:"msg"`
	Arg    WSArg           `json:"arg"`
	Action string          `json:"action"`
	Data   json.RawMessage `json:"data"`
}

type WSFillMessage

type WSFillMessage struct {
	Arg    WSArg        `json:"arg"`
	Action string       `json:"action"`
	Data   []FillRecord `json:"data"`
}

func DecodeFillMessage

func DecodeFillMessage(payload []byte) (*WSFillMessage, error)

type WSOrderBookData

type WSOrderBookData struct {
	Asks     [][]NumberString `json:"a"`
	Bids     [][]NumberString `json:"b"`
	Checksum int64            `json:"checksum"`
	PSeq     int64            `json:"pseq"`
	Seq      int64            `json:"seq"`
	TS       string           `json:"ts"`
}

type WSOrderBookMessage

type WSOrderBookMessage struct {
	Arg    WSArg             `json:"arg"`
	Action string            `json:"action"`
	Data   []WSOrderBookData `json:"data"`
	TS     int64             `json:"ts"`
}

func DecodeOrderBookMessage

func DecodeOrderBookMessage(payload []byte) (*WSOrderBookMessage, error)

type WSOrderMessage

type WSOrderMessage struct {
	Arg    WSArg         `json:"arg"`
	Action string        `json:"action"`
	Data   []OrderRecord `json:"data"`
}

func DecodeOrderMessage

func DecodeOrderMessage(payload []byte) (*WSOrderMessage, error)

type WSPositionMessage

type WSPositionMessage struct {
	Arg    WSArg            `json:"arg"`
	Action string           `json:"action"`
	Data   []PositionRecord `json:"data"`
}

func DecodePositionMessage

func DecodePositionMessage(payload []byte) (*WSPositionMessage, error)

Jump to

Keyboard shortcuts

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