bybit

package
v0.0.0-...-0658b27 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 43 Imported by: 0

README

GoCryptoTrader package Bybit

Build Status Software License GoDoc Coverage Status Go Report Card

This bybit package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Bybit Exchange

Current Features
  • REST Support
  • Websocket Support
How to enable
	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then
How to do REST public/private calls
  • If enabled via "configuration".json file the exchange will be added to the IBotExchange array in the go var bot Bot and you will only be able to use the wrapper interface functions for accessing exchange data. View routines.go for an example of integration usage with GoCryptoTrader. Rudimentary example below:

main.go

var b exchange.IBotExchange

for i := range bot.Exchanges {
	if bot.Exchanges[i].GetName() == "Bybit" {
		b = bot.Exchanges[i]
	}
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := b.FetchTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := b.FetchOrderbook()
if err != nil {
	// Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := b.GetAccountInfo()
if err != nil {
	// Handle error
}
  • If enabled via individually importing package, rudimentary example below:
// Public calls

// Fetches current ticker information
ticker, err := b.GetTicker()
if err != nil {
	// Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderBook()
if err != nil {
	// Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := b.GetUserInfo(...)
if err != nil {
	// Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := b.Trade(...)
if err != nil {
	// Handle error
}
How to do Websocket public/private calls
	// Exchanges will be abstracted out in further updates and examples will be
	// supplied then
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringToOrderStatus

func StringToOrderStatus(status string) order.Status

StringToOrderStatus returns order status from string

Types

type AccountFee

type AccountFee struct {
	Category string `json:"category"`
	List     []Fee  `json:"list"`
}

AccountFee holds account fee information

type AccountInfo

type AccountInfo struct {
	UnifiedMarginStatus int64                `json:"unifiedMarginStatus"`
	MarginMode          string               `json:"marginMode"` // ISOLATED_MARGIN, REGULAR_MARGIN, PORTFOLIO_MARGIN
	DcpStatus           string               `json:"dcpStatus"`  // Disconnected-CancelAll-Prevention status: ON, OFF
	TimeWindow          int64                `json:"timeWindow"`
	SmpGroup            int64                `json:"smpGroup"`
	IsMasterTrader      bool                 `json:"isMasterTrader"`
	SpotHedgingStatus   string               `json:"spotHedgingStatus"`
	UpdatedTime         convert.ExchangeTime `json:"updatedTime"`
}

AccountInfo represents margin mode account information.

type AccountInfos

type AccountInfos map[string]struct {
	Status string `json:"status"`
	Assets []struct {
		Coin     string `json:"coin"`
		Frozen   string `json:"frozen"`
		Free     string `json:"free"`
		Withdraw string `json:"withdraw"`
	} `json:"assets"`
}

AccountInfos represents account type and account information

type AccountLoanInfo

type AccountLoanInfo struct {
	AcctBalanceSum  types.Number `json:"acctBalanceSum"`
	DebtBalanceSum  types.Number `json:"debtBalanceSum"`
	LoanAccountList []struct {
		Interest     string       `json:"interest"`
		Loan         string       `json:"loan"`
		Locked       string       `json:"locked"`
		TokenID      string       `json:"tokenId"`
		Free         types.Number `json:"free"`
		RemainAmount types.Number `json:"remainAmount"`
		Total        types.Number `json:"total"`
	} `json:"loanAccountList"`
	RiskRate     types.Number `json:"riskRate"`
	Status       int64        `json:"status"`
	SwitchStatus int64        `json:"switchStatus"`
}

AccountLoanInfo covers: Margin trade (Normal Account)

type AddOrReduceMargin

type AddOrReduceMargin struct {
	Category                 string               `json:"category"`
	Symbol                   string               `json:"symbol"`
	PositionIndex            int64                `json:"positionIdx"` // position mode index
	RiskID                   int64                `json:"riskId"`
	RiskLimitValue           string               `json:"riskLimitValue"`
	Size                     types.Number         `json:"size"`
	PositionValue            string               `json:"positionValue"`
	AveragePrice             types.Number         `json:"avgPrice"`
	LiquidationPrice         types.Number         `json:"liqPrice"`
	BustPrice                types.Number         `json:"bustPrice"`
	MarkPrice                types.Number         `json:"markPrice"`
	Leverage                 string               `json:"leverage"`
	AutoAddMargin            int64                `json:"autoAddMargin"`
	PositionStatus           string               `json:"positionStatus"`
	PositionIM               types.Number         `json:"positionIM"`
	PositionMM               types.Number         `json:"positionMM"`
	UnrealisedProfitAndLoss  types.Number         `json:"unrealisedPnl"`
	CumRealisedProfitAndLoss types.Number         `json:"cumRealisedPnl"`
	StopLoss                 types.Number         `json:"stopLoss"`
	TakeProfit               types.Number         `json:"takeProfit"`
	TrailingStop             types.Number         `json:"trailingStop"`
	CreatedTime              convert.ExchangeTime `json:"createdTime"`
	UpdatedTime              convert.ExchangeTime `json:"updatedTime"`
}

AddOrReduceMargin represents a add or reduce margin response.

type AddOrReduceMarginParam

type AddOrReduceMarginParam struct {
	Category      string        `json:"category"`
	Symbol        currency.Pair `json:"symbol"`
	Margin        int64         `json:"margin,string"` // Add or reduce. To add, then 10; To reduce, then -10. Support up to 4 decimal
	PositionIndex int64         `json:"positionIdx"`   // Same as PositionIndex value in AutoAddMarginParam
}

AddOrReduceMarginParam holds manually add or reduce margin for isolated margin position parameters.

type AffiliateCustomerInfo

type AffiliateCustomerInfo struct {
	UID                 string       `json:"uid"`
	TakerVol30Day       types.Number `json:"takerVol30Day"`
	MakerVol30Day       types.Number `json:"makerVol30Day"`
	TradeVol30Day       types.Number `json:"tradeVol30Day"`
	DepositAmount30Day  types.Number `json:"depositAmount30Day"`
	TakerVol365Day      types.Number `json:"takerVol365Day"`
	MakerVol365Day      types.Number `json:"makerVol365Day"`
	TradeVol365Day      types.Number `json:"tradeVol365Day"`
	DepositAmount365Day types.Number `json:"depositAmount365Day"`
	TotalWalletBalance  types.Number `json:"totalWalletBalance"`
	DepositUpdateTime   time.Time    `json:"depositUpdateTime"`
	VipLevel            string       `json:"vipLevel"`
	VolUpdateTime       time.Time    `json:"volUpdateTime"`
}

AffiliateCustomerInfo represents user information

type AllowedDepositCoinInfo

type AllowedDepositCoinInfo struct {
	ConfigList []struct {
		Coin               string `json:"coin"`
		Chain              string `json:"chain"`
		CoinShowName       string `json:"coinShowName"`
		ChainType          string `json:"chainType"`
		BlockConfirmNumber int64  `json:"blockConfirmNumber"`
		MinDepositAmount   string `json:"minDepositAmount"`
	} `json:"configList"`
	NextPageCursor string `json:"nextPageCursor"`
}

AllowedDepositCoinInfo represents coin deposit information.

type AmendOrderParams

type AmendOrderParams struct {
	Category               string        `json:"category,omitempty"`
	Symbol                 currency.Pair `json:"symbol,omitempty"`
	OrderID                string        `json:"orderId,omitempty"`
	OrderLinkID            string        `json:"orderLinkId,omitempty"` // User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. future orderLinkId rules:
	OrderImpliedVolatility string        `json:"orderIv,omitempty"`
	TriggerPrice           float64       `json:"triggerPrice,omitempty,string"`
	OrderQuantity          float64       `json:"qty,omitempty,string"` // Order quantity. For Spot Market Buy order, please note that qty should be quote currency amount
	Price                  float64       `json:"price,string,omitempty"`

	TakeProfitPrice float64 `json:"takeProfit,omitempty,string"`
	StopLossPrice   float64 `json:"stopLoss,omitempty,string"`

	TakeProfitTriggerBy string `json:"tpTriggerBy,omitempty"` // The price type to trigger take profit. 'MarkPrice', 'IndexPrice', default: 'LastPrice'
	StopLossTriggerBy   string `json:"slTriggerBy,omitempty"` // The price type to trigger stop loss. MarkPrice, IndexPrice, default: LastPrice
	TriggerPriceType    string `json:"triggerBy,omitempty"`   // Conditional order param. Trigger price type. 'LastPrice', 'IndexPrice', 'MarkPrice'

	TakeProfitLimitPrice float64 `json:"tpLimitPrice,omitempty,string"`
	StopLossLimitPrice   float64 `json:"slLimitPrice,omitempty,string"`

	// TP/SL mode
	// Full: entire position for TP/SL. Then, tpOrderType or slOrderType must be Market
	// Partial: partial position tp/sl. Limit TP/SL order are supported. Note: When create limit tp/sl,
	// 'tpslMode' is required and it must be Partial
	// Valid for 'linear' & 'inverse'
	TPSLMode string `json:"tpslMode,omitempty"`
}

AmendOrderParams represents a parameter for amending order.

type Authenticate

type Authenticate struct {
	RequestID string        `json:"req_id"`
	Args      []interface{} `json:"args"`
	Operation string        `json:"op"`
}

Authenticate stores authentication variables required

type AutoAddMarginParam

type AutoAddMarginParam struct {
	Category      string        `json:"category"`
	Symbol        currency.Pair `json:"symbol"`
	AutoAddmargin int64         `json:"autoAddMargin,string"` // Turn on/off. 0: off. 1: on

	// Positions in different position modes.
	// 0: one-way mode, 1: hedge-mode Buy side, 2: hedge-mode Sell side
	PositionIndex int64 `json:"positionIdx,omitempty,string"`
}

AutoAddMarginParam represents parameters for auto add margin

type BatchAmendOrderParamItem

type BatchAmendOrderParamItem struct {
	Symbol                 currency.Pair `json:"symbol"`
	OrderID                string        `json:"orderId,omitempty"`
	OrderLinkID            string        `json:"orderLinkId,omitempty"` // User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. future orderLinkId rules:
	OrderImpliedVolatility string        `json:"orderIv,omitempty"`
	OrderQuantity          float64       `json:"qty,omitempty,string"` // Order quantity. For Spot Market Buy order, please note that qty should be quote currency amount
	Price                  float64       `json:"price,string,omitempty"`

	// TP/SL mode
	// Full: entire position for TP/SL. Then, tpOrderType or slOrderType must be Market
	// Partial: partial position tp/sl. Limit TP/SL order are supported. Note: When create limit tp/sl,
	// 'tpslMode' is required and it must be Partial
	// Valid for 'linear' & 'inverse'
	TPSLMode string `json:"tpslMode,omitempty"`
}

BatchAmendOrderParamItem represents a single order amend item in batch amend order

type BatchAmendOrderParams

type BatchAmendOrderParams struct {
	Category string                     `json:"category"`
	Request  []BatchAmendOrderParamItem `json:"request"`
}

BatchAmendOrderParams request parameter for batch amend order.

type BatchOrderItemParam

type BatchOrderItemParam struct {
	Category         string        `json:"category,omitempty"`
	Symbol           currency.Pair `json:"symbol,omitempty"`
	OrderType        string        `json:"orderType,omitempty"`
	Side             string        `json:"side,omitempty"`
	OrderQuantity    float64       `json:"qty,string,omitempty"`
	Price            float64       `json:"price,string,omitempty"`
	TriggerDirection int64         `json:"triggerDirection,omitempty"`
	TriggerPrice     int64         `json:"triggerPrice,omitempty"`
	OrderIv          int64         `json:"orderIv,omitempty,string"`
	TriggerBy        string        `json:"triggerBy,omitempty"` // Possible values:  LastPrice, IndexPrice, and MarkPrice
	TimeInForce      string        `json:"timeInForce,omitempty"`

	// PositionIndex Used to identify positions in different position modes. Under hedge-mode,
	// this param is required (USDT perps have hedge mode)
	// 0: one-way mode 1: hedge-mode Buy side 2: hedge-mode Sell side
	PositionIndex         int64  `json:"positionIdx,omitempty"`
	OrderLinkID           string `json:"orderLinkId,omitempty"`
	TakeProfit            string `json:"takeProfit,omitempty"`  // Take profit price, valid for linear
	StopLoss              string `json:"stopLoss,omitempty"`    // Stop loss price, valid for linear
	TakeProfitTriggerBy   string `json:"tpTriggerBy,omitempty"` // MarkPrice, IndexPrice, default: LastPrice. Valid for linear
	StopLossTriggerBy     string `json:"slTriggerBy,omitempty"` // MarkPrice, IndexPrice, default: LastPrice
	SMPType               string `json:"smpType,omitempty"`
	ReduceOnly            bool   `json:"reduceOnly,omitempty"`
	CloseOnTrigger        bool   `json:"closeOnTrigger,omitempty"`
	MarketMakerProtection bool   `json:"mmp,omitempty"`
	TPSLMode              string `json:"tpslMode,omitempty"`
	TakeProfitLimitPrice  string `json:"tpLimitPrice,omitempty"`
	StopLossLimitPrice    string `json:"slLimitPrice,omitempty"`
	TakeProfitOrderType   string `json:"tpOrderType,omitempty"`
	StopLossOrderType     string `json:"slOrderType,omitempty"`
}

BatchOrderItemParam represents a batch order place parameter.

type BatchOrderResponse

type BatchOrderResponse struct {
	Category    string               `json:"category"`
	Symbol      string               `json:"symbol"`
	OrderID     string               `json:"orderId"`
	OrderLinkID string               `json:"orderLinkId"`
	CreateAt    convert.ExchangeTime `json:"createAt"`
}

BatchOrderResponse represents a batch trade order item response.

type BatchOrdersList

type BatchOrdersList struct {
	List []BatchOrderResponse `json:"list"`
}

BatchOrdersList represents a list trade orders.

type BindOrUnbindUIDResponse

type BindOrUnbindUIDResponse struct {
	UID     string `json:"uid"`
	Operate string `json:"operate"`
}

BindOrUnbindUIDResponse holds uid information after binding/unbinding.

type BorrowHistory

type BorrowHistory struct {
	NextPageCursor string `json:"nextPageCursor"`
	List           []struct {
		Currency                  string               `json:"currency"`
		CreatedTime               convert.ExchangeTime `json:"createdTime"`
		BorrowCost                types.Number         `json:"borrowCost"`
		HourlyBorrowRate          types.Number         `json:"hourlyBorrowRate"`
		InterestBearingBorrowSize types.Number         `json:"InterestBearingBorrowSize"`
		CostExemption             string               `json:"costExemption"`
		BorrowAmount              types.Number         `json:"borrowAmount"`
		UnrealisedLoss            types.Number         `json:"unrealisedLoss"`
		FreeBorrowedAmount        types.Number         `json:"freeBorrowedAmount"`
	} `json:"list"`
}

BorrowHistory represents interest records.

type BorrowOrderDetail

type BorrowOrderDetail struct {
	ID              string               `json:"id"`
	AccountID       string               `json:"accountId"`
	Coin            string               `json:"coin"`
	CreatedTime     convert.ExchangeTime `json:"createdTime"`
	InterestAmount  types.Number         `json:"interestAmount"`
	InterestBalance types.Number         `json:"interestBalance"`
	LoanAmount      types.Number         `json:"loanAmount"`
	LoanBalance     types.Number         `json:"loanBalance"`
	RemainAmount    types.Number         `json:"remainAmount"`
	Status          int64                `json:"status"`
	Type            int64                `json:"type"`
}

BorrowOrderDetail represents a borrow order detail info.

type BorrowQuota

type BorrowQuota struct {
	Symbol               string       `json:"symbol"`
	MaxTradeQty          string       `json:"maxTradeQty"`
	Side                 string       `json:"side"`
	MaxTradeAmount       string       `json:"maxTradeAmount"`
	BorrowCoin           string       `json:"borrowCoin"`
	SpotMaxTradeQuantity types.Number `json:"spotMaxTradeQty"`
	SpotMaxTradeAmount   types.Number `json:"spotMaxTradeAmount"`
}

BorrowQuota represents

type BorrowResponse

type BorrowResponse struct {
	TransactID string `json:"transactId"`
}

BorrowResponse represents borrow response transaction id.

type BorrowableCoinInfo

type BorrowableCoinInfo struct {
	Coin               string `json:"coin"`
	BorrowingPrecision int64  `json:"borrowingPrecision"`
	RepaymentPrecision int64  `json:"repaymentPrecision"`
}

BorrowableCoinInfo represents borrowable coin information.

type BrokerEarningItem

type BrokerEarningItem struct {
	UserID   string               `json:"userId"`
	BizType  string               `json:"bizType"`
	Symbol   string               `json:"symbol"`
	Coin     string               `json:"coin"`
	Earning  string               `json:"earning"`
	OrderID  string               `json:"orderId"`
	ExecTime convert.ExchangeTime `json:"execTime"`
}

BrokerEarningItem represents contract-to-contract broker earning item.

type Bybit

type Bybit struct {
	exchange.Base

	// AccountType holds information about whether the account to which the api key belongs is a unified margin account or not.
	// 0: unified, and 1: for normal account
	AccountType uint8
}

Bybit is the overarching type across this package

func (*Bybit) AddOrReduceMargin

func (by *Bybit) AddOrReduceMargin(ctx context.Context, arg *AddOrReduceMarginParam) (*AddOrReduceMargin, error)

AddOrReduceMargin manually add or reduce margin for isolated margin position

func (*Bybit) AmendOrder

func (by *Bybit) AmendOrder(ctx context.Context, arg *AmendOrderParams) (*OrderResponse, error)

AmendOrder amends an open unfilled or partially filled orders.

func (*Bybit) AuthenticateWebsocket

func (by *Bybit) AuthenticateWebsocket(ctx context.Context) error

AuthenticateWebsocket sends an authentication message to the websocket

func (*Bybit) BatchAmendOrder

func (by *Bybit) BatchAmendOrder(ctx context.Context, category string, args []BatchAmendOrderParamItem) (*BatchOrderResponse, error)

BatchAmendOrder represents a batch amend order.

func (*Bybit) BindOrUnbindUID

func (by *Bybit) BindOrUnbindUID(ctx context.Context, uid, operate string) (*BindOrUnbindUIDResponse, error)

BindOrUnbindUID For the INS loan product, you can bind new UID to risk unit or unbind UID out from risk unit. possible 'operate' values: 0: bind, 1: unbind

func (*Bybit) Borrow

func (by *Bybit) Borrow(ctx context.Context, arg *LendArgument) (*BorrowResponse, error)

Borrow borrows a coin.

func (*Bybit) C2CDepositFunds

func (by *Bybit) C2CDepositFunds(ctx context.Context, arg *C2CLendingFundsParams) (*C2CLendingFundResponse, error)

C2CDepositFunds lending funds to Bybit asset pool

func (*Bybit) C2CRedeemFunds

func (by *Bybit) C2CRedeemFunds(ctx context.Context, arg *C2CLendingFundsParams) (*C2CLendingFundResponse, error)

C2CRedeemFunds withdraw funds from the Bybit asset pool.

func (*Bybit) CancelAllOrders

func (by *Bybit) CancelAllOrders(ctx context.Context, orderCancellation *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*Bybit) CancelAllTradeOrders

func (by *Bybit) CancelAllTradeOrders(ctx context.Context, arg *CancelAllOrdersParam) ([]OrderResponse, error)

CancelAllTradeOrders cancel all open orders

func (*Bybit) CancelBatchOrder

func (by *Bybit) CancelBatchOrder(ctx context.Context, arg *CancelBatchOrder) ([]CancelBatchResponseItem, error)

CancelBatchOrder cancel more than one open order in a single request.

func (*Bybit) CancelBatchOrders

func (by *Bybit) CancelBatchOrders(ctx context.Context, o []order.Cancel) (*order.CancelBatchResponse, error)

CancelBatchOrders cancels orders by their corresponding ID numbers

func (*Bybit) CancelOrder

func (by *Bybit) CancelOrder(ctx context.Context, ord *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Bybit) CancelTradeOrder

func (by *Bybit) CancelTradeOrder(ctx context.Context, arg *CancelOrderParams) (*OrderResponse, error)

CancelTradeOrder cancels an open unfilled or partially filled order.

func (*Bybit) CancelWithdrawal

func (by *Bybit) CancelWithdrawal(ctx context.Context, id string) (*StatusResponse, error)

CancelWithdrawal cancel the withdrawal

func (*Bybit) ConfirmNewRiskLimit

func (by *Bybit) ConfirmNewRiskLimit(ctx context.Context, category, symbol string) error

ConfirmNewRiskLimit t is only applicable when the user is marked as only reducing positions (please see the isReduceOnly field in the Get Position Info interface). After the user actively adjusts the risk level, this interface is called to try to calculate the adjusted risk level, and if it passes (retCode=0), the system will remove the position reduceOnly mark. You are recommended to call Get Position Info to check isReduceOnly field.

func (*Bybit) ConstructOrderDetails

func (by *Bybit) ConstructOrderDetails(tradeOrders []TradeOrder, assetType asset.Item, pair currency.Pair, filterPairs currency.Pairs) (order.FilteredOrders, error)

ConstructOrderDetails constructs list of order.Detail instances given list of TradeOrder and other filtering information

func (*Bybit) CreateInternalTransfer

func (by *Bybit) CreateInternalTransfer(ctx context.Context, arg *TransferParams) (string, error)

CreateInternalTransfer create the internal transfer between different account types under the same UID. Each account type has its own acceptable coins, e.g, you cannot transfer USDC from SPOT to CONTRACT. Please refer to transferable coin list API to find out more.

func (*Bybit) CreateNewSubUserID

func (by *Bybit) CreateNewSubUserID(ctx context.Context, arg *CreateSubUserParams) (*SubUserItem, error)

CreateNewSubUserID created a new sub user id. Use master user's api key only.

func (*Bybit) CreateSubUIDAPIKey

func (by *Bybit) CreateSubUIDAPIKey(ctx context.Context, arg *SubUIDAPIKeyParam) (*SubUIDAPIResponse, error)

CreateSubUIDAPIKey create new API key for those newly created sub UID. Use master user's api key only.

func (*Bybit) CreateUniversalTransfer

func (by *Bybit) CreateUniversalTransfer(ctx context.Context, arg *TransferParams) (string, error)

CreateUniversalTransfer transfer between sub-sub or main-sub. Please make sure you have enabled universal transfer on your sub UID in advance. To use sub acct api key, it must have "SubMemberTransferList" permission When use sub acct api key, it can only transfer to main account You can not transfer between the same UID

func (*Bybit) DeleteMasterAPIKey

func (by *Bybit) DeleteMasterAPIKey(ctx context.Context) error

DeleteMasterAPIKey delete the api key of master account. Use the api key pending to be delete to call the endpoint. Use master user's api key only.

func (*Bybit) DeleteSubAccountAPIKey

func (by *Bybit) DeleteSubAccountAPIKey(ctx context.Context, subAccountUID string) error

DeleteSubAccountAPIKey delete the api key of sub account. Use the api key pending to be delete to call the endpoint. Use sub user's api key only.

func (*Bybit) DeleteSubUID

func (by *Bybit) DeleteSubUID(ctx context.Context, subMemberID string) error

DeleteSubUID delete a sub UID. Before deleting the UID, please make sure there is no asset. Use master user's api key**.

func (*Bybit) EnableUniversalTransferForSubUID

func (by *Bybit) EnableUniversalTransferForSubUID(ctx context.Context, subMemberIDs ...string) error

EnableUniversalTransferForSubUID Transfer between sub-sub or main-sub Use this endpoint to enable a subaccount to take part in a universal transfer. It is a one-time switch which, once thrown, enables a subaccount permanently. If not set, your subaccount cannot use universal transfers.

func (*Bybit) FetchAccountInfo

func (by *Bybit) FetchAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*Bybit) FetchOrderbook

func (by *Bybit) FetchOrderbook(ctx context.Context, currency currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*Bybit) FetchTicker

func (by *Bybit) FetchTicker(ctx context.Context, p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*Bybit) FetchTradablePairs

func (by *Bybit) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*Bybit) FreezeSubUID

func (by *Bybit) FreezeSubUID(ctx context.Context, subUID string, frozen bool) error

FreezeSubUID freeze Sub UID. Use master user's api key only.

func (*Bybit) GenerateDefaultSubscriptions

func (by *Bybit) GenerateDefaultSubscriptions() ([]subscription.Subscription, error)

GenerateDefaultSubscriptions generates default subscription

func (*Bybit) GenerateInverseDefaultSubscriptions

func (by *Bybit) GenerateInverseDefaultSubscriptions() ([]subscription.Subscription, error)

GenerateInverseDefaultSubscriptions generates default subscription

func (*Bybit) GenerateLinearDefaultSubscriptions

func (by *Bybit) GenerateLinearDefaultSubscriptions() ([]subscription.Subscription, error)

GenerateLinearDefaultSubscriptions generates default subscription

func (*Bybit) GenerateOptionsDefaultSubscriptions

func (by *Bybit) GenerateOptionsDefaultSubscriptions() ([]subscription.Subscription, error)

GenerateOptionsDefaultSubscriptions generates default subscription

func (*Bybit) GetAPIKeyInformation

func (by *Bybit) GetAPIKeyInformation(ctx context.Context) (*SubUIDAPIResponse, error)

GetAPIKeyInformation retrieves the information of the api key. Use the api key pending to be checked to call the endpoint. Both master and sub user's api key are applicable.

func (*Bybit) GetAccountFundingHistory

func (by *Bybit) GetAccountFundingHistory(_ context.Context) ([]exchange.FundingHistory, error)

GetAccountFundingHistory returns funding history, deposits and withdrawals

func (*Bybit) GetAccountInfo

func (by *Bybit) GetAccountInfo(ctx context.Context) (*AccountInfo, error)

GetAccountInfo retrieves the margin mode configuration of the account. query the margin mode and the upgraded status of account

func (*Bybit) GetActiveOrders

func (by *Bybit) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetActiveOrders retrieves any orders that are active/open

func (*Bybit) GetAffiliateUserInfo

func (by *Bybit) GetAffiliateUserInfo(ctx context.Context, uid string) (*AffiliateCustomerInfo, error)

GetAffiliateUserInfo the API is used for affiliate to get their users information The master account uid of affiliate's client

func (*Bybit) GetAllCoinBalance

func (by *Bybit) GetAllCoinBalance(ctx context.Context, accountType, memberID, coin string, withBonus int64) (*CoinBalances, error)

GetAllCoinBalance retrieves all coin balance of all account types under the master account, and sub account. It is not allowed to get master account coin balance via sub account api key.

func (*Bybit) GetAllowedDepositCoinInfo

func (by *Bybit) GetAllowedDepositCoinInfo(ctx context.Context, coin, chain, cursor string, limit int64) (*AllowedDepositCoinInfo, error)

GetAllowedDepositCoinInfo retrieves allowed deposit coin information. To find out paired chain of coin, please refer coin info api.

func (*Bybit) GetAssetInfo

func (by *Bybit) GetAssetInfo(ctx context.Context, accountType, coin string) (*AccountInfos, error)

GetAssetInfo retrieves asset information

func (*Bybit) GetAvailableTransferChains

func (by *Bybit) GetAvailableTransferChains(ctx context.Context, cryptocurrency currency.Code) ([]string, error)

GetAvailableTransferChains returns the available transfer blockchains for the specific cryptocurrency

func (*Bybit) GetBorrowHistory

func (by *Bybit) GetBorrowHistory(ctx context.Context, currency, cursor string, startTime, endTime time.Time, limit int64) (*BorrowHistory, error)

GetBorrowHistory retrieves interest records, sorted in reverse order of creation time.

func (*Bybit) GetBorrowOrderDetail

func (by *Bybit) GetBorrowOrderDetail(ctx context.Context, startTime, endTime time.Time, coin currency.Code, status, limit int64) ([]BorrowOrderDetail, error)

GetBorrowOrderDetail represents the borrow order detail. Status '0'(default):get all kinds of status '1':uncleared '2':cleared

func (*Bybit) GetBorrowQuota

func (by *Bybit) GetBorrowQuota(ctx context.Context, category, symbol, side string) (*BorrowQuota, error)

GetBorrowQuota retrieves the qty and amount of borrowable coins in spot account.

func (*Bybit) GetBorrowableCoinInfo

func (by *Bybit) GetBorrowableCoinInfo(ctx context.Context, coin currency.Code) ([]BorrowableCoinInfo, error)

GetBorrowableCoinInfo retrieves borrowable coin info list.

func (*Bybit) GetBrokerEarning

func (by *Bybit) GetBrokerEarning(ctx context.Context, businessType, cursor string, startTime, endTime time.Time, limit int64) ([]BrokerEarningItem, error)

GetBrokerEarning exchange broker master account to query The data can support up to past 6 months until T-1 startTime & endTime are either entered at the same time or not entered Business type. 'SPOT', 'DERIVATIVES', 'OPTIONS'

func (*Bybit) GetBybitServerTime

func (by *Bybit) GetBybitServerTime(ctx context.Context) (*ServerTime, error)

GetBybitServerTime retrieves bybit server time

func (*Bybit) GetC2CLendingAccountInfo

func (by *Bybit) GetC2CLendingAccountInfo(ctx context.Context, coin currency.Code) (*LendingAccountInfo, error)

GetC2CLendingAccountInfo retrieves C2C lending account information.

func (*Bybit) GetC2CLendingCoinInfo

func (by *Bybit) GetC2CLendingCoinInfo(ctx context.Context, coin currency.Code) ([]C2CLendingCoinInfo, error)

GetC2CLendingCoinInfo retrieves C2C basic information of lending coins

func (*Bybit) GetC2CLendingOrderRecords

func (by *Bybit) GetC2CLendingOrderRecords(ctx context.Context, coin currency.Code, orderID, orderType string, startTime, endTime time.Time, limit int64) ([]C2CLendingFundResponse, error)

GetC2CLendingOrderRecords retrieves lending or redeem history

func (*Bybit) GetClosedPnL

func (by *Bybit) GetClosedPnL(ctx context.Context, category, symbol, cursor string, startTime, endTime time.Time, limit int64) (*ClosedProfitAndLossResponse, error)

GetClosedPnL retrieves user's closed profit and loss records. The results are sorted by createdTime in descending order.

func (*Bybit) GetCoinExchangeRecords

func (by *Bybit) GetCoinExchangeRecords(ctx context.Context, fromCoin, toCoin, cursor string, limit int64) (*CoinExchangeRecords, error)

GetCoinExchangeRecords queries the coin exchange records.

func (*Bybit) GetCoinGreeks

func (by *Bybit) GetCoinGreeks(ctx context.Context, baseCoin string) (*CoinGreeks, error)

GetCoinGreeks retrieves current account Greeks information

func (*Bybit) GetCoinInfo

func (by *Bybit) GetCoinInfo(ctx context.Context, coin currency.Code) (*CoinInfo, error)

GetCoinInfo retrieves coin information, including chain information, withdraw and deposit status.

func (*Bybit) GetCollateralInfo

func (by *Bybit) GetCollateralInfo(ctx context.Context, currency string) (*CollateralInfo, error)

GetCollateralInfo retrieves the collateral information of the current unified margin account, including loan interest rate, loanable amount, collateral conversion rate, whether it can be mortgaged as margin, etc.

func (*Bybit) GetDeliveryPrice

func (by *Bybit) GetDeliveryPrice(ctx context.Context, category, symbol, baseCoin, cursor string, limit int64) (*DeliveryPrice, error)

GetDeliveryPrice retrieves delivery price.

func (*Bybit) GetDeliveryRecord

func (by *Bybit) GetDeliveryRecord(ctx context.Context, category, symbol, cursor string, expiryDate time.Time, limit int64) (*DeliveryRecord, error)

GetDeliveryRecord retrieves delivery records of USDC futures and Options, sorted by deliveryTime in descending order

func (*Bybit) GetDepositAddress

func (by *Bybit) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _, chain string) (*deposit.Address, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Bybit) GetDepositRecords

func (by *Bybit) GetDepositRecords(ctx context.Context, coin, cursor string, startTime, endTime time.Time, limit int64) (*DepositRecords, error)

GetDepositRecords query deposit records.

func (*Bybit) GetExecution

func (by *Bybit) GetExecution(ctx context.Context, category, symbol, orderID, orderLinkID, baseCoin, executionType, stopOrderType, cursor string, startTime, endTime time.Time, limit int64) (*ExecutionResponse, error)

GetExecution retrieves users' execution records, sorted by execTime in descending order. However, for Normal spot, they are sorted by execId in descending order. Execution Type possible values: 'Trade', 'AdlTrade' Auto-Deleveraging, 'Funding' Funding fee, 'BustTrade' Liquidation, 'Delivery' USDC futures delivery, 'BlockTrade' UTA Spot: 'stopOrderType', "" for normal order, "tpslOrder" for TP/SL order, "Stop" for conditional order, "OcoOrder" for OCO order

func (*Bybit) GetFeeByType

func (by *Bybit) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on the type of transaction

func (*Bybit) GetFeeRate

func (by *Bybit) GetFeeRate(ctx context.Context, category, symbol, baseCoin string) (*AccountFee, error)

GetFeeRate retrieves the trading fee rate.

func (*Bybit) GetFundingRateHistory

func (by *Bybit) GetFundingRateHistory(ctx context.Context, category, symbol string, startTime, endTime time.Time, limit int64) (*FundingRateHistory, error)

GetFundingRateHistory retrieves historical funding rates. Each symbol has a different funding interval. For example, if the interval is 8 hours and the current time is UTC 12, then it returns the last funding rate, which settled at UTC 8.

func (*Bybit) GetFuturesContractDetails

func (by *Bybit) GetFuturesContractDetails(ctx context.Context, item asset.Item) ([]futures.Contract, error)

GetFuturesContractDetails returns details about futures contracts

func (*Bybit) GetHistoricCandles

func (by *Bybit) GetHistoricCandles(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)

GetHistoricCandles returns candles between a time period for a set time interval

func (*Bybit) GetHistoricCandlesExtended

func (by *Bybit) GetHistoricCandlesExtended(ctx context.Context, pair currency.Pair, a asset.Item, interval kline.Interval, start, end time.Time) (*kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

func (*Bybit) GetHistoricTrades

func (by *Bybit) GetHistoricTrades(ctx context.Context, p currency.Pair, assetType asset.Item, _, _ time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*Bybit) GetHistoricalVolatility

func (by *Bybit) GetHistoricalVolatility(ctx context.Context, category, baseCoin string, period int64, startTime, endTime time.Time) ([]HistoricVolatility, error)

GetHistoricalVolatility retrieves option historical volatility. The data is hourly. If both 'startTime' and 'endTime' are not specified, it will return the most recent 1 hours worth of data. 'startTime' and 'endTime' are a pair of params. Either both are passed or they are not passed at all. This endpoint can query the last 2 years worth of data, but make sure [endTime - startTime] <= 30 days.

func (*Bybit) GetIndexPriceKline

func (by *Bybit) GetIndexPriceKline(ctx context.Context, category, symbol string, interval kline.Interval, startTime, endTime time.Time, limit int64) ([]KlineItem, error)

GetIndexPriceKline query for historical index price klines. Charts are returned in groups based on the requested interval.

func (*Bybit) GetInstitutionalLengingMarginCoinInfo

func (by *Bybit) GetInstitutionalLengingMarginCoinInfo(ctx context.Context, productID string) (*InstitutionalMarginCoinInfo, error)

GetInstitutionalLengingMarginCoinInfo retrieves institutional lending margin coin information. ProductId. If not passed, then return all product margin coin. For spot, it returns coin that convertRation greater than 0.

func (*Bybit) GetInstitutionalLoanOrders

func (by *Bybit) GetInstitutionalLoanOrders(ctx context.Context, orderID string, startTime, endTime time.Time, limit int64) ([]LoanOrderDetails, error)

GetInstitutionalLoanOrders retrieves institutional loan orders.

func (*Bybit) GetInstitutionalRepayOrders

func (by *Bybit) GetInstitutionalRepayOrders(ctx context.Context, startTime, endTime time.Time, limit int64) ([]OrderRepayInfo, error)

GetInstitutionalRepayOrders retrieves list of repaid order information.

func (*Bybit) GetInstrumentInfo

func (by *Bybit) GetInstrumentInfo(ctx context.Context, category, symbol, status, baseCoin, cursor string, limit int64) (*InstrumentsInfo, error)

GetInstrumentInfo retrieves the list of instrument details given the category and symbol.

func (*Bybit) GetInsurance

func (by *Bybit) GetInsurance(ctx context.Context, coin string) (*InsuranceHistory, error)

GetInsurance retrieves insurance pool data (BTC/USDT/USDC etc). The data is updated every 24 hours.

func (*Bybit) GetInterestAndQuota

func (by *Bybit) GetInterestAndQuota(ctx context.Context, coin currency.Code) (*InterestAndQuota, error)

GetInterestAndQuota retrieves interest and quota information.

func (*Bybit) GetInternalDepositRecordsOffChain

func (by *Bybit) GetInternalDepositRecordsOffChain(ctx context.Context, coin, cursor string, startTime, endTime time.Time, limit int64) (*InternalDepositRecords, error)

GetInternalDepositRecordsOffChain retrieves deposit records within the Bybit platform. These transactions are not on the blockchain.

func (*Bybit) GetInternalTransferRecords

func (by *Bybit) GetInternalTransferRecords(ctx context.Context, transferID, coin, status, cursor string, startTime, endTime time.Time, limit int64) (*TransferResponse, error)

GetInternalTransferRecords retrieves the internal transfer records between different account types under the same UID.

func (*Bybit) GetKlines

func (by *Bybit) GetKlines(ctx context.Context, category, symbol string, interval kline.Interval, startTime, endTime time.Time, limit int64) ([]KlineItem, error)

GetKlines query for historical klines (also known as candles/candlesticks). Charts are returned in groups based on the requested interval.

func (*Bybit) GetLTV

func (by *Bybit) GetLTV(ctx context.Context) (*LTVInfo, error)

GetLTV retrieves a loan-to-value(LTV)

func (*Bybit) GetLatestFundingRates

func (by *Bybit) GetLatestFundingRates(ctx context.Context, r *fundingrate.LatestRateRequest) ([]fundingrate.LatestRateResponse, error)

GetLatestFundingRates returns the latest funding rates data

func (*Bybit) GetLeverageTokenInfo

func (by *Bybit) GetLeverageTokenInfo(ctx context.Context, ltCoin currency.Code) ([]LeverageTokenInfo, error)

GetLeverageTokenInfo query leverage token information Abbreviation of the LT, such as BTC3L

func (*Bybit) GetLeveragedTokenMarket

func (by *Bybit) GetLeveragedTokenMarket(ctx context.Context, ltCoin currency.Code) (*LeveragedTokenMarket, error)

GetLeveragedTokenMarket retrieves leverage token market information

func (*Bybit) GetLoanAccountInfo

func (by *Bybit) GetLoanAccountInfo(ctx context.Context) (*AccountLoanInfo, error)

GetLoanAccountInfo retrieves loan account information.

func (*Bybit) GetLongShortRatio

func (by *Bybit) GetLongShortRatio(ctx context.Context, category, symbol string, interval kline.Interval, limit int64) ([]InstrumentInfoItem, error)

GetLongShortRatio retrieves long short ratio of an instrument.

func (*Bybit) GetMMPState

func (by *Bybit) GetMMPState(ctx context.Context, baseCoin string) (*MMPStates, error)

GetMMPState retrieve Market Maker Protection (MMP) states for different coins.

func (*Bybit) GetMarginCoinInfo

func (by *Bybit) GetMarginCoinInfo(ctx context.Context, coin currency.Code) ([]MarginCoinInfo, error)

GetMarginCoinInfo retrieves margin coin information.

func (*Bybit) GetMarkPriceKline

func (by *Bybit) GetMarkPriceKline(ctx context.Context, category, symbol string, interval kline.Interval, startTime, endTime time.Time, limit int64) ([]KlineItem, error)

GetMarkPriceKline query for historical mark price klines. Charts are returned in groups based on the requested interval.

func (*Bybit) GetMasterDepositAddress

func (by *Bybit) GetMasterDepositAddress(ctx context.Context, coin currency.Code, chainType string) (*DepositAddresses, error)

GetMasterDepositAddress retrieves the deposit address information of MASTER account.

func (*Bybit) GetOpenInterest

func (by *Bybit) GetOpenInterest(ctx context.Context, k ...key.PairAsset) ([]futures.OpenInterest, error)

GetOpenInterest returns the open interest rate for a given asset pair

func (*Bybit) GetOpenInterestData

func (by *Bybit) GetOpenInterestData(ctx context.Context, category, symbol, intervalTime string, startTime, endTime time.Time, limit int64, cursor string) (*OpenInterest, error)

GetOpenInterestData retrieves open interest of each symbol.

func (*Bybit) GetOpenOrders

func (by *Bybit) GetOpenOrders(ctx context.Context, category, symbol, baseCoin, settleCoin, orderID, orderLinkID, orderFilter, cursor string,
	openOnly, limit int64) (*TradeOrders, error)

GetOpenOrders retrieves unfilled or partially filled orders in real-time. To query older order records, please use the order history interface. orderFilter: possible values are 'Order', 'StopOrder', 'tpslOrder', and 'OcoOrder'

func (*Bybit) GetOrderBook

func (by *Bybit) GetOrderBook(ctx context.Context, category, symbol string, limit int64) (*Orderbook, error)

GetOrderBook retrieves for orderbook depth data.

func (*Bybit) GetOrderHistory

func (by *Bybit) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*Bybit) GetOrderInfo

func (by *Bybit) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (*order.Detail, error)

GetOrderInfo returns order information based on order ID

func (*Bybit) GetPositionInfo

func (by *Bybit) GetPositionInfo(ctx context.Context, category, symbol, baseCoin, settleCoin, cursor string, limit int64) (*PositionInfoList, error)

GetPositionInfo retrieves real-time position data, such as position size, cumulative realizedPNL.

func (*Bybit) GetPreUpgradeClosedPnL

func (by *Bybit) GetPreUpgradeClosedPnL(ctx context.Context, category, symbol, cursor string, startTime, endTime time.Time, limit int64) (*ClosedProfitAndLossResponse, error)

GetPreUpgradeClosedPnL retrieves user's closed profit and loss records from before you upgraded the account to a Unified account. The results are sorted by createdTime in descending order.

func (*Bybit) GetPreUpgradeOptionDeliveryRecord

func (by *Bybit) GetPreUpgradeOptionDeliveryRecord(ctx context.Context, category, symbol, cursor string, expiryDate time.Time, limit int64) (*PreUpdateOptionDeliveryRecord, error)

GetPreUpgradeOptionDeliveryRecord retrieves delivery records of Option before you upgraded the account to a Unified account, sorted by deliveryTime in descending order

func (*Bybit) GetPreUpgradeOrderHistory

func (by *Bybit) GetPreUpgradeOrderHistory(ctx context.Context, category, symbol, baseCoin, orderID, orderLinkID, orderFilter, orderStatus, cursor string, startTime, endTime time.Time, limit int64) (*TradeOrders, error)

GetPreUpgradeOrderHistory the account is upgraded to a Unified account, you can get the orders which occurred before the upgrade.

func (*Bybit) GetPreUpgradeTradeHistory

func (by *Bybit) GetPreUpgradeTradeHistory(ctx context.Context, category, symbol, orderID, orderLinkID, baseCoin, executionType, cursor string, startTime, endTime time.Time, limit int64) (*ExecutionResponse, error)

GetPreUpgradeTradeHistory retrieves users' execution records which occurred before you upgraded the account to a Unified account, sorted by execTime in descending order

func (*Bybit) GetPreUpgradeTransactionLog

func (by *Bybit) GetPreUpgradeTransactionLog(ctx context.Context, category, baseCoin, transactionType, cursor string, startTime, endTime time.Time, limit int64) (*TransactionLog, error)

GetPreUpgradeTransactionLog retrieves transaction logs which occurred in the USDC Derivatives wallet before the account was upgraded to a Unified account.

func (*Bybit) GetPreUpgradeUSDCSessionSettlement

func (by *Bybit) GetPreUpgradeUSDCSessionSettlement(ctx context.Context, category, symbol, cursor string, limit int64) (*SettlementSession, error)

GetPreUpgradeUSDCSessionSettlement retrieves session settlement records of USDC perpetual before you upgrade the account to Unified account.

func (*Bybit) GetProductInfo

func (by *Bybit) GetProductInfo(ctx context.Context, productID string) (*InstitutionalProductInfo, error)

GetProductInfo represents a product info.

func (*Bybit) GetPublicTradingHistory

func (by *Bybit) GetPublicTradingHistory(ctx context.Context, category, symbol, baseCoin, optionType string, limit int64) (*TradingHistory, error)

GetPublicTradingHistory retrieves recent public trading data. Option type. 'Call' or 'Put'. For option only

func (*Bybit) GetPurchaseAndRedemptionRecords

func (by *Bybit) GetPurchaseAndRedemptionRecords(ctx context.Context, ltCoin currency.Code, orderID, serialNo string, startTime, endTime time.Time, ltOrderType, limit int64) ([]RedeemPurchaseRecord, error)

GetPurchaseAndRedemptionRecords retrieves purchase or redeem history. ltOrderType false integer LT order type. 1: purchase, 2: redemption

func (*Bybit) GetRecentTrades

func (by *Bybit) GetRecentTrades(ctx context.Context, p currency.Pair, assetType asset.Item) ([]trade.Data, error)

GetRecentTrades returns the most recent trades for a currency and asset

func (*Bybit) GetRepaymentOrderDetail

func (by *Bybit) GetRepaymentOrderDetail(ctx context.Context, startTime, endTime time.Time, coin currency.Code, limit int64) ([]CoinRepaymentResponse, error)

GetRepaymentOrderDetail retrieves repayment order detail.

func (*Bybit) GetRiskLimit

func (by *Bybit) GetRiskLimit(ctx context.Context, category, symbol string) (*RiskLimitHistory, error)

GetRiskLimit retrieves risk limit history

func (*Bybit) GetServerTime

func (by *Bybit) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error)

GetServerTime returns the current exchange server time.

func (*Bybit) GetSingleCoinBalance

func (by *Bybit) GetSingleCoinBalance(ctx context.Context, accountType, coin, memberID string, withBonus, withTransferSafeAmount int64) (*CoinBalance, error)

GetSingleCoinBalance retrieves the balance of a specific coin in a specific account type. Supports querying sub UID's balance.

func (*Bybit) GetSubAccountAllAPIKeys

func (by *Bybit) GetSubAccountAllAPIKeys(ctx context.Context, subMemberID, cursor string, limit int64) (*SubAccountAPIKeys, error)

GetSubAccountAllAPIKeys retrieves all api keys information of a sub UID.

func (*Bybit) GetSubDepositAddress

func (by *Bybit) GetSubDepositAddress(ctx context.Context, coin currency.Code, chainType, subMemberID string) (*DepositAddresses, error)

GetSubDepositAddress retrieves the deposit address information of SUB account.

func (*Bybit) GetSubDepositRecords

func (by *Bybit) GetSubDepositRecords(ctx context.Context, subMemberID, coin, cursor string, startTime, endTime time.Time, limit int64) (*DepositRecords, error)

GetSubDepositRecords query subaccount's deposit records by main UID's API key. on chain

func (*Bybit) GetSubUID

func (by *Bybit) GetSubUID(ctx context.Context) (*SubUID, error)

GetSubUID retrieves the sub UIDs under a main UID

func (*Bybit) GetSubUIDList

func (by *Bybit) GetSubUIDList(ctx context.Context) ([]SubUserItem, error)

GetSubUIDList get all sub uid of master account. Use master user's api key only.

func (*Bybit) GetTickers

func (by *Bybit) GetTickers(ctx context.Context, category, symbol, baseCoin string, expiryDate time.Time) (*TickerData, error)

GetTickers returns the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.

func (*Bybit) GetTradeOrderHistory

func (by *Bybit) GetTradeOrderHistory(ctx context.Context, category, symbol, orderID, orderLinkID,
	baseCoin, settleCoin, orderFilter, orderStatus, cursor string,
	startTime, endTime time.Time, limit int64) (*TradeOrders, error)

GetTradeOrderHistory retrieves order history. As order creation/cancellation is asynchronous, the data returned from this endpoint may delay. If you want to get real-time order information, you could query this endpoint or rely on the websocket stream (recommended). orderFilter: possible values are 'Order', 'StopOrder', 'tpslOrder', and 'OcoOrder'

func (*Bybit) GetTransactionLog

func (by *Bybit) GetTransactionLog(ctx context.Context, category, baseCoin, transactionType, cursor string, startTime, endTime time.Time, limit int64) (*TransactionLog, error)

GetTransactionLog retrieves transaction logs in Unified account.

func (*Bybit) GetTransferableCoin

func (by *Bybit) GetTransferableCoin(ctx context.Context, fromAccountType, toAccountType string) (*TransferableCoins, error)

GetTransferableCoin the transferable coin list between each account type

func (*Bybit) GetUIDWalletType

func (by *Bybit) GetUIDWalletType(ctx context.Context, memberIDs string) (*WalletType, error)

GetUIDWalletType retrieves available wallet types for the master account or sub account

func (*Bybit) GetUSDCSessionSettlement

func (by *Bybit) GetUSDCSessionSettlement(ctx context.Context, category, symbol, cursor string, limit int64) (*SettlementSession, error)

GetUSDCSessionSettlement retrieves session settlement records of USDC perpetual and futures

func (*Bybit) GetUniversalTransferRecords

func (by *Bybit) GetUniversalTransferRecords(ctx context.Context, transferID, coin, status, cursor string, startTime, endTime time.Time, limit int64) (*TransferResponse, error)

GetUniversalTransferRecords query universal transfer records Main acct api key or Sub acct api key are both supported Main acct api key needs "SubMemberTransfer" permission Sub acct api key needs "SubMemberTransferList" permission

func (*Bybit) GetVIPMarginData

func (by *Bybit) GetVIPMarginData(ctx context.Context, vipLevel, currency string) (*VIPMarginData, error)

GetVIPMarginData retrieves public VIP Margin data

func (*Bybit) GetWalletBalance

func (by *Bybit) GetWalletBalance(ctx context.Context, accountType, coin string) (*WalletBalance, error)

GetWalletBalance represents wallet balance, query asset information of each currency, and account risk rate information. By default, currency information with assets or liabilities of 0 is not returned. Unified account: UNIFIED (trade spot/linear/options), CONTRACT(trade inverse) Normal account: CONTRACT, SPOT

func (*Bybit) GetWithdrawableAmount

func (by *Bybit) GetWithdrawableAmount(ctx context.Context, coin currency.Code) (*WithdrawableAmount, error)

GetWithdrawableAmount retrieves withdrawable amount information using currency code

func (*Bybit) GetWithdrawalRecords

func (by *Bybit) GetWithdrawalRecords(ctx context.Context, coin currency.Code, withdrawalID, withdrawType, cursor string, startTime, endTime time.Time, limit int64) (*WithdrawalRecords, error)

GetWithdrawalRecords query withdrawal records. endTime - startTime should be less than 30 days. Query last 30 days records by default. Can query by the master UID's api key only

func (*Bybit) GetWithdrawalsHistory

func (by *Bybit) GetWithdrawalsHistory(ctx context.Context, c currency.Code, a asset.Item) ([]exchange.WithdrawalHistory, error)

GetWithdrawalsHistory returns previous withdrawals data

func (*Bybit) InverseSubscribe

func (by *Bybit) InverseSubscribe(channelSubscriptions []subscription.Subscription) error

InverseSubscribe sends a subscription message to linear public channels.

func (*Bybit) InverseUnsubscribe

func (by *Bybit) InverseUnsubscribe(channelSubscriptions []subscription.Subscription) error

InverseUnsubscribe sends an unsubscription messages through linear public channels.

func (*Bybit) IsPerpetualFutureCurrency

func (by *Bybit) IsPerpetualFutureCurrency(a asset.Item, p currency.Pair) (bool, error)

IsPerpetualFutureCurrency ensures a given asset and currency is a perpetual future

func (*Bybit) LinearSubscribe

func (by *Bybit) LinearSubscribe(channelSubscriptions []subscription.Subscription) error

LinearSubscribe sends a subscription message to linear public channels.

func (*Bybit) LinearUnsubscribe

func (by *Bybit) LinearUnsubscribe(channelSubscriptions []subscription.Subscription) error

LinearUnsubscribe sends an unsubscription messages through linear public channels.

func (*Bybit) ModifyMasterAPIKey

func (by *Bybit) ModifyMasterAPIKey(ctx context.Context, arg *SubUIDAPIKeyUpdateParam) (*SubUIDAPIResponse, error)

ModifyMasterAPIKey modify the settings of master api key. Use the api key pending to be modified to call the endpoint. Use master user's api key only.

func (*Bybit) ModifyOrder

func (by *Bybit) ModifyOrder(ctx context.Context, action *order.Modify) (*order.ModifyResponse, error)

ModifyOrder will allow of changing orderbook placement and limit to market conversion

func (*Bybit) ModifySubAPIKey

func (by *Bybit) ModifySubAPIKey(ctx context.Context, arg *SubUIDAPIKeyUpdateParam) (*SubUIDAPIResponse, error)

ModifySubAPIKey modifies the settings of sub api key. Use the api key pending to be modified to call the endpoint. Use sub user's api key only.

func (*Bybit) OptionSubscribe

func (by *Bybit) OptionSubscribe(channelSubscriptions []subscription.Subscription) error

OptionSubscribe sends a subscription message to options public channels.

func (*Bybit) OptionUnsubscribe

func (by *Bybit) OptionUnsubscribe(channelSubscriptions []subscription.Subscription) error

OptionUnsubscribe sends an unsubscription messages through options public channels.

func (*Bybit) PlaceBatchOrder

func (by *Bybit) PlaceBatchOrder(ctx context.Context, arg *PlaceBatchOrderParam) ([]BatchOrderResponse, error)

PlaceBatchOrder place batch or trade order.

func (*Bybit) PlaceOrder

func (by *Bybit) PlaceOrder(ctx context.Context, arg *PlaceOrderParams) (*OrderResponse, error)

PlaceOrder creates an order for spot, spot margin, USDT perpetual, USDC perpetual, USDC futures, inverse futures and options.

func (*Bybit) PurchaseLeverageToken

func (by *Bybit) PurchaseLeverageToken(ctx context.Context, ltCoin currency.Code, amount float64, serialNumber string) (*LeverageToken, error)

PurchaseLeverageToken purcases a leverage token.

func (*Bybit) RedeemLeverageToken

func (by *Bybit) RedeemLeverageToken(ctx context.Context, ltCoin currency.Code, quantity float64, serialNumber string) (*RedeemToken, error)

RedeemLeverageToken redeem leverage token

func (*Bybit) Repay

func (by *Bybit) Repay(ctx context.Context, arg *LendArgument) (*RepayResponse, error)

Repay repay a debt.

func (*Bybit) ResetMMP

func (by *Bybit) ResetMMP(ctx context.Context, baseCoin string) error

ResetMMP resets MMP. once the mmp triggered, you can unfreeze the account by this endpoint

func (*Bybit) RetrieveAndSetAccountType

func (by *Bybit) RetrieveAndSetAccountType(ctx context.Context) error

RetrieveAndSetAccountType retrieve to set account type information

func (*Bybit) SendAuthHTTPRequestV5

func (by *Bybit) SendAuthHTTPRequestV5(ctx context.Context, ePath exchange.URL, method, path string, params url.Values, arg, result interface{}, f request.EndpointLimit) error

SendAuthHTTPRequestV5 sends an authenticated HTTP request

func (*Bybit) SendHTTPRequest

func (by *Bybit) SendHTTPRequest(ctx context.Context, ePath exchange.URL, path string, f request.EndpointLimit, result interface{}) error

SendHTTPRequest sends an unauthenticated request

func (*Bybit) SetAutoAddMargin

func (by *Bybit) SetAutoAddMargin(ctx context.Context, arg *AutoAddMarginParam) error

SetAutoAddMargin sets auto add margin

func (*Bybit) SetCollateralCoin

func (by *Bybit) SetCollateralCoin(ctx context.Context, coin currency.Code, collateralSwitchON bool) error

SetCollateralCoin decide whether the assets in the Unified account needs to be collateral coins.

func (*Bybit) SetDefaults

func (by *Bybit) SetDefaults()

SetDefaults sets the basic defaults for Bybit

func (*Bybit) SetDepositAccount

func (by *Bybit) SetDepositAccount(ctx context.Context, accountType string) (*StatusResponse, error)

SetDepositAccount sets auto transfer account after deposit. The same function as the setting for Deposit on web GUI account types: CONTRACT Derivatives Account 'SPOT' Spot Account 'INVESTMENT' ByFi Account (The service has been offline) 'OPTION' USDC Account 'UNIFIED' UMA or UTA 'FUND' Funding Account

func (*Bybit) SetDisconnectCancelAll

func (by *Bybit) SetDisconnectCancelAll(ctx context.Context, arg *SetDCPParams) error

SetDisconnectCancelAll You can use this endpoint to get your current DCP configuration. Your private websocket connection must subscribe "dcp" topic in order to trigger DCP successfully

func (*Bybit) SetLeverage

func (by *Bybit) SetLeverage(ctx context.Context, item asset.Item, pair currency.Pair, _ margin.Type, amount float64, orderSide order.Side) error

SetLeverage sets the account's initial leverage for the asset type and pair

func (*Bybit) SetLeverageLevel

func (by *Bybit) SetLeverageLevel(ctx context.Context, arg *SetLeverageParams) error

SetLeverageLevel sets a leverage from 0 to max leverage of corresponding risk limit

func (*Bybit) SetMMP

func (by *Bybit) SetMMP(ctx context.Context, arg *MMPRequestParam) error

SetMMP Market Maker Protection (MMP) is an automated mechanism designed to protect market makers (MM) against liquidity risks and over-exposure in the market.

func (*Bybit) SetMarginMode

func (by *Bybit) SetMarginMode(ctx context.Context, marginMode string) (*SetMarginModeResponse, error)

SetMarginMode set margin mode to either of ISOLATED_MARGIN, REGULAR_MARGIN(i.e. Cross margin), PORTFOLIO_MARGIN

func (*Bybit) SetRiskLimit

func (by *Bybit) SetRiskLimit(ctx context.Context, arg *SetRiskLimitParam) (*RiskLimitResponse, error)

SetRiskLimit risk limit will limit the maximum position value you can hold under different margin requirements. If you want to hold a bigger position size, you need more margin. This interface can set the risk limit of a single position. If the order exceeds the current risk limit when placing an order, it will be rejected. '0': one-way mode '1': hedge-mode Buy side '2': hedge-mode Sell side

func (*Bybit) SetSpotHedging

func (by *Bybit) SetSpotHedging(ctx context.Context, setHedgingModeOn bool) error

SetSpotHedging to turn on/off Spot hedging feature in Portfolio margin for Unified account.

func (*Bybit) SetSpotMarginTradeLeverage

func (by *Bybit) SetSpotMarginTradeLeverage(ctx context.Context, leverage float64) error

SetSpotMarginTradeLeverage set the user's maximum leverage in spot cross margin

func (*Bybit) SetTakeProfitStopLossMode

func (by *Bybit) SetTakeProfitStopLossMode(ctx context.Context, arg *TPSLModeParams) (*TPSLModeResponse, error)

SetTakeProfitStopLossMode set partial TP/SL mode, you can set the TP/SL size smaller than position size.

func (*Bybit) SetTradingStop

func (by *Bybit) SetTradingStop(ctx context.Context, arg *TradingStopParams) error

SetTradingStop set the take profit, stop loss or trailing stop for the position.

func (*Bybit) Setup

func (by *Bybit) Setup(exch *config.Exchange) error

Setup takes in the supplied exchange configuration details and sets params

func (*Bybit) SubmitOrder

func (by *Bybit) SubmitOrder(ctx context.Context, s *order.Submit) (*order.SubmitResponse, error)

SubmitOrder submits a new order

func (*Bybit) Subscribe

func (by *Bybit) Subscribe(channelsToSubscribe []subscription.Subscription) error

Subscribe sends a websocket message to receive data from the channel

func (*Bybit) SwitchPositionMode

func (by *Bybit) SwitchPositionMode(ctx context.Context, arg *SwitchPositionModeParams) error

SwitchPositionMode switch the position mode for USDT perpetual and Inverse futures. If you are in one-way Mode, you can only open one position on Buy or Sell side. If you are in hedge mode, you can open both Buy and Sell side positions simultaneously. switches mode between MergedSingle: One-Way Mode or BothSide: Hedge Mode

func (*Bybit) SwitchTradeMode

func (by *Bybit) SwitchTradeMode(ctx context.Context, arg *SwitchTradeModeParams) error

SwitchTradeMode sets the trade mode value either to 'cross' or 'isolated'. Select cross margin mode or isolated margin mode per symbol level

func (*Bybit) ToggleMarginTrade

func (by *Bybit) ToggleMarginTrade(ctx context.Context, spotMarginMode bool) (*SpotMarginMode, error)

ToggleMarginTrade turn on / off spot margin trade Your account needs to activate spot margin first; i.e., you must have finished the quiz on web / app. spotMarginMode '1': on, '0': off

func (*Bybit) ToggleMarginTradeNormal

func (by *Bybit) ToggleMarginTradeNormal(ctx context.Context, spotMarginMode bool) (*SpotMarginMode, error)

ToggleMarginTradeNormal turn on / off spot margin trade Your account needs to activate spot margin first; i.e., you must have finished the quiz on web / app. spotMarginMode '1': on, '0': off

func (*Bybit) Unsubscribe

func (by *Bybit) Unsubscribe(channelsToUnsubscribe []subscription.Subscription) error

Unsubscribe sends a websocket message to stop receiving data from the channel

func (*Bybit) UpdateAccountInfo

func (by *Bybit) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies

func (*Bybit) UpdateOrderExecutionLimits

func (by *Bybit) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) error

UpdateOrderExecutionLimits sets exchange executions for a required asset type

func (*Bybit) UpdateOrderbook

func (by *Bybit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bybit) UpdateTicker

func (by *Bybit) UpdateTicker(ctx context.Context, p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Bybit) UpdateTickers

func (by *Bybit) UpdateTickers(ctx context.Context, assetType asset.Item) error

UpdateTickers updates the ticker for all currency pairs of a given asset type

func (*Bybit) UpdateTradablePairs

func (by *Bybit) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*Bybit) UpgradeToUnifiedAccount

func (by *Bybit) UpgradeToUnifiedAccount(ctx context.Context) (*UnifiedAccountUpgradeResponse, error)

UpgradeToUnifiedAccount upgrades the account to unified account.

func (*Bybit) ValidateAPICredentials

func (by *Bybit) ValidateAPICredentials(ctx context.Context, assetType asset.Item) error

ValidateAPICredentials validates current credentials used for wrapper

func (*Bybit) WithdrawCryptocurrencyFunds

func (by *Bybit) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bybit) WithdrawCurrency

func (by *Bybit) WithdrawCurrency(ctx context.Context, arg *WithdrawalParam) (string, error)

WithdrawCurrency Withdraw assets from your Bybit account. You can make an off-chain transfer if the target wallet address is from Bybit. This means that no blockchain fee will be charged.

func (*Bybit) WithdrawFiatFunds

func (by *Bybit) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bybit) WithdrawFiatFundsToInternationalBank

func (by *Bybit) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*Bybit) WsAuth

func (by *Bybit) WsAuth(ctx context.Context) error

WsAuth sends an authentication message to receive auth data

func (*Bybit) WsConnect

func (by *Bybit) WsConnect() error

WsConnect connects to a websocket feed

func (*Bybit) WsInverseConnect

func (by *Bybit) WsInverseConnect() error

WsInverseConnect connects to inverse websocket feed

func (*Bybit) WsLinearConnect

func (by *Bybit) WsLinearConnect() error

WsLinearConnect connects to linear a websocket feed

func (*Bybit) WsOptionsConnect

func (by *Bybit) WsOptionsConnect() error

WsOptionsConnect connects to options a websocket feed

type C2CLendingCoinInfo

type C2CLendingCoinInfo struct {
	Coin            string       `json:"coin"`
	LoanToPoolRatio types.Number `json:"loanToPoolRatio"`
	MaxRedeemQty    types.Number `json:"maxRedeemQty"`
	MinPurchaseQty  types.Number `json:"minPurchaseQty"`
	Precision       types.Number `json:"precision"`
	Rate            types.Number `json:"rate"`
}

C2CLendingCoinInfo represent contract-to-contract lending coin information.

type C2CLendingFundResponse

type C2CLendingFundResponse struct {
	Coin         string               `json:"coin"`
	OrderID      string               `json:"orderId"`
	SerialNumber string               `json:"serialNo"`
	Status       string               `json:"status"`
	CreatedTime  convert.ExchangeTime `json:"createdTime"`
	Quantity     types.Number         `json:"quantity"`
	UpdatedTime  convert.ExchangeTime `json:"updatedTime"`

	// added for redeem funds
	PrincipalQty string `json:"principalQty"`

	// added for to distinguish between redeem funds and deposit funds
	OrderType string `json:"orderType"`
}

C2CLendingFundResponse represents contract-to-contract deposit funds item.

type C2CLendingFundsParams

type C2CLendingFundsParams struct {
	Coin         currency.Code `json:"coin"`
	Quantity     float64       `json:"quantity,string"`
	SerialNumber string        `json:"serialNO"`
}

C2CLendingFundsParams represents deposit funds parameter

type CancelAllOrdersParam

type CancelAllOrdersParam struct {
	Category    string        `json:"category"`
	Symbol      currency.Pair `json:"symbol"`
	BaseCoin    string        `json:"baseCoin,omitempty"`
	SettleCoin  string        `json:"settleCoin,omitempty"`
	OrderFilter string        `json:"orderFilter,omitempty"` // Valid for spot only. Order,tpslOrder. If not passed, Order by default

	// Possible value: Stop. Only used for category=linear or inverse and orderFilter=StopOrder,
	// you can cancel conditional orders except TP/SL order and Trailing stop orders with this param
	StopOrderType string `json:"stopOrderType,omitempty"`
}

CancelAllOrdersParam request parameters for cancel all orders.

type CancelAllResponse

type CancelAllResponse struct {
	List []OrderResponse `json:"list"`
}

CancelAllResponse represents a cancel all trade orders response.

type CancelBatchOrder

type CancelBatchOrder struct {
	Category string              `json:"category"`
	Request  []CancelOrderParams `json:"request"`
}

CancelBatchOrder represents a batch cancel request parameters.

type CancelBatchResponseItem

type CancelBatchResponseItem struct {
	Category    string `json:"category,omitempty"`
	Symbol      string `json:"symbol,omitempty"`
	OrderID     string `json:"orderId,omitempty"`
	OrderLinkID string `json:"orderLinkId,omitempty"`
}

CancelBatchResponseItem represents a batch cancel response item.

type CancelOrderParams

type CancelOrderParams struct {
	Category    string        `json:"category,omitempty"`
	Symbol      currency.Pair `json:"symbol,omitempty"`
	OrderID     string        `json:"orderId,omitempty"`
	OrderLinkID string        `json:"orderLinkId,omitempty"` // User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. future orderLinkId rules:

	OrderFilter string `json:"orderFilter,omitempty"` // Valid for spot only. Order,tpslOrder. If not passed, Order by default
}

CancelOrderParams represents a cancel order parameters.

type ClosedProfitAndLossResponse

type ClosedProfitAndLossResponse struct {
	NextPageCursor string `json:"nextPageCursor"`
	Category       string `json:"category"`
	List           []struct {
		Symbol              string               `json:"symbol"`
		OrderID             string               `json:"orderId"`
		Side                string               `json:"side"`
		Quantity            types.Number         `json:"qty"`
		OrderPrice          types.Number         `json:"orderPrice"`
		OrderType           string               `json:"orderType"`
		ExecutionType       string               `json:"execType"`
		ClosedSize          types.Number         `json:"closedSize"`
		CumulatedEntryValue string               `json:"cumEntryValue"`
		AvgEntryPrice       types.Number         `json:"avgEntryPrice"`
		CumulatedExitValue  string               `json:"cumExitValue"`
		AvgExitPrice        types.Number         `json:"avgExitPrice"`
		ClosedPnl           string               `json:"closedPnl"`
		FillCount           types.Number         `json:"fillCount"`
		Leverage            string               `json:"leverage"`
		CreatedTime         convert.ExchangeTime `json:"createdTime"`
		UpdatedTime         convert.ExchangeTime `json:"updatedTime"`
	} `json:"list"`
}

ClosedProfitAndLossResponse represents list of closed profit and loss records

type CoinBalance

type CoinBalance struct {
	AccountType string `json:"accountType"`
	BizType     int64  `json:"bizType"`
	AccountID   string `json:"accountId"`
	MemberID    string `json:"memberId"`
	Balance     struct {
		Coin               string       `json:"coin"`
		WalletBalance      types.Number `json:"walletBalance"`
		TransferBalance    types.Number `json:"transferBalance"`
		Bonus              types.Number `json:"bonus"`
		TransferSafeAmount string       `json:"transferSafeAmount"`
	} `json:"balance"`
}

CoinBalance represents coin balance for a specific asset type.

type CoinBalances

type CoinBalances struct {
	AccountType string `json:"accountType"`
	BizType     int64  `json:"bizType"`
	AccountID   string `json:"accountId"`
	MemberID    string `json:"memberId"`
	Balance     []struct {
		Coin               string       `json:"coin"`
		WalletBalance      types.Number `json:"walletBalance"`
		TransferBalance    types.Number `json:"transferBalance"`
		Bonus              types.Number `json:"bonus"`
		TransferSafeAmount string       `json:"transferSafeAmount"`
	} `json:"balance"`
}

CoinBalances represents coin balances for a specific asset type.

type CoinExchangeRecords

type CoinExchangeRecords struct {
	OrderBody []struct {
		FromCoin              string               `json:"fromCoin"`
		FromAmount            types.Number         `json:"fromAmount"`
		ToCoin                string               `json:"toCoin"`
		ToAmount              types.Number         `json:"toAmount"`
		ExchangeRate          types.Number         `json:"exchangeRate"`
		CreatedTime           convert.ExchangeTime `json:"createdTime"`
		ExchangeTransactionID string               `json:"exchangeTxId"`
	} `json:"orderBody"`
	NextPageCursor string `json:"nextPageCursor"`
}

CoinExchangeRecords represents a coin exchange records.

type CoinGreeks

type CoinGreeks struct {
	List []struct {
		BaseCoin   string       `json:"baseCoin"`
		TotalDelta types.Number `json:"totalDelta"`
		TotalGamma types.Number `json:"totalGamma"`
		TotalVega  types.Number `json:"totalVega"`
		TotalTheta types.Number `json:"totalTheta"`
	} `json:"list"`
}

CoinGreeks represents current account greeks information.

type CoinInfo

type CoinInfo struct {
	Rows []struct {
		Name         string       `json:"name"`
		Coin         string       `json:"coin"`
		RemainAmount types.Number `json:"remainAmount"`
		Chains       []struct {
			ChainType             string       `json:"chainType"`
			Confirmation          string       `json:"confirmation"`
			WithdrawFee           types.Number `json:"withdrawFee"`
			DepositMin            types.Number `json:"depositMin"`
			WithdrawMin           types.Number `json:"withdrawMin"`
			Chain                 string       `json:"chain"`
			ChainDeposit          types.Number `json:"chainDeposit"`
			ChainWithdraw         string       `json:"chainWithdraw"`
			MinAccuracy           types.Number `json:"minAccuracy"`
			WithdrawPercentageFee types.Number `json:"withdrawPercentageFee"`
		} `json:"chains"`
	} `json:"rows"`
}

CoinInfo represents coin info information.

type CoinRepaymentResponse

type CoinRepaymentResponse struct {
	AccountID          string               `json:"accountId"`
	Coin               string               `json:"coin"`
	RepaidAmount       types.Number         `json:"repaidAmount"`
	RepayID            string               `json:"repayId"`
	RepayMarginOrderID string               `json:"repayMarginOrderId"`
	RepayTime          convert.ExchangeTime `json:"repayTime"`
	TransactIDs        []struct {
		RepaidAmount       types.Number `json:"repaidAmount"`
		RepaidInterest     types.Number `json:"repaidInterest"`
		RepaidPrincipal    types.Number `json:"repaidPrincipal"`
		RepaidSerialNumber types.Number `json:"repaidSerialNumber"`
		TransactID         string       `json:"transactId"`
	} `json:"transactIds"`
}

CoinRepaymentResponse represents a coin repayment detail.

type CollateralInfo

type CollateralInfo struct {
	List []struct {
		Currency            string       `json:"currency"`
		HourlyBorrowRate    types.Number `json:"hourlyBorrowRate"`
		MaxBorrowingAmount  types.Number `json:"maxBorrowingAmount"`
		FreeBorrowingAmount types.Number `json:"freeBorrowingAmount"`
		FreeBorrowingLimit  types.Number `json:"freeBorrowingLimit"`
		FreeBorrowAmount    types.Number `json:"freeBorrowAmount"` // The amount of borrowing within your total borrowing amount that is exempt from interest charges
		BorrowAmount        types.Number `json:"borrowAmount"`
		AvailableToBorrow   types.Number `json:"availableToBorrow"`
		Borrowable          bool         `json:"borrowable"`
		BorrowUsageRate     types.Number `json:"borrowUsageRate"`
		MarginCollateral    bool         `json:"marginCollateral"`
		CollateralSwitch    bool         `json:"collateralSwitch"`
		CollateralRatio     types.Number `json:"collateralRatio"` // Collateral ratio
	} `json:"list"`
}

CollateralInfo represents collateral information of the current unified margin account.

type CreateSubUserParams

type CreateSubUserParams struct {
	Username   string `json:"username,omitempty"`   // Give a username of the new sub user id.
	Password   string `json:"password,omitempty"`   // Set the password for the new sub user id. 8-30 characters, must include numbers, capital and little letters.
	MemberType int64  `json:"memberType,omitempty"` // '1': normal sub account, '6': custodial sub account
	Switch     int64  `json:"switch,omitempty"`     // '0': turn off quick login (default) '1': turn on quick login
	IsUTC      bool   `json:"isUta,omitempty"`
	Note       string `json:"note,omitempty"`
}

CreateSubUserParams parameter to create a new sub user id. Use master user's api key only.

type DeliveryPrice

type DeliveryPrice struct {
	Category       string `json:"category"`
	NextPageCursor string `json:"nextPageCursor"`
	List           []struct {
		Symbol        string               `json:"symbol"`
		DeliveryPrice types.Number         `json:"deliveryPrice"`
		DeliveryTime  convert.ExchangeTime `json:"deliveryTime"`
	} `json:"list"`
}

DeliveryPrice represents the delivery price information.

type DeliveryRecord

type DeliveryRecord struct {
	NextPageCursor string `json:"nextPageCursor"`
	Category       string `json:"category"`
	List           []struct {
		Symbol                        string               `json:"symbol"`
		Side                          string               `json:"side"`
		DeliveryTime                  convert.ExchangeTime `json:"deliveryTime"`
		ExercisePrice                 types.Number         `json:"strike"`
		Fee                           types.Number         `json:"fee"`
		Position                      types.Number         `json:"position"`
		DeliveryPrice                 types.Number         `json:"deliveryPrice"`
		DeliveryRealizedProfitAndLoss types.Number         `json:"deliveryRpl"`
	} `json:"list"`
}

DeliveryRecord represents delivery records of USDC futures and Options.

type DepositAddresses

type DepositAddresses struct {
	Coin   string `json:"coin"`
	Chains []struct {
		ChainType      string `json:"chainType"`
		AddressDeposit string `json:"addressDeposit"`
		TagDeposit     string `json:"tagDeposit"`
		Chain          string `json:"chain"`
	} `json:"chains"`
}

DepositAddresses represents deposit address information.

type DepositRecords

type DepositRecords struct {
	Rows []struct {
		Coin          string `json:"coin"`
		Chain         string `json:"chain"`
		Amount        string `json:"amount"`
		TxID          string `json:"txID"`
		Status        int64  `json:"status"`
		ToAddress     string `json:"toAddress"`
		Tag           string `json:"tag"`
		DepositFee    string `json:"depositFee"`
		SuccessAt     string `json:"successAt"`
		Confirmations string `json:"confirmations"`
		TxIndex       string `json:"txIndex"`
		BlockHash     string `json:"blockHash"`
	} `json:"rows"`
	NextPageCursor string `json:"nextPageCursor"`
}

DepositRecords represents deposit records

type Error

type Error struct {
	ReturnCode      int64  `json:"ret_code"`
	ReturnMsg       string `json:"ret_msg"`
	ReturnCodeV5    int64  `json:"retCode"`
	ReturnMessageV5 string `json:"retMsg"`
	ExtCode         string `json:"ext_code"`
	ExtMsg          string `json:"ext_info"`
}

Error defines all error information for each request

type ErrorMessage

type ErrorMessage struct {
	Code    int64  `json:"code"`
	Message string `json:"msg"`
}

ErrorMessage represents an error message item

type Execution

type Execution struct {
	Symbol                 string               `json:"symbol"`
	OrderType              string               `json:"orderType"`
	UnderlyingPrice        types.Number         `json:"underlyingPrice"`
	IndexPrice             types.Number         `json:"indexPrice"`
	OrderLinkID            string               `json:"orderLinkId"`
	Side                   string               `json:"side"`
	OrderID                string               `json:"orderId"`
	StopOrderType          string               `json:"stopOrderType"`
	LeavesQuantity         types.Number         `json:"leavesQty"`
	ExecTime               convert.ExchangeTime `json:"execTime"`
	IsMaker                bool                 `json:"isMaker"`
	ExecFee                types.Number         `json:"execFee"`
	FeeRate                types.Number         `json:"feeRate"`
	ExecID                 string               `json:"execId"`
	TradeImpliedVolatility string               `json:"tradeIv"`
	BlockTradeID           string               `json:"blockTradeId"`
	MarkPrice              types.Number         `json:"markPrice"`
	ExecPrice              types.Number         `json:"execPrice"`
	MarkIv                 string               `json:"markIv"`
	OrderQuantity          types.Number         `json:"orderQty"`
	ExecValue              string               `json:"execValue"`
	ExecType               string               `json:"execType"`
	OrderPrice             types.Number         `json:"orderPrice"`
	ExecQuantity           types.Number         `json:"execQty"`
	ClosedSize             types.Number         `json:"closedSize"`
}

Execution represents execution record

type ExecutionResponse

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

ExecutionResponse represents users order execution response

type Fee

type Fee struct {
	BaseCoin string       `json:"baseCoin"`
	Symbol   string       `json:"symbol"`
	Taker    types.Number `json:"takerFeeRate"`
	Maker    types.Number `json:"makerFeeRate"`
}

Fee holds fee information

type FeeRate

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

FeeRate represents maker and taker fee rate information for a symbol.

type FundingRate

type FundingRate struct {
	Symbol               string               `json:"symbol"`
	FundingRate          types.Number         `json:"fundingRate"`
	FundingRateTimestamp convert.ExchangeTime `json:"fundingRateTimestamp"`
}

FundingRate represents a funding rate instance.

type FundingRateHistory

type FundingRateHistory struct {
	Category string        `json:"category"`
	List     []FundingRate `json:"list"`
}

FundingRateHistory represents a funding rate history for a category.

type GreeksResponse

type GreeksResponse struct {
	ID           string               `json:"id"`
	Topic        string               `json:"topic"`
	CreationTime convert.ExchangeTime `json:"creationTime"`
	Data         []struct {
		BaseCoin   string       `json:"baseCoin"`
		TotalDelta types.Number `json:"totalDelta"`
		TotalGamma types.Number `json:"totalGamma"`
		TotalVega  types.Number `json:"totalVega"`
		TotalTheta types.Number `json:"totalTheta"`
	} `json:"data"`
}

GreeksResponse represents changes to your greeks data

type HistoricVolatility

type HistoricVolatility struct {
	Period int64                `json:"period"`
	Value  types.Number         `json:"value"`
	Time   convert.ExchangeTime `json:"time"`
}

HistoricVolatility represents option historical volatility

type InstitutionalMarginCoinInfo

type InstitutionalMarginCoinInfo struct {
	MarginToken []struct {
		ProductID string `json:"productId"`
		TokenInfo []struct {
			Token            string `json:"token"`
			ConvertRatioList []struct {
				Ladder       string       `json:"ladder"`
				ConvertRatio types.Number `json:"convertRatio"`
			} `json:"convertRatioList"`
		} `json:"tokenInfo"`
	} `json:"marginToken"`
}

InstitutionalMarginCoinInfo represents margin coin info for institutional lending token and tokens convert information.

type InstitutionalProductInfo

type InstitutionalProductInfo struct {
	MarginProductInfo []struct {
		ProductID           string   `json:"productId"`
		Leverage            string   `json:"leverage"`
		SupportSpot         int64    `json:"supportSpot"`
		SupportContract     int64    `json:"supportContract"`
		WithdrawLine        string   `json:"withdrawLine"`
		TransferLine        string   `json:"transferLine"`
		SpotBuyLine         string   `json:"spotBuyLine"`
		SpotSellLine        string   `json:"spotSellLine"`
		ContractOpenLine    string   `json:"contractOpenLine"`
		LiquidationLine     string   `json:"liquidationLine"`
		StopLiquidationLine string   `json:"stopLiquidationLine"`
		ContractLeverage    string   `json:"contractLeverage"`
		TransferRatio       string   `json:"transferRatio"`
		SpotSymbols         []string `json:"spotSymbols"`
		ContractSymbols     []string `json:"contractSymbols"`
	} `json:"marginProductInfo"`
}

InstitutionalProductInfo represents institutional product info.

type InstrumentInfo

type InstrumentInfo struct {
	Symbol          string               `json:"symbol"`
	ContractType    string               `json:"contractType"`
	Innovation      string               `json:"innovation"`
	MarginTrading   string               `json:"marginTrading"`
	OptionsType     string               `json:"optionsType"`
	Status          string               `json:"status"`
	BaseCoin        string               `json:"baseCoin"`
	QuoteCoin       string               `json:"quoteCoin"`
	LaunchTime      convert.ExchangeTime `json:"launchTime"`
	DeliveryTime    convert.ExchangeTime `json:"deliveryTime"`
	DeliveryFeeRate types.Number         `json:"deliveryFeeRate"`
	PriceScale      types.Number         `json:"priceScale"`
	LeverageFilter  struct {
		MinLeverage  types.Number `json:"minLeverage"`
		MaxLeverage  types.Number `json:"maxLeverage"`
		LeverageStep types.Number `json:"leverageStep"`
	} `json:"leverageFilter"`
	PriceFilter struct {
		MinPrice types.Number `json:"minPrice"`
		MaxPrice types.Number `json:"maxPrice"`
		TickSize types.Number `json:"tickSize"`
	} `json:"priceFilter"`
	LotSizeFilter struct {
		MaxOrderQty         types.Number `json:"maxOrderQty"`
		MinOrderQty         types.Number `json:"minOrderQty"`
		QtyStep             types.Number `json:"qtyStep"`
		PostOnlyMaxOrderQty types.Number `json:"postOnlyMaxOrderQty"`
		BasePrecision       types.Number `json:"basePrecision"`
		QuotePrecision      types.Number `json:"quotePrecision"`
		MinOrderAmt         types.Number `json:"minOrderAmt"`
		MaxOrderAmt         types.Number `json:"maxOrderAmt"`
	} `json:"lotSizeFilter"`
	UnifiedMarginTrade bool   `json:"unifiedMarginTrade"`
	FundingInterval    int64  `json:"fundingInterval"`
	SettleCoin         string `json:"settleCoin"`
}

InstrumentInfo holds all instrument info across spot, linear, option types

type InstrumentInfoItem

type InstrumentInfoItem struct {
	Symbol    string               `json:"symbol"`
	BuyRatio  types.Number         `json:"buyRatio"`
	SellRatio types.Number         `json:"sellRatio"`
	Timestamp convert.ExchangeTime `json:"timestamp"`
}

InstrumentInfoItem represents an instrument long short ratio information.

type InstrumentsInfo

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

InstrumentsInfo represents a category, page indicator, and list of instrument information.

type InsuranceHistory

type InsuranceHistory struct {
	UpdatedTime convert.ExchangeTime `json:"updatedTime"`
	List        []struct {
		Coin    string       `json:"coin"`
		Balance types.Number `json:"balance"`
		Value   types.Number `json:"value"`
	} `json:"list"`
}

InsuranceHistory represents an insurance list.

type InterestAndQuota

type InterestAndQuota struct {
	Coin           string       `json:"coin"`
	InterestRate   string       `json:"interestRate"`
	LoanAbleAmount types.Number `json:"loanAbleAmount"`
	MaxLoanAmount  types.Number `json:"maxLoanAmount"`
}

InterestAndQuota represents interest and quota information.

type InternalDepositRecords

type InternalDepositRecords struct {
	Rows []struct {
		ID          string               `json:"id"`
		Amount      types.Number         `json:"amount"`
		Type        int64                `json:"type"`
		Coin        string               `json:"coin"`
		Address     string               `json:"address"`
		Status      int64                `json:"status"`
		CreatedTime convert.ExchangeTime `json:"createdTime"`
	} `json:"rows"`
	NextPageCursor string `json:"nextPageCursor"`
}

InternalDepositRecords represents internal deposit records response instances

type KlineItem

type KlineItem struct {
	StartTime time.Time
	Open      float64
	High      float64
	Low       float64
	Close     float64

	// not available for mark and index price kline data
	TradeVolume float64
	Turnover    float64
}

KlineItem stores an individual kline data item

type KlineResponse

type KlineResponse struct {
	Symbol   string     `json:"symbol"`
	Category string     `json:"category"`
	List     [][]string `json:"list"`
}

KlineResponse represents a kline item list instance as an array of string.

type LTKlines

type LTKlines []struct {
	Confirm   bool                 `json:"confirm"`
	Interval  string               `json:"interval"`
	Start     convert.ExchangeTime `json:"start"`
	End       convert.ExchangeTime `json:"end"`
	Open      types.Number         `json:"open"`
	Close     types.Number         `json:"close"`
	High      types.Number         `json:"high"`
	Low       types.Number         `json:"low"`
	Timestamp convert.ExchangeTime `json:"timestamp"`
}

LTKlines represents a leverage token kline.

type LTNav

type LTNav struct {
	Symbol         string               `json:"symbol"`
	Time           convert.ExchangeTime `json:"time"`
	Nav            types.Number         `json:"nav"`
	BasketPosition types.Number         `json:"basketPosition"`
	Leverage       types.Number         `json:"leverage"`
	BasketLoan     types.Number         `json:"basketLoan"`
	Circulation    types.Number         `json:"circulation"`
	Basket         types.Number         `json:"basket"`
}

LTNav represents leveraged token nav stream.

type LTTicker

type LTTicker struct {
	Symbol             string       `json:"symbol"`
	LastPrice          types.Number `json:"lastPrice"`
	HighPrice24H       types.Number `json:"highPrice24h"`
	LowPrice24H        types.Number `json:"lowPrice24h"`
	PrevPrice24H       types.Number `json:"prevPrice24h"`
	Price24HPercentage types.Number `json:"price24hPcnt"`
}

LTTicker represents a leverage token ticker.

type LTVInfo

type LTVInfo struct {
	LtvInfo []struct {
		LoanToValue    string       `json:"ltv"`
		ParentUID      string       `json:"parentUid"`
		SubAccountUids []string     `json:"subAccountUids"`
		UnpaidAmount   types.Number `json:"unpaidAmount"`
		UnpaidInfo     []struct {
			Token          string       `json:"token"`
			UnpaidQuantity types.Number `json:"unpaidQty"`
			UnpaidInterest types.Number `json:"unpaidInterest"`
		} `json:"unpaidInfo"`
		Balance     string `json:"balance"`
		BalanceInfo []struct {
			Token           string       `json:"token"`
			Price           types.Number `json:"price"`
			Qty             types.Number `json:"qty"`
			ConvertedAmount types.Number `json:"convertedAmount"`
		} `json:"balanceInfo"`
	} `json:"ltvInfo"`
}

LTVInfo represents institutional lending Loan-to-value(LTV)

type LendArgument

type LendArgument struct {
	Coin           currency.Code `json:"coin"`
	AmountToBorrow float64       `json:"qty,string"`
}

LendArgument represents currency borrow and repay parameter.

type LendingAccountInfo

type LendingAccountInfo struct {
	Coin              string       `json:"coin"`
	PrincipalInterest string       `json:"principalInterest"`
	PrincipalQty      types.Number `json:"principalQty"`
	PrincipalTotal    types.Number `json:"principalTotal"`
	Quantity          types.Number `json:"quantity"`
}

LendingAccountInfo represents contract-to-contract lending account info item.

type LeverageToken

type LeverageToken struct {
	Amount        types.Number `json:"amount"`
	ExecAmt       types.Number `json:"execAmt"`
	ExecQty       types.Number `json:"execQty"`
	LtCoin        string       `json:"ltCoin"`
	LtOrderStatus string       `json:"ltOrderStatus"`
	PurchaseID    string       `json:"purchaseId"`
	SerialNo      string       `json:"serialNo"`
	ValueCoin     string       `json:"valueCoin"`
}

LeverageToken represents a response instance when purchasing a leverage token.

type LeverageTokenInfo

type LeverageTokenInfo struct {
	FundFee          types.Number         `json:"fundFee"`
	FundFeeTime      convert.ExchangeTime `json:"fundFeeTime"`
	LtCoin           string               `json:"ltCoin"`
	LtName           string               `json:"ltName"`
	LtStatus         string               `json:"ltStatus"`
	ManageFeeRate    types.Number         `json:"manageFeeRate"`
	ManageFeeTime    convert.ExchangeTime `json:"manageFeeTime"`
	MaxPurchase      string               `json:"maxPurchase"`
	MaxPurchaseDaily string               `json:"maxPurchaseDaily"`
	MaxRedeem        string               `json:"maxRedeem"`
	MaxRedeemDaily   string               `json:"maxRedeemDaily"`
	MinPurchase      string               `json:"minPurchase"`
	MinRedeem        string               `json:"minRedeem"`
	NetValue         types.Number         `json:"netValue"`
	PurchaseFeeRate  types.Number         `json:"purchaseFeeRate"`
	RedeemFeeRate    types.Number         `json:"redeemFeeRate"`
	Total            types.Number         `json:"total"`
	Value            types.Number         `json:"value"`
}

LeverageTokenInfo represents leverage token information.

type LeveragedTokenMarket

type LeveragedTokenMarket struct {
	Basket      types.Number         `json:"basket"`
	Circulation types.Number         `json:"circulation"`
	Leverage    types.Number         `json:"leverage"` // Real leverage calculated by last traded price
	LTCoin      string               `json:"ltCoin"`
	NetValue    types.Number         `json:"nav"`
	NavTime     convert.ExchangeTime `json:"navTime"` // Update time for net asset value (in milliseconds and UTC time zone)
}

LeveragedTokenMarket represents leverage token market details.

type LoanOrderDetails

type LoanOrderDetails struct {
	OrderID             string               `json:"orderId"`
	OrderProductID      string               `json:"orderProductId"`
	ParentUID           string               `json:"parentUid"`
	LoanTime            convert.ExchangeTime `json:"loanTime"`
	LoanCoin            string               `json:"loanCoin"`
	LoanAmount          types.Number         `json:"loanAmount"`
	UnpaidAmount        types.Number         `json:"unpaidAmount"`
	UnpaidInterest      types.Number         `json:"unpaidInterest"`
	RepaidAmount        types.Number         `json:"repaidAmount"`
	RepaidInterest      types.Number         `json:"repaidInterest"`
	InterestRate        types.Number         `json:"interestRate"`
	Status              int64                `json:"status"`
	Leverage            string               `json:"leverage"`
	SupportSpot         int64                `json:"supportSpot"`
	SupportContract     int64                `json:"supportContract"`
	WithdrawLine        types.Number         `json:"withdrawLine"`
	TransferLine        types.Number         `json:"transferLine"`
	SpotBuyLine         types.Number         `json:"spotBuyLine"`
	SpotSellLine        types.Number         `json:"spotSellLine"`
	ContractOpenLine    types.Number         `json:"contractOpenLine"`
	LiquidationLine     types.Number         `json:"liquidationLine"`
	StopLiquidationLine types.Number         `json:"stopLiquidationLine"`
	ContractLeverage    types.Number         `json:"contractLeverage"`
	TransferRatio       types.Number         `json:"transferRatio"`
	SpotSymbols         []string             `json:"spotSymbols"`
	ContractSymbols     []string             `json:"contractSymbols"`
}

LoanOrderDetails retrieves institutional loan order detail item.

type MMPRequestParam

type MMPRequestParam struct {
	BaseCoin           string       `json:"baseCoin"`
	TimeWindowMS       int64        `json:"window,string"`
	FrozenPeriod       int64        `json:"frozenPeriod,string"`
	TradeQuantityLimit types.Number `json:"qtyLimit"`
	DeltaLimit         types.Number `json:"deltaLimit"`
}

MMPRequestParam represents an MMP request parameter.

type MMPStates

type MMPStates struct {
	Result []struct {
		BaseCoin           string       `json:"baseCoin"`
		MmpEnabled         bool         `json:"mmpEnabled"`
		Window             string       `json:"window"`
		FrozenPeriod       string       `json:"frozenPeriod"`
		TradeQuantityLimit types.Number `json:"qtyLimit"`
		DeltaLimit         types.Number `json:"deltaLimit"`
		MmpFrozenUntil     types.Number `json:"mmpFrozenUntil"`
		MmpFrozen          bool         `json:"mmpFrozen"`
	} `json:"result"`
}

MMPStates represents an MMP states.

type MarginCoinInfo

type MarginCoinInfo struct {
	Coin             string       `json:"coin"`
	ConversionRate   types.Number `json:"conversionRate"`
	LiquidationOrder int64        `json:"liquidationOrder"`
}

MarginCoinInfo represents margin coin information.

type MarkPriceKlineResponse

type MarkPriceKlineResponse struct {
	Symbol   string     `json:"symbol"`
	Category string     `json:"category"`
	List     [][]string `json:"list"`
}

MarkPriceKlineResponse represents a kline data item.

type OpenInterest

type OpenInterest struct {
	Symbol   string `json:"symbol"`
	Category string `json:"category"`
	List     []struct {
		OpenInterest types.Number         `json:"openInterest"`
		Timestamp    convert.ExchangeTime `json:"timestamp"`
	} `json:"list"`
	NextPageCursor string `json:"nextPageCursor"`
}

OpenInterest represents open interest of each symbol.

type OrderRepayInfo

type OrderRepayInfo struct {
	RepayOrderID string               `json:"repayOrderId"`
	RepaidTime   convert.ExchangeTime `json:"repaidTime"`
	Token        string               `json:"token"`
	Quantity     convert.ExchangeTime `json:"quantity"`
	Interest     convert.ExchangeTime `json:"interest"`
	BusinessType string               `json:"businessType"`
	Status       string               `json:"status"`
}

OrderRepayInfo represents repaid information information.

type OrderResponse

type OrderResponse struct {
	OrderID     string `json:"orderId"`
	OrderLinkID string `json:"orderLinkId"`
}

OrderResponse holds newly placed order information.

type Orderbook

type Orderbook struct {
	UpdateID       int64
	Bids           []orderbook.Item
	Asks           []orderbook.Item
	Symbol         string
	GenerationTime time.Time
}

Orderbook stores the orderbook data

type PermissionsList

type PermissionsList struct {
	ContractTrade []string `json:"ContractTrade,omitempty"`
	Spot          []string `json:"Spot,omitempty"`
	Wallet        []string `json:"Wallet,omitempty"`
	Options       []string `json:"Options,omitempty"`
	Exchange      []string `json:"Exchange,omitempty"`
	CopyTrading   []string `json:"CopyTrading,omitempty"`
	BlockTrade    []string `json:"BlockTrade,omitempty"`
	NFT           []string `json:"NFT,omitempty"`
}

PermissionsList represents list of sub api permissions.

type PingMessage

type PingMessage struct {
	Operation string `json:"op"`
	RequestID string `json:"req_id"`
}

PingMessage represents a ping message.

type PlaceBatchOrderParam

type PlaceBatchOrderParam struct {
	Category string                `json:"category"`
	Request  []BatchOrderItemParam `json:"request"`
}

PlaceBatchOrderParam represents a parameter for placing batch orders

type PlaceOrderParams

type PlaceOrderParams struct {
	Category               string        `json:"category"`   // Required
	Symbol                 currency.Pair `json:"symbol"`     // Required
	Side                   string        `json:"side"`       // Required
	OrderType              string        `json:"orderType"`  // Required // Market, Limit
	OrderQuantity          float64       `json:"qty,string"` // Required // Order quantity. For Spot Market Buy order, please note that qty should be quote currency amount
	Price                  float64       `json:"price,string,omitempty"`
	TimeInForce            string        `json:"timeInForce,omitempty"`      // IOC and GTC
	OrderLinkID            string        `json:"orderLinkId,omitempty"`      // User customised order ID. A max of 36 characters. Combinations of numbers, letters (upper and lower cases), dashes, and underscores are supported. future orderLinkId rules:
	WhetherToBorrow        bool          `json:"-"`                          // '0' for default spot, '1' for Margin trading.
	IsLeverage             int64         `json:"isLeverage,omitempty"`       // Required   // '0' for default spot, '1' for Margin trading.
	OrderFilter            string        `json:"orderFilter,omitempty"`      // Valid for spot only. Order,tpslOrder. If not passed, Order by default
	TriggerDirection       int64         `json:"triggerDirection,omitempty"` // Required // Conditional order param. Used to identify the expected direction of the conditional order. '1': triggered when market price rises to triggerPrice '2': triggered when market price falls to triggerPrice
	TriggerPrice           float64       `json:"triggerPrice,omitempty,string"`
	TriggerPriceType       string        `json:"triggerBy,omitempty"` // Conditional order param. Trigger price type. 'LastPrice', 'IndexPrice', 'MarkPrice'
	OrderImpliedVolatility string        `json:"orderIv,omitempty"`
	PositionIdx            int64         `json:"positionIdx,omitempty"` // Under hedge-mode, this param is required '0': one-way mode '1': hedge-mode Buy side '2': hedge-mode Sell side
	TakeProfitPrice        float64       `json:"takeProfit,omitempty,string"`
	TakeProfitTriggerBy    string        `json:"tpTriggerBy,omitempty"` // The price type to trigger take profit. 'MarkPrice', 'IndexPrice', default: 'LastPrice'
	StopLossTriggerBy      string        `json:"slTriggerBy,omitempty"` // The price type to trigger stop loss. MarkPrice, IndexPrice, default: LastPrice
	StopLossPrice          float64       `json:"stopLoss,omitempty,string"`
	SMPExecutionType       string        `json:"smpType,omitempty"` // default: 'None', 'CancelMaker', 'CancelTaker', 'CancelBoth'
	ReduceOnly             bool          `json:"reduceOnly,omitempty"`
	CloseOnTrigger         bool          `json:"closeOnTrigger,omitempty"`
	MarketMakerProtection  bool          `json:"mmp,omitempty"` // option only. true means set the order as a market maker protection order.

	// TP/SL mode
	// "Full": entire position for TP/SL. Then, tpOrderType or slOrderType must be Market
	// 'Partial': partial position tp/sl. Limit TP/SL order are supported. Note: When create limit tp/sl, tpslMode is required and it must be Partial
	TpslMode     string  `json:"tpslMode,omitempty"`
	TpOrderType  string  `json:"tpOrderType,omitempty"`
	SlOrderType  string  `json:"slOrderType,omitempty"`
	TpLimitPrice float64 `json:"tpLimitPrice,omitempty,string"`
	SlLimitPrice float64 `json:"slLimitPrice,omitempty,string"`
}

PlaceOrderParams represents

type PositionInfo

type PositionInfo struct {
	Symbol           string       `json:"symbol"`
	Side             string       `json:"side"`
	Size             types.Number `json:"size"`
	AveragePrice     types.Number `json:"avgPrice"`
	PositionValue    types.Number `json:"positionValue"`
	TradeMode        int64        `json:"tradeMode"`
	PositionStatus   string       `json:"positionStatus"`
	AutoAddMargin    int64        `json:"autoAddMargin"`
	ADLRankIndicator int64        `json:"adlRankIndicator"`
	Leverage         types.Number `json:"leverage"`
	PositionBalance  types.Number `json:"positionBalance"`
	MarkPrice        types.Number `json:"markPrice"`
	LiqPrice         types.Number `json:"liqPrice"`
	BustPrice        types.Number `json:"bustPrice"`
	PositionMM       types.Number `json:"positionMM"`
	PositionIM       types.Number `json:"positionIM"`
	TpslMode         string       `json:"tpslMode"`
	TakeProfit       types.Number `json:"takeProfit"`
	StopLoss         types.Number `json:"stopLoss"`
	TrailingStop     types.Number `json:"trailingStop"`
	UnrealisedPnl    types.Number `json:"unrealisedPnl"`
	PositionIndex    int64        `json:"positionIdx"`
	RiskID           int64        `json:"riskId"`
	RiskLimitValue   string       `json:"riskLimitValue"`

	// Futures & Perp: it is the all time cumulative realised P&L
	// Option: it is the realised P&L when you hold that position
	CumRealisedPnl types.Number         `json:"cumRealisedPnl"`
	CreatedTime    convert.ExchangeTime `json:"createdTime"`
	UpdatedTime    convert.ExchangeTime `json:"updatedTime"`

	IsReduceOnly           bool                 `json:"isReduceOnly"`
	MMRSysUpdatedTime      convert.ExchangeTime `json:"mmrSysUpdatedTime"`
	LeverageSysUpdatedTime convert.ExchangeTime `json:"leverageSysUpdatedTime"`

	// Cross sequence, used to associate each fill and each position update
	// Different symbols may have the same seq, please use seq + symbol to check unique
	// Returns "-1" if the symbol has never been traded
	// Returns the seq updated by the last transaction when there are settings like leverage, risk limit
	Sequence int64 `json:"seq"`
}

PositionInfo represents a position info item.

type PositionInfoList

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

PositionInfoList represents a list of positions infos.

type PreUpdateOptionDeliveryRecord

type PreUpdateOptionDeliveryRecord struct {
	NextPageCursor string `json:"nextPageCursor"`
	Category       string `json:"category"`
	List           []struct {
		Symbol        string               `json:"symbol"`
		Side          string               `json:"side"`
		DeliveryTime  convert.ExchangeTime `json:"deliveryTime"`
		ExercisePrice types.Number         `json:"strike"`
		Fee           types.Number         `json:"fee"`
		Position      string               `json:"position"`
		DeliveryPrice types.Number         `json:"deliveryPrice"`
		DeliveryRpl   string               `json:"deliveryRpl"` // Realized PnL of the delivery
	} `json:"list"`
}

PreUpdateOptionDeliveryRecord represents delivery records of Option

type RateLimit

type RateLimit struct {
	SpotRate                                  *rate.Limiter
	CreateOrderRate                           *rate.Limiter
	CreateSpotOrderRate                       *rate.Limiter
	AmendOrderRate                            *rate.Limiter
	CancelOrderRate                           *rate.Limiter
	CancelSpotRate                            *rate.Limiter
	CancelAllRate                             *rate.Limiter
	CancelAllSpotRate                         *rate.Limiter
	CreateBatchOrderRate                      *rate.Limiter
	AmendBatchOrderRate                       *rate.Limiter
	CancelBatchOrderRate                      *rate.Limiter
	GetOrderRate                              *rate.Limiter
	GetOrderHistoryRate                       *rate.Limiter
	GetPositionListRate                       *rate.Limiter
	GetExecutionListRate                      *rate.Limiter
	GetPositionClosedPNLRate                  *rate.Limiter
	PostPositionSetLeverageRate               *rate.Limiter
	SetPositionTPLSModeRate                   *rate.Limiter
	SetPositionRiskLimitRate                  *rate.Limiter
	StopTradingPositionRate                   *rate.Limiter
	GetAccountWalletBalanceRate               *rate.Limiter
	GetAccountFeeRate                         *rate.Limiter
	GetAssetTransferQueryInfoRate             *rate.Limiter
	GetAssetTransferQueryTransferCoinListRate *rate.Limiter
	GetAssetTransferCoinListRate              *rate.Limiter
	GetAssetInterTransferListRate             *rate.Limiter
	GetSubMemberListRate                      *rate.Limiter
	GetAssetUniversalTransferListRate         *rate.Limiter
	GetAssetAccountCoinBalanceRate            *rate.Limiter
	GetAssetDepositRecordsRate                *rate.Limiter
	GetAssetDepositSubMemberRecordsRate       *rate.Limiter
	GetAssetDepositSubMemberAddressRate       *rate.Limiter
	GetWithdrawRecordsRate                    *rate.Limiter
	GetAssetCoinInfoRate                      *rate.Limiter
	GetExchangeOrderRecordRate                *rate.Limiter
	InterTransferRate                         *rate.Limiter
	SaveTransferSubMemberRate                 *rate.Limiter
	UniversalTransferRate                     *rate.Limiter
	CreateWithdrawalRate                      *rate.Limiter
	CancelWithdrawalRate                      *rate.Limiter
	UserCreateSubMemberRate                   *rate.Limiter
	UserCreateSubAPIKeyRate                   *rate.Limiter
	UserFrozenSubMemberRate                   *rate.Limiter
	UserUpdateAPIRate                         *rate.Limiter
	UserUpdateSubAPIRate                      *rate.Limiter
	UserDeleteAPIRate                         *rate.Limiter
	UserDeleteSubAPIRate                      *rate.Limiter
	UserQuerySubMembersRate                   *rate.Limiter
	UserQueryAPIRate                          *rate.Limiter
	GetSpotLeverageTokenOrderRecordsRate      *rate.Limiter
	SpotLeverageTokenPurchaseRate             *rate.Limiter
	SpotLeverTokenRedeemRate                  *rate.Limiter
	GetSpotCrossMarginTradeLoanInfoRate       *rate.Limiter
	GetSpotCrossMarginTradeAccountRate        *rate.Limiter
	GetSpotCrossMarginTradeOrdersRate         *rate.Limiter
	GetSpotCrossMarginTradeRepayHistoryRate   *rate.Limiter
	SpotCrossMarginTradeLoanRate              *rate.Limiter
	SpotCrossMarginTradeRepayRate             *rate.Limiter
	SpotCrossMarginTradeSwitchRate            *rate.Limiter
}

RateLimit implements the request.Limiter interface

func SetRateLimit

func SetRateLimit() *RateLimit

SetRateLimit returns the rate limit for the exchange

func (*RateLimit) Limit

Limit executes rate limiting functionality for Binance

type RedeemPurchaseRecord

type RedeemPurchaseRecord struct {
	Amount        types.Number         `json:"amount"`
	Fee           types.Number         `json:"fee"`
	LtCoin        string               `json:"ltCoin"`
	LtOrderStatus string               `json:"ltOrderStatus"`
	LtOrderType   string               `json:"ltOrderType"`
	OrderID       string               `json:"orderId"`
	OrderTime     convert.ExchangeTime `json:"orderTime"`
	SerialNo      string               `json:"serialNo"`
	UpdateTime    convert.ExchangeTime `json:"updateTime"`
	Value         types.Number         `json:"value"`
	ValueCoin     string               `json:"valueCoin"`
}

RedeemPurchaseRecord represents a purchase and redeem record instance.

type RedeemToken

type RedeemToken struct {
	ExecAmt       types.Number `json:"execAmt"`
	ExecQty       types.Number `json:"execQty"`
	LtCoin        string       `json:"ltCoin"`
	LtOrderStatus string       `json:"ltOrderStatus"`
	Quantity      types.Number `json:"quantity"`
	RedeemID      string       `json:"redeemId"`
	SerialNo      string       `json:"serialNo"`
	ValueCoin     string       `json:"valueCoin"`
}

RedeemToken represents leverage redeem token

type RepayResponse

type RepayResponse struct {
	RepayID string `json:"repayId"`
}

RepayResponse represents a repay id

type RestResponse

type RestResponse struct {
	RetCode    int64       `json:"retCode"`
	RetMsg     string      `json:"retMsg"`
	Result     interface{} `json:"result"`
	RetExtInfo struct {
		List []ErrorMessage `json:"list"`
	} `json:"retExtInfo"`
	Time convert.ExchangeTime `json:"time"`
}

RestResponse represents a REST response instance.

type RiskLimitHistory

type RiskLimitHistory struct {
	Category string `json:"category"`
	List     []struct {
		ID                int64        `json:"id"`
		IsLowestRisk      int64        `json:"isLowestRisk"`
		Symbol            string       `json:"symbol"`
		RiskLimitValue    types.Number `json:"riskLimitValue"`
		MaintenanceMargin types.Number `json:"maintenanceMargin"`
		InitialMargin     types.Number `json:"initialMargin"`
		MaxLeverage       types.Number `json:"maxLeverage"`
	} `json:"list"`
}

RiskLimitHistory represents risk limit history of a category.

type RiskLimitResponse

type RiskLimitResponse struct {
	RiskID         int64  `json:"riskId"`
	RiskLimitValue string `json:"riskLimitValue"`
	Category       string `json:"category"`
}

RiskLimitResponse represents a risk limit response.

type ServerTime

type ServerTime struct {
	TimeSecond convert.ExchangeTime `json:"timeSecond"`
	TimeNano   convert.ExchangeTime `json:"timeNano"`
}

ServerTime represents server time

type SetDCPParams

type SetDCPParams struct {
	TimeWindow int64 `json:"timeWindow"`
}

SetDCPParams represents the set disconnect cancel all parameters.

type SetLeverageParams

type SetLeverageParams struct {
	Category     string  `json:"category"`
	Symbol       string  `json:"symbol"`
	BuyLeverage  float64 `json:"buyLeverage,string"`  // [0, max leverage of corresponding risk limit]. Note: Under one-way mode, buyLeverage must be the same as sellLeverage
	SellLeverage float64 `json:"sellLeverage,string"` // [0, max leverage of corresponding risk limit]. Note: Under one-way mode, buyLeverage must be the same as sellLeverage
}

SetLeverageParams parameters to set the leverage.

type SetMarginModeResponse

type SetMarginModeResponse struct {
	Reasons []struct {
		ReasonCode string `json:"reasonCode"`
		ReasonMsg  string `json:"reasonMsg"`
	} `json:"reasons"`
}

SetMarginModeResponse represents a response for setting margin mode.

type SetRiskLimitParam

type SetRiskLimitParam struct {
	Category     string        `json:"category"`
	Symbol       currency.Pair `json:"symbol"` // Symbol name. Either symbol or coin is required. symbol has a higher priority
	RiskID       int64         `json:"riskId"`
	PositionMode int64         `json:"positionIdx"` // Used to identify positions in different position modes. For hedge mode, it is required '0': one-way mode '1': hedge-mode Buy side '2': hedge-mode Sell side
}

SetRiskLimitParam represents a risk limit set parameter.

type SettlementSession

type SettlementSession struct {
	NextPageCursor string `json:"nextPageCursor"`
	Category       string `json:"category"`
	List           []struct {
		RealisedProfitAndLoss string               `json:"realisedPnl"`
		Symbol                string               `json:"symbol"`
		Side                  string               `json:"side"`
		MarkPrice             types.Number         `json:"markPrice"`
		Size                  types.Number         `json:"size"`
		CreatedTime           convert.ExchangeTime `json:"createdTime"`
		SessionAveragePrice   types.Number         `json:"sessionAvgPrice"`
	} `json:"list"`
}

SettlementSession represents a USDC settlement session.

type SpotMarginMode

type SpotMarginMode struct {
	SpotMarginMode string `json:"spotMarginMode"`
}

SpotMarginMode represents data about whether spot margin trade is on / off

type StatusResponse

type StatusResponse struct {
	Status int64 `json:"status"` // 1: SUCCESS 0: FAIL
}

StatusResponse represents account information

type SubAccountAPIKeys

type SubAccountAPIKeys struct {
	Result []struct {
		ID          string    `json:"id"`
		Ips         []string  `json:"ips"`
		APIKey      string    `json:"apiKey"`
		Note        string    `json:"note"`
		Status      int64     `json:"status"`
		ExpiredAt   time.Time `json:"expiredAt"`
		CreatedAt   time.Time `json:"createdAt"`
		Type        int64     `json:"type"`
		Permissions struct {
			ContractTrade []string `json:"ContractTrade"`
			Spot          []string `json:"Spot"`
			Wallet        []string `json:"Wallet"`
			Options       []string `json:"Options"`
			Derivatives   []string `json:"Derivatives"`
			CopyTrading   []string `json:"CopyTrading"`
			BlockTrade    []string `json:"BlockTrade"`
			Exchange      []string `json:"Exchange"`
			Nft           []string `json:"NFT"`
			Affiliate     []string `json:"Affiliate"`
		} `json:"permissions"`
		Secret      string `json:"secret"`
		ReadOnly    bool   `json:"readOnly"`
		DeadlineDay int64  `json:"deadlineDay"`
		Flag        string `json:"flag"`
	} `json:"result"`
	NextPageCursor string `json:"nextPageCursor"`
}

SubAccountAPIKeys holds list of sub-account API Keys

type SubUID

type SubUID struct {
	SubMemberIDs             []string `json:"subMemberIds"`
	TransferableSubMemberIDs []string `json:"transferableSubMemberIds"`
}

SubUID represents a sub-users ID

type SubUIDAPIKeyParam

type SubUIDAPIKeyParam struct {
	Subuid int64  `json:"subuid"`
	Note   string `json:"note"`

	ReadOnly int64 `json:"readOnly"`

	// Set the IP bind. example: ["192.168.0.1,192.168.0.2"]note:
	// don't pass ips or pass with ["*"] means no bind
	// No ip bound api key will be invalid after 90 days
	// api key will be invalid after 7 days once the account password is changed
	IPs []string `json:"ips"`

	// Tick the types of permission. one of below types must be passed, otherwise the error is thrown
	Permissions map[string][]string `json:"permissions,omitempty"`
}

SubUIDAPIKeyParam represents a sub-user ID API key creation parameter.

type SubUIDAPIKeyUpdateParam

type SubUIDAPIKeyUpdateParam struct {
	APIKey   string `json:"apikey"`
	ReadOnly int64  `json:"readOnly,omitempty"`
	// Set the IP bind. example: ["192.168.0.1,192.168.0.2"]note:
	// don't pass ips or pass with ["*"] means no bind
	// No ip bound api key will be invalid after 90 days
	// api key will be invalid after 7 days once the account password is changed
	IPs string `json:"ips"`

	// You can provide the IP addresses as a list of strings.
	IPAddresses []string `json:"-"`

	// Tick the types of permission. one of below types must be passed, otherwise the error is thrown
	Permissions PermissionsList `json:"permissions"`
}

SubUIDAPIKeyUpdateParam represents a sub-user ID API key update parameter.

type SubUIDAPIResponse

type SubUIDAPIResponse struct {
	ID          string              `json:"id"`
	Note        string              `json:"note"`
	APIKey      string              `json:"apiKey"`
	ReadOnly    int64               `json:"readOnly"`
	Secret      string              `json:"secret"`
	Permissions map[string][]string `json:"permissions"`

	IPS                   []string  `json:"ips"`
	Type                  int64     `json:"type"`
	DeadlineDay           int64     `json:"deadlineDay"`
	ExpiredAt             time.Time `json:"expiredAt"`
	CreatedAt             time.Time `json:"createdAt"`
	IsMarginUnified       int64     `json:"unified"` // Whether the account to which the account upgrade to unified margin account.
	IsUnifiedTradeAccount int64     `json:"uta"`     // Whether the account to which the account upgrade to unified trade account.
	UserID                int64     `json:"userID"`
	InviterID             int64     `json:"inviterID"`
	VipLevel              string    `json:"vipLevel"`
	MktMakerLevel         string    `json:"mktMakerLevel"`
	AffiliateID           int64     `json:"affiliateID"`
	RsaPublicKey          string    `json:"rsaPublicKey"`
	IsMaster              bool      `json:"isMaster"`

	// Personal account kyc level. LEVEL_DEFAULT, LEVEL_1, LEVEL_2
	KycLevel  string `json:"kycLevel"`
	KycRegion string `json:"kycRegion"`
}

SubUIDAPIResponse represents sub UID API key response.

type SubUserItem

type SubUserItem struct {
	UID        string `json:"uid"`
	Username   string `json:"username"`
	MemberType int64  `json:"memberType"`
	Status     int64  `json:"status"`
	Remark     string `json:"remark"`
}

SubUserItem represents a sub user response instance.

type SubscriptionArgument

type SubscriptionArgument struct {
	RequestID string   `json:"req_id"`
	Operation string   `json:"op"`
	Arguments []string `json:"args"`
	// contains filtered or unexported fields
}

SubscriptionArgument represents a subscription arguments.

type SubscriptionResponse

type SubscriptionResponse struct {
	Success   bool   `json:"success"`
	RetMsg    string `json:"ret_msg"`
	ConnID    string `json:"conn_id"`
	RequestID string `json:"req_id"`
	Operation string `json:"op"`
}

SubscriptionResponse represents a subscription response.

type SwitchPositionModeParams

type SwitchPositionModeParams struct {
	Category     string        `json:"category"`
	Symbol       currency.Pair `json:"symbol"` // Symbol name. Either symbol or coin is required. symbol has a higher priority
	Coin         currency.Code `json:"coin"`
	PositionMode int64         `json:"mode"` // Position mode. 0: Merged Single. 3: Both Sides
}

SwitchPositionModeParams represents a position switch mode parameters.

type SwitchTradeModeParams

type SwitchTradeModeParams struct {
	Category     string  `json:"category"`
	Symbol       string  `json:"symbol"`
	BuyLeverage  float64 `json:"buyLeverage,string"`
	SellLeverage float64 `json:"sellLeverage,string"`
	TradeMode    int64   `json:"tradeMode"` // 0: cross margin. 1: isolated margin
}

SwitchTradeModeParams parameters to switch between cross margin and isolated margin trade mode.

type TPSLModeParams

type TPSLModeParams struct {
	Category string `json:"category"`
	Symbol   string `json:"symbol"`
	TpslMode string `json:"tpSlMode"` // TP/SL mode. Full,Partial
}

TPSLModeParams parameters for settle Take Profit(TP) or Stop Loss(SL) mode.

type TPSLModeResponse

type TPSLModeResponse struct {
	TPSLMode string `json:"tpSlMode"`
}

TPSLModeResponse represents response for the take profit and stop loss mode change.

type TickerData

type TickerData struct {
	Category string       `json:"category"`
	List     []TickerItem `json:"list"`
}

TickerData represents a list of ticker detailed information.

type TickerItem

type TickerItem struct {
	Symbol                 string               `json:"symbol"`
	LastPrice              types.Number         `json:"lastPrice"`
	IndexPrice             types.Number         `json:"indexPrice"`
	MarkPrice              types.Number         `json:"markPrice"`
	PrevPrice24H           types.Number         `json:"prevPrice24h"`
	Price24HPcnt           types.Number         `json:"price24hPcnt"`
	HighPrice24H           types.Number         `json:"highPrice24h"`
	LowPrice24H            types.Number         `json:"lowPrice24h"`
	PrevPrice1H            types.Number         `json:"prevPrice1h"`
	OpenInterest           types.Number         `json:"openInterest"`
	OpenInterestValue      types.Number         `json:"openInterestValue"`
	Turnover24H            types.Number         `json:"turnover24h"`
	Volume24H              types.Number         `json:"volume24h"`
	FundingRate            types.Number         `json:"fundingRate"`
	NextFundingTime        convert.ExchangeTime `json:"nextFundingTime"`
	PredictedDeliveryPrice types.Number         `json:"predictedDeliveryPrice"`
	BasisRate              types.Number         `json:"basisRate"`
	DeliveryFeeRate        types.Number         `json:"deliveryFeeRate"`
	DeliveryTime           convert.ExchangeTime `json:"deliveryTime"`
	Ask1Size               types.Number         `json:"ask1Size"`
	Bid1Price              types.Number         `json:"bid1Price"`
	Ask1Price              types.Number         `json:"ask1Price"`
	Bid1Size               types.Number         `json:"bid1Size"`
	Basis                  types.Number         `json:"basis"`
	Bid1Iv                 types.Number         `json:"bid1Iv"`
	Ask1Iv                 types.Number         `json:"ask1Iv"`
	MarkIv                 types.Number         `json:"markIv"`
	UnderlyingPrice        types.Number         `json:"underlyingPrice"`
	TotalVolume            types.Number         `json:"totalVolume"`
	TotalTurnover          types.Number         `json:"totalTurnover"`
	Delta                  types.Number         `json:"delta"`
	Gamma                  types.Number         `json:"gamma"`
	Vega                   types.Number         `json:"vega"`
	Theta                  types.Number         `json:"theta"`
	Change24Hour           types.Number         `json:"change24h"`
}

TickerItem represents a ticker item detail.

type TradeOrder

type TradeOrder struct {
	OrderID                string               `json:"orderId"`
	OrderLinkID            string               `json:"orderLinkId"`
	BlockTradeID           string               `json:"blockTradeId"`
	Symbol                 string               `json:"symbol"`
	Price                  types.Number         `json:"price"`
	OrderQuantity          types.Number         `json:"qty"`
	Side                   string               `json:"side"`
	IsLeverage             string               `json:"isLeverage"`
	PositionIdx            int64                `json:"positionIdx"`
	OrderStatus            string               `json:"orderStatus"`
	CancelType             string               `json:"cancelType"`
	RejectReason           string               `json:"rejectReason"`
	AveragePrice           types.Number         `json:"avgPrice"`
	LeavesQuantity         types.Number         `json:"leavesQty"`
	LeavesValue            string               `json:"leavesValue"`
	CumulativeExecQuantity types.Number         `json:"cumExecQty"`
	CumulativeExecValue    types.Number         `json:"cumExecValue"`
	CumulativeExecFee      types.Number         `json:"cumExecFee"`
	TimeInForce            string               `json:"timeInForce"`
	OrderType              string               `json:"orderType"`
	StopOrderType          string               `json:"stopOrderType"`
	OrderIv                string               `json:"orderIv"`
	TriggerPrice           types.Number         `json:"triggerPrice"`
	TakeProfitPrice        types.Number         `json:"takeProfit"`
	StopLossPrice          types.Number         `json:"stopLoss"`
	TpTriggerBy            string               `json:"tpTriggerBy"`
	SlTriggerBy            string               `json:"slTriggerBy"`
	TriggerDirection       int64                `json:"triggerDirection"`
	TriggerBy              string               `json:"triggerBy"`
	LastPriceOnCreated     string               `json:"lastPriceOnCreated"`
	ReduceOnly             bool                 `json:"reduceOnly"`
	CloseOnTrigger         bool                 `json:"closeOnTrigger"`
	SmpType                string               `json:"smpType"`
	SmpGroup               int64                `json:"smpGroup"`
	SmpOrderID             string               `json:"smpOrderId"`
	TpslMode               string               `json:"tpslMode"`
	TpLimitPrice           types.Number         `json:"tpLimitPrice"`
	SlLimitPrice           types.Number         `json:"slLimitPrice"`
	PlaceType              string               `json:"placeType"`
	CreatedTime            convert.ExchangeTime `json:"createdTime"`
	UpdatedTime            convert.ExchangeTime `json:"updatedTime"`

	// UTA Spot: add new response field 'ocoTriggerBy',
	// and the value can be 'OcoTriggerByUnknown', 'OcoTriggerByTp', 'OcoTriggerBySl'
	OCOTriggerType string `json:"ocoTriggerType"`
	OCOTriggerBy   string `json:"ocoTriggerBy"`
}

TradeOrder represents a trade order details.

type TradeOrders

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

TradeOrders represents category and list of trade orders of the category.

type TradingHistory

type TradingHistory struct {
	Category string               `json:"category"`
	List     []TradingHistoryItem `json:"list"`
}

TradingHistory represents a trading history list.

type TradingHistoryItem

type TradingHistoryItem struct {
	ExecutionID  string               `json:"execId"`
	Symbol       string               `json:"symbol"`
	Side         string               `json:"side"`
	Price        types.Number         `json:"price"`
	Size         types.Number         `json:"size"`
	TradeTime    convert.ExchangeTime `json:"time"`
	IsBlockTrade bool                 `json:"isBlockTrade"`
}

TradingHistoryItem represents a trading history item instance.

type TradingStopParams

type TradingStopParams struct {
	Category                 string        `json:"category"`
	Symbol                   currency.Pair `json:"symbol"`                 // Symbol name. Either symbol or coin is required. symbol has a higher priority
	TakeProfit               string        `json:"takeProfit,omitempty"`   // Cannot be less than 0, 0 means cancel TP
	StopLoss                 string        `json:"stopLoss,omitempty"`     // Cannot be less than 0, 0 means cancel SL
	TrailingStop             string        `json:"trailingStop,omitempty"` // Trailing stop by price distance. Cannot be less than 0, 0 means cancel TS
	TakeProfitTriggerType    string        `json:"tpTriggerBy,omitempty"`
	StopLossTriggerType      string        `json:"slTriggerBy,omitempty"`
	ActivePrice              float64       `json:"activePrice,omitempty,string"`
	TakeProfitOrStopLossMode string        `json:"tpslMode,omitempty"`
	TakeProfitOrderType      string        `json:"tpOrderType,omitempty"`
	StopLossOrderType        string        `json:"slOrderType,omitempty"`
	TakeProfitSize           float64       `json:"tpSize,string,omitempty"`
	StopLossSize             float64       `json:"slSize,string,omitempty"`
	TakeProfitLimitPrice     float64       `json:"tpLimitPrice,string,omitempty"`
	StopLossLimitPrice       float64       `json:"slLimitPrice,string,omitempty"`
	PositionIndex            int64         `json:"positionIdx,omitempty"`
}

TradingStopParams take profit, stop loss or trailing stop for the position.

type TransactionLog

type TransactionLog struct {
	NextPageCursor string               `json:"nextPageCursor"`
	List           []TransactionLogItem `json:"list"`
}

TransactionLog represents a transaction log history.

type TransactionLogItem

type TransactionLogItem struct {
	Symbol          string               `json:"symbol"`
	Side            string               `json:"side"`
	Funding         string               `json:"funding"`
	OrderLinkID     string               `json:"orderLinkId"`
	OrderID         string               `json:"orderId"`
	Fee             types.Number         `json:"fee"`
	Change          string               `json:"change"`
	CashFlow        string               `json:"cashFlow"`
	TransactionTime convert.ExchangeTime `json:"transactionTime"`
	Type            string               `json:"type"`
	FeeRate         types.Number         `json:"feeRate"`
	BonusChange     types.Number         `json:"bonusChange"`
	Size            types.Number         `json:"size"`
	Qty             types.Number         `json:"qty"`
	CashBalance     types.Number         `json:"cashBalance"`
	Currency        string               `json:"currency"`
	Category        string               `json:"category"`
	TradePrice      types.Number         `json:"tradePrice"`
	TradeID         string               `json:"tradeId"`
}

TransactionLogItem represents a transaction log item information.

type TransferParams

type TransferParams struct {
	TransferID      uuid.UUID     `json:"transferId"`
	Coin            currency.Code `json:"coin"`
	Amount          types.Number  `json:"amount,string"`
	FromAccountType string        `json:"fromAccountType"`
	ToAccountType   string        `json:"toAccountType"`

	// Added for universal transfers
	FromMemberID int64 `json:"fromMemberId"`
	ToMemberID   int64 `json:"toMemberId"`
}

TransferParams represents parameters from internal coin transfer.

type TransferResponse

type TransferResponse struct {
	List []struct {
		TransferID      string               `json:"transferId"`
		Coin            string               `json:"coin"`
		Amount          types.Number         `json:"amount"`
		FromAccountType string               `json:"fromAccountType"`
		ToAccountType   string               `json:"toAccountType"`
		Timestamp       convert.ExchangeTime `json:"timestamp"`
		Status          string               `json:"status"`

		// Returned with universal transfer IDs.
		FromMemberID string `json:"fromMemberId"`
		ToMemberID   string `json:"toMemberId"`
	} `json:"list"`
	NextPageCursor string `json:"nextPageCursor"`
}

TransferResponse represents a transfer response

type TransferableCoins

type TransferableCoins struct {
	List []string `json:"list"`
}

TransferableCoins represents list of transferable coins.

type UnifiedAccountUpgradeResponse

type UnifiedAccountUpgradeResponse struct {
	UnifiedUpdateStatus string `json:"unifiedUpdateStatus"`
	UnifiedUpdateMsg    struct {
		Messages []string `json:"msg"`
	} `json:"unifiedUpdateMsg"`
}

UnifiedAccountUpgradeResponse represents a response parameter for update to unified account.

type VIPMarginData

type VIPMarginData struct {
	VipCoinList []struct {
		List []struct {
			Borrowable         bool         `json:"borrowable"`
			CollateralRatio    types.Number `json:"collateralRatio"`
			Currency           string       `json:"currency"`
			HourlyBorrowRate   types.Number `json:"hourlyBorrowRate"`
			LiquidationOrder   string       `json:"liquidationOrder"`
			MarginCollateral   bool         `json:"marginCollateral"`
			MaxBorrowingAmount types.Number `json:"maxBorrowingAmount"`
		} `json:"list"`
		VipLevel string `json:"vipLevel"`
	} `json:"vipCoinList"`
}

VIPMarginData represents VIP margin data.

type WalletBalance

type WalletBalance struct {
	List []struct {
		TotalEquity            types.Number `json:"totalEquity"`
		AccountIMRate          types.Number `json:"accountIMRate"`
		TotalMarginBalance     types.Number `json:"totalMarginBalance"`
		TotalInitialMargin     types.Number `json:"totalInitialMargin"`
		AccountType            string       `json:"accountType"`
		TotalAvailableBalance  types.Number `json:"totalAvailableBalance"`
		AccountMMRate          types.Number `json:"accountMMRate"`
		TotalPerpUPL           string       `json:"totalPerpUPL"`
		TotalWalletBalance     types.Number `json:"totalWalletBalance"`
		AccountLTV             string       `json:"accountLTV"` // Account LTV: account total borrowed size / (account total equity + account total borrowed size).
		TotalMaintenanceMargin types.Number `json:"totalMaintenanceMargin"`
		SpotHedgingQuantity    types.Number `json:"spotHedgingQty"`
		Coin                   []struct {
			AvailableToBorrow       types.Number `json:"availableToBorrow"`
			Bonus                   types.Number `json:"bonus"`
			AccruedInterest         string       `json:"accruedInterest"`
			AvailableToWithdraw     types.Number `json:"availableToWithdraw"`
			AvailableBalanceForSpot types.Number `json:"free"`
			TotalOrderIM            string       `json:"totalOrderIM"`
			Equity                  types.Number `json:"equity"`
			TotalPositionMM         string       `json:"totalPositionMM"`
			USDValue                types.Number `json:"usdValue"`
			UnrealisedPnl           types.Number `json:"unrealisedPnl"`
			BorrowAmount            types.Number `json:"borrowAmount"`
			TotalPositionIM         string       `json:"totalPositionIM"`
			WalletBalance           types.Number `json:"walletBalance"`
			CumulativeRealisedPnl   types.Number `json:"cumRealisedPnl"`
			Coin                    string       `json:"coin"`
		} `json:"coin"`
	} `json:"list"`
}

WalletBalance represents wallet balance

type WalletType

type WalletType struct {
	Accounts []struct {
		UID         string   `json:"uid"`
		AccountType []string `json:"accountType"`
	} `json:"accounts"`
}

WalletType represents available wallet types for the master account or sub account

type WebsocketLiquidation

type WebsocketLiquidation struct {
	Symbol      string               `json:"symbol"`
	Side        string               `json:"side"`
	Price       types.Number         `json:"price"`
	Size        types.Number         `json:"size"`
	UpdatedTime convert.ExchangeTime `json:"updatedTime"`
}

WebsocketLiquidation represents liquidation stream push data.

type WebsocketPublicTrades

type WebsocketPublicTrades []struct {
	OrderFillTimestamp   convert.ExchangeTime `json:"T"`
	Symbol               string               `json:"s"`
	Side                 string               `json:"S"`
	Size                 types.Number         `json:"v"`
	Price                types.Number         `json:"p"`
	PriceChangeDirection string               `json:"L"`
	TradeID              string               `json:"i"`
	BlockTrade           bool                 `json:"BT"`
}

WebsocketPublicTrades represents

type WebsocketResponse

type WebsocketResponse struct {
	Topic         string               `json:"topic"`
	Type          string               `json:"type"`
	Timestamp     convert.ExchangeTime `json:"ts"`
	Data          json.RawMessage      `json:"data"`
	CrossSequence int64                `json:"cs"`

	// for ping messages
	Operation string `json:"op"`

	// for subscription response checks.
	RequestID string `json:"req_id"`
}

WebsocketResponse represents push data response struct.

type WebsocketWallet

type WebsocketWallet struct {
	ID           string               `json:"id"`
	Topic        string               `json:"topic"`
	CreationTime convert.ExchangeTime `json:"creationTime"`
	Data         []struct {
		AccountIMRate          types.Number `json:"accountIMRate"`
		AccountMMRate          types.Number `json:"accountMMRate"`
		TotalEquity            types.Number `json:"totalEquity"`
		TotalWalletBalance     types.Number `json:"totalWalletBalance"`
		TotalMarginBalance     types.Number `json:"totalMarginBalance"`
		TotalAvailableBalance  types.Number `json:"totalAvailableBalance"`
		TotalPerpUPL           types.Number `json:"totalPerpUPL"`
		TotalInitialMargin     types.Number `json:"totalInitialMargin"`
		TotalMaintenanceMargin types.Number `json:"totalMaintenanceMargin"`
		Coin                   []struct {
			Coin                string       `json:"coin"`
			Equity              types.Number `json:"equity"`
			UsdValue            types.Number `json:"usdValue"`
			WalletBalance       types.Number `json:"walletBalance"`
			AvailableToWithdraw types.Number `json:"availableToWithdraw"`
			AvailableToBorrow   types.Number `json:"availableToBorrow"`
			BorrowAmount        types.Number `json:"borrowAmount"`
			AccruedInterest     types.Number `json:"accruedInterest"`
			TotalOrderIM        types.Number `json:"totalOrderIM"`
			TotalPositionIM     types.Number `json:"totalPositionIM"`
			TotalPositionMM     types.Number `json:"totalPositionMM"`
			UnrealisedPnl       types.Number `json:"unrealisedPnl"`
			CumRealisedPnl      types.Number `json:"cumRealisedPnl"`
			Bonus               types.Number `json:"bonus"`
			SpotHedgingQuantity types.Number `json:"spotHedgingQty"`
		} `json:"coin"`
		AccountType string `json:"accountType"`
		AccountLTV  string `json:"accountLTV"`
	} `json:"data"`
}

WebsocketWallet represents a wallet stream to see changes to your wallet in real-time.

type WithdrawableAmount

type WithdrawableAmount struct {
	LimitAmountUsd     string `json:"limitAmountUsd"`
	WithdrawableAmount map[string]struct {
		Coin               string       `json:"coin"`
		WithdrawableAmount types.Number `json:"withdrawableAmount"`
		AvailableBalance   types.Number `json:"availableBalance"`
	} `json:"withdrawableAmount"`
}

WithdrawableAmount represents withdrawable amount information for each currency code

type WithdrawalParam

type WithdrawalParam struct {
	Coin        currency.Code `json:"coin,omitempty"`
	Chain       string        `json:"chain,omitempty"`
	Address     string        `json:"address,omitempty"`
	Tag         string        `json:"tag,omitempty"`
	Amount      float64       `json:"amount,omitempty,string"`
	Timestamp   int64         `json:"timestamp,omitempty"`
	ForceChain  int64         `json:"forceChain,omitempty"` // Whether or not to force an on-chain withdrawal '0'(default): If the address is parsed out to be an internal address, then internal transfer '1': Force the withdrawal to occur on-chain '2': Use UID to withdraw
	AccountType string        `json:"accountType,omitempty"`
}

WithdrawalParam represents asset withdrawal request parameter.

type WithdrawalRecords

type WithdrawalRecords struct {
	Rows []struct {
		Coin          string               `json:"coin"`
		Chain         string               `json:"chain"`
		Amount        types.Number         `json:"amount"`
		TransactionID string               `json:"txID"`
		Status        string               `json:"status"`
		ToAddress     string               `json:"toAddress"`
		Tag           string               `json:"tag"`
		WithdrawFee   types.Number         `json:"withdrawFee"`
		CreateTime    convert.ExchangeTime `json:"createTime"`
		UpdateTime    convert.ExchangeTime `json:"updateTime"`
		WithdrawID    string               `json:"withdrawId"`
		WithdrawType  int64                `json:"withdrawType"`
	} `json:"rows"`
	NextPageCursor string `json:"nextPageCursor"`
}

WithdrawalRecords represents a list of withdrawal records.

type WsExecutions

type WsExecutions []struct {
	Category        string               `json:"category"`
	Symbol          string               `json:"symbol"`
	ExecFee         types.Number         `json:"execFee"`
	ExecID          string               `json:"execId"`
	ExecPrice       types.Number         `json:"execPrice"`
	ExecQty         types.Number         `json:"execQty"`
	ExecType        string               `json:"execType"`
	ExecValue       types.Number         `json:"execValue"`
	IsMaker         bool                 `json:"isMaker"`
	FeeRate         string               `json:"feeRate"`
	TradeIv         string               `json:"tradeIv"`
	MarkIv          string               `json:"markIv"`
	BlockTradeID    string               `json:"blockTradeId"`
	MarkPrice       types.Number         `json:"markPrice"`
	IndexPrice      types.Number         `json:"indexPrice"`
	UnderlyingPrice types.Number         `json:"underlyingPrice"`
	LeavesQty       types.Number         `json:"leavesQty"`
	OrderID         string               `json:"orderId"`
	OrderLinkID     string               `json:"orderLinkId"`
	OrderPrice      types.Number         `json:"orderPrice"`
	OrderQty        types.Number         `json:"orderQty"`
	OrderType       string               `json:"orderType"`
	StopOrderType   string               `json:"stopOrderType"`
	Side            string               `json:"side"`
	ExecTime        convert.ExchangeTime `json:"execTime"`
	IsLeverage      types.Number         `json:"isLeverage"`
	ClosedSize      types.Number         `json:"closedSize"`
}

WsExecutions represents execution stream to see your executions in real-time.

type WsKlines

type WsKlines []struct {
	Confirm   bool                 `json:"confirm"`
	Start     convert.ExchangeTime `json:"start"`
	End       convert.ExchangeTime `json:"end"`
	Open      types.Number         `json:"open"`
	Close     types.Number         `json:"close"`
	High      types.Number         `json:"high"`
	Low       types.Number         `json:"low"`
	Volume    types.Number         `json:"volume"`
	Turnover  string               `json:"turnover"`
	Interval  string               `json:"interval"`
	Timestamp convert.ExchangeTime `json:"timestamp"`
}

WsKlines represents a list of Kline data.

type WsLinearTicker

type WsLinearTicker struct {
	Symbol            string               `json:"symbol"`
	TickDirection     string               `json:"tickDirection"`
	Price24HPcnt      types.Number         `json:"price24hPcnt"`
	LastPrice         types.Number         `json:"lastPrice"`
	PrevPrice24H      types.Number         `json:"prevPrice24h"`
	HighPrice24H      types.Number         `json:"highPrice24h"`
	LowPrice24H       types.Number         `json:"lowPrice24h"`
	PrevPrice1H       types.Number         `json:"prevPrice1h"`
	MarkPrice         types.Number         `json:"markPrice"`
	IndexPrice        types.Number         `json:"indexPrice"`
	OpenInterest      types.Number         `json:"openInterest"`
	OpenInterestValue types.Number         `json:"openInterestValue"`
	Turnover24H       types.Number         `json:"turnover24h"`
	Volume24H         types.Number         `json:"volume24h"`
	NextFundingTime   convert.ExchangeTime `json:"nextFundingTime"`
	FundingRate       types.Number         `json:"fundingRate"`
	Bid1Price         types.Number         `json:"bid1Price"`
	Bid1Size          types.Number         `json:"bid1Size"`
	Ask1Price         types.Number         `json:"ask1Price"`
	Ask1Size          types.Number         `json:"ask1Size"`
}

WsLinearTicker represents a linear ticker information.

type WsOptionTicker

type WsOptionTicker struct {
	Symbol                 string       `json:"symbol"`
	BidPrice               types.Number `json:"bidPrice"`
	BidSize                types.Number `json:"bidSize"`
	BidIv                  types.Number `json:"bidIv"`
	AskPrice               types.Number `json:"askPrice"`
	AskSize                types.Number `json:"askSize"`
	AskIv                  types.Number `json:"askIv"`
	LastPrice              types.Number `json:"lastPrice"`
	HighPrice24H           types.Number `json:"highPrice24h"`
	LowPrice24H            types.Number `json:"lowPrice24h"`
	MarkPrice              types.Number `json:"markPrice"`
	IndexPrice             types.Number `json:"indexPrice"`
	MarkPriceIv            types.Number `json:"markPriceIv"`
	UnderlyingPrice        types.Number `json:"underlyingPrice"`
	OpenInterest           types.Number `json:"openInterest"`
	Turnover24H            types.Number `json:"turnover24h"`
	Volume24H              types.Number `json:"volume24h"`
	TotalVolume            types.Number `json:"totalVolume"`
	TotalTurnover          types.Number `json:"totalTurnover"`
	Delta                  types.Number `json:"delta"`
	Gamma                  types.Number `json:"gamma"`
	Vega                   types.Number `json:"vega"`
	Theta                  types.Number `json:"theta"`
	PredictedDeliveryPrice types.Number `json:"predictedDeliveryPrice"`
	Change24H              types.Number `json:"change24h"`
}

WsOptionTicker represents options public ticker data.

type WsOrderbookDetail

type WsOrderbookDetail struct {
	Symbol   string     `json:"s"`
	Bids     [][]string `json:"b"`
	Asks     [][]string `json:"a"`
	UpdateID int64      `json:"u"`
	Sequence int64      `json:"seq"`
}

WsOrderbookDetail represents an orderbook detail information.

type WsOrders

type WsOrders []struct {
	Symbol             string               `json:"symbol"`
	OrderID            string               `json:"orderId"`
	Side               string               `json:"side"`
	OrderType          string               `json:"orderType"`
	CancelType         string               `json:"cancelType"`
	Price              types.Number         `json:"price"`
	Qty                types.Number         `json:"qty"`
	OrderIv            string               `json:"orderIv"`
	TimeInForce        string               `json:"timeInForce"`
	OrderStatus        string               `json:"orderStatus"`
	OrderLinkID        string               `json:"orderLinkId"`
	LastPriceOnCreated string               `json:"lastPriceOnCreated"`
	ReduceOnly         bool                 `json:"reduceOnly"`
	LeavesQty          types.Number         `json:"leavesQty"`
	LeavesValue        types.Number         `json:"leavesValue"`
	CumExecQty         types.Number         `json:"cumExecQty"`
	CumExecValue       types.Number         `json:"cumExecValue"`
	AvgPrice           types.Number         `json:"avgPrice"`
	BlockTradeID       string               `json:"blockTradeId"`
	PositionIdx        int64                `json:"positionIdx"`
	CumExecFee         types.Number         `json:"cumExecFee"`
	CreatedTime        convert.ExchangeTime `json:"createdTime"`
	UpdatedTime        convert.ExchangeTime `json:"updatedTime"`
	RejectReason       string               `json:"rejectReason"`
	StopOrderType      string               `json:"stopOrderType"`
	TpslMode           string               `json:"tpslMode"`
	TriggerPrice       types.Number         `json:"triggerPrice"`
	TakeProfit         types.Number         `json:"takeProfit"`
	StopLoss           types.Number         `json:"stopLoss"`
	TpTriggerBy        types.Number         `json:"tpTriggerBy"`
	SlTriggerBy        types.Number         `json:"slTriggerBy"`
	TpLimitPrice       types.Number         `json:"tpLimitPrice"`
	SlLimitPrice       types.Number         `json:"slLimitPrice"`
	TriggerDirection   int64                `json:"triggerDirection"`
	TriggerBy          string               `json:"triggerBy"`
	CloseOnTrigger     bool                 `json:"closeOnTrigger"`
	Category           string               `json:"category"`
	PlaceType          string               `json:"placeType"`
	SmpType            string               `json:"smpType"` // SMP execution type
	SmpGroup           int64                `json:"smpGroup"`
	SmpOrderID         string               `json:"smpOrderId"`

	// UTA Spot: add new response field ocoTriggerBy, and the value can be
	// OcoTriggerByUnknown, OcoTriggerByTp, OcoTriggerBySl
	OCOTriggerBy string `json:"ocoTriggerBy"`
}

WsOrders represents private order

type WsPositions

type WsPositions []struct {
	PositionIdx      int64                `json:"positionIdx"`
	TradeMode        int64                `json:"tradeMode"`
	RiskID           int64                `json:"riskId"`
	RiskLimitValue   types.Number         `json:"riskLimitValue"`
	Symbol           string               `json:"symbol"`
	Side             string               `json:"side"`
	Size             types.Number         `json:"size"`
	EntryPrice       types.Number         `json:"entryPrice"`
	Leverage         types.Number         `json:"leverage"`
	PositionValue    types.Number         `json:"positionValue"`
	PositionBalance  types.Number         `json:"positionBalance"`
	MarkPrice        types.Number         `json:"markPrice"`
	PositionIM       types.Number         `json:"positionIM"`
	PositionMM       types.Number         `json:"positionMM"`
	TakeProfit       types.Number         `json:"takeProfit"`
	StopLoss         types.Number         `json:"stopLoss"`
	TrailingStop     types.Number         `json:"trailingStop"`
	UnrealisedPnl    types.Number         `json:"unrealisedPnl"`
	CumRealisedPnl   types.Number         `json:"cumRealisedPnl"`
	CreatedTime      convert.ExchangeTime `json:"createdTime"`
	UpdatedTime      convert.ExchangeTime `json:"updatedTime"`
	TpslMode         string               `json:"tpslMode"`
	LiqPrice         types.Number         `json:"liqPrice"`
	BustPrice        types.Number         `json:"bustPrice"`
	Category         string               `json:"category"`
	PositionStatus   string               `json:"positionStatus"`
	AdlRankIndicator int64                `json:"adlRankIndicator"`
}

WsPositions represents a position information.

type WsSpotTicker

type WsSpotTicker struct {
	Symbol        string       `json:"symbol"`
	LastPrice     types.Number `json:"lastPrice"`
	HighPrice24H  types.Number `json:"highPrice24h"`
	LowPrice24H   types.Number `json:"lowPrice24h"`
	PrevPrice24H  types.Number `json:"prevPrice24h"`
	Volume24H     types.Number `json:"volume24h"`
	Turnover24H   types.Number `json:"turnover24h"`
	Price24HPcnt  types.Number `json:"price24hPcnt"`
	UsdIndexPrice types.Number `json:"usdIndexPrice"`
}

WsSpotTicker represents a spot public ticker information.

Jump to

Keyboard shortcuts

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