binance

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 34 Imported by: 0

README

GoCryptoTrader package Binance

Build Status Software License GoDoc Coverage Status Go Report Card

This binance 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

Binance 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() == "Binance" {
		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

View Source
const (
	// PositionMarginTypeAdd 增加逐仓保证金
	PositionMarginTypeAdd = PositionMarginType(1)
	// PositionMarginTypeSub 减少逐仓保证金
	PositionMarginTypeSub = PositionMarginType(2)
)
View Source
const (
	// MarginType_ISOLATED 逐仓
	MarginType_ISOLATED = MarginType("ISOLATED")
	// MarginType_CROSSED 全仓
	MarginType_CROSSED = MarginType("CROSSED")
)
View Source
const (
	WorkingType_MARK_PRICE     = WorkingType("MARK_PRICE")
	WorkingType_CONTRACT_PRICE = WorkingType("CONTRACT_PRICE")
)
View Source
const (
	IncomeType_TRANSFER        = IncomeType("TRANSFER")
	IncomeType_WELCOME_BONUS   = IncomeType("WELCOME_BONUS")
	IncomeType_REALIZED_PNL    = IncomeType("REALIZED_PNL")
	IncomeType_FUNDING_FEE     = IncomeType("FUNDING_FEE")
	IncomeType_COMMISSION      = IncomeType("COMMISSION")
	IncomeType_INSURANCE_CLEAR = IncomeType("INSURANCE_CLEAR")
	IncomeType_ALL             = IncomeType("")
)
View Source
const (
	//MAIN_C2C 现货钱包转向C2C钱包
	TransferType_MAIN_C2C = TransferType("MAIN_C2C")
	//MAIN_UMFUTURE 现货钱包转向U本位合约钱包
	TransferType_MAIN_UMFUTURE = TransferType("MAIN_UMFUTURE")
	//MAIN_CMFUTURE 现货钱包转向币本位合约钱包
	TransferType_MAIN_CMFUTURE = TransferType("MAIN_CMFUTURE")
	//MAIN_MARGIN 现货钱包转向杠杆全仓钱包
	TransferType_MAIN_MARGIN = TransferType("MAIN_MARGIN")
	//MAIN_MINING 现货钱包转向矿池钱包
	TransferType_MAIN_MINING = TransferType("MAIN_MINING")
	//C2C_MAIN C2C钱包转向现货钱包
	TransferType_C2C_MAIN = TransferType("C2C_MAIN")
	//C2C_UMFUTURE C2C钱包转向U本位合约钱包
	TransferType_C2C_UMFUTURE = TransferType("C2C_UMFUTURE")
	//C2C_MINING C2C钱包转向矿池钱包
	TransferType_C2C_MINING = TransferType("C2C_MINING")
	//UMFUTURE_MAIN U本位合约钱包转向现货钱包
	TransferType_UMFUTURE_MAIN = TransferType("UMFUTURE_MAIN")
	//UMFUTURE_C2C U本位合约钱包转向C2C钱包
	TransferType_UMFUTURE_C2C = TransferType("UMFUTURE_C2C")
	//UMFUTURE_MARGIN U本位合约钱包转向杠杆全仓钱包
	TransferType_UMFUTURE_MARGIN = TransferType("UMFUTURE_MARGIN")
	//CMFUTURE_MAIN 币本位合约钱包转向现货钱包
	TransferType_CMFUTURE_MAIN = TransferType("CMFUTURE_MAIN")
	//MARGIN_MAIN 杠杆全仓钱包转向现货钱包
	TransferType_MARGIN_MAIN = TransferType("MARGIN_MAIN")
	//MARGIN_UMFUTURE 杠杆全仓钱包转向U本位合约钱包
	TransferType_MARGIN_UMFUTURE = TransferType("MARGIN_UMFUTURE")
	//MINING_MAIN 矿池钱包转向现货钱包
	TransferType_MINING_MAIN = TransferType("MINING_MAIN")
	//TransferType_MINING_UMFUTURE MINING_UMFUTURE 矿池钱包转向U本位合约钱包
	TransferType_MINING_UMFUTURE = TransferType("MINING_UMFUTURE")
	// TransferType_MINING_C2CMINING_C2C 矿池钱包转向C2C钱包
	TransferType_MINING_C2C = TransferType("MINING_C2C")
)
View Source
const (
	// PositionSideBOTH 单一持仓方向
	PositionSideBOTH = PositionSide("BOTH")
	// PositionSideLONG 多头(双向持仓下)
	PositionSideLONG = PositionSide("LONG")
	// PositionSideSHORT 空头(双向持仓下)
	PositionSideSHORT = PositionSide("SHORT")
)
View Source
const (
	// ContractTypePERPETUAL 永续合约
	ContractTypePERPETUAL = ContractType("PERPETUAL")
	// ContractTypeCURRENT_MONTH 当月交割合约
	ContractTypeCURRENT_MONTH = ContractType("CURRENT_MONTH")
	// PositionSideSHORT 次月交割合约
	ContractTypeNEXT_MONTH = ContractType("NEXT_MONTH")
)
View Source
const (
	EmailSent = iota
	Cancelled
	AwaitingApproval
	Rejected
	Processing
	Failure
	Completed
)

withdrawals status codes description

Variables

View Source
var (
	// BinanceRequestParamsTimeGTC GTC
	BinanceRequestParamsTimeGTC = RequestParamsTimeForceType("GTC")

	// BinanceRequestParamsTimeIOC IOC
	BinanceRequestParamsTimeIOC = RequestParamsTimeForceType("IOC")

	// BinanceRequestParamsTimeFOK FOK
	BinanceRequestParamsTimeFOK = RequestParamsTimeForceType("FOK")
)
View Source
var (
	// BinanceRequestParamsOrderLimit Limit order
	BinanceRequestParamsOrderLimit = RequestParamsOrderType("LIMIT")

	// BinanceRequestParamsOrderMarket Market order
	BinanceRequestParamsOrderMarket = RequestParamsOrderType("MARKET")

	// BinanceRequestParamsOrderStopLoss STOP_LOSS
	BinanceRequestParamsOrderStopLoss = RequestParamsOrderType("STOP_LOSS")

	// BinanceRequestParamsOrderStopLossLimit STOP_LOSS_LIMIT
	BinanceRequestParamsOrderStopLossLimit = RequestParamsOrderType("STOP_LOSS_LIMIT")

	// BinanceRequestParamsOrderTakeProfit TAKE_PROFIT
	BinanceRequestParamsOrderTakeProfit = RequestParamsOrderType("TAKE_PROFIT")

	// BinanceRequestParamsOrderTakeProfitLimit TAKE_PROFIT_LIMIT
	BinanceRequestParamsOrderTakeProfitLimit = RequestParamsOrderType("TAKE_PROFIT_LIMIT")

	// BinanceRequestParamsOrderLimitMarker LIMIT_MAKER
	BinanceRequestParamsOrderLimitMarker = RequestParamsOrderType("LIMIT_MAKER")
)
View Source
var WithdrawalFees = map[currency.Code]float64{}/* 164 elements not displayed */

WithdrawalFees the large list of predefined withdrawal fees Prone to change

Functions

This section is empty.

Types

type ADLEstimateData

type ADLEstimateData struct {
	Symbol      string `json:"symbol"`
	ADLQuantile struct {
		Long  float64 `json:"LONG"`
		Short float64 `json:"SHORT"`
		Hedge float64 `json:"HEDGE"`
	} `json:"adlQuantile"`
}

ADLEstimateData stores data for ADL estimates

type Account

type Account struct {
	MakerCommission  int       `json:"makerCommission"`
	TakerCommission  int       `json:"takerCommission"`
	BuyerCommission  int       `json:"buyerCommission"`
	SellerCommission int       `json:"sellerCommission"`
	CanTrade         bool      `json:"canTrade"`
	CanWithdraw      bool      `json:"canWithdraw"`
	CanDeposit       bool      `json:"canDeposit"`
	UpdateTime       time.Time `json:"updateTime"`
	Balances         []Balance `json:"balances"`
}

Account holds the account data

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type AccountInfoFuture

type AccountInfoFuture struct {
	FeeTier                     int     `json:"feeTier"`                            // 手续费等级
	CanTrade                    bool    `json:"canTrade"`                           // 是否可以交易
	CanDeposit                  bool    `json:"canDeposit"`                         // 是否可以入金
	CanWithdraw                 bool    `json:"canWithdraw"`                        // 是否可以出金
	UpdateTime                  int64   `json:"updateTime"`                         // 现货指数价格
	TotalInitialMargin          float64 `json:"totalInitialMargin,string"`          // 但前所需起始保证金总额(存在逐仓请忽略), 仅计算usdt资产
	TotalMaintMargin            float64 `json:"totalMaintMargin,string"`            // 维持保证金总额, 仅计算usdt资产
	TotalWalletBalance          float64 `json:"totalWalletBalance,string"`          // 账户总余额, 仅计算usdt资产
	TotalUnrealizedProfit       float64 `json:"totalUnrealizedProfit,string"`       // 持仓未实现盈亏总额, 仅计算usdt资产
	TotalMarginBalance          float64 `json:"totalMarginBalance,string"`          // 保证金总余额, 仅计算usdt资产
	TotalPositionInitialMargin  float64 `json:"totalPositionInitialMargin,string"`  // 持仓所需起始保证金(基于最新标记价格), 仅计算usdt资产
	TotalOpenOrderInitialMargin float64 `json:"totalOpenOrderInitialMargin,string"` // 当前挂单所需起始保证金(基于最新标记价格), 仅计算usdt资产
	TotalCrossWalletBalance     float64 `json:"totalCrossWalletBalance,string"`     // 全仓账户余额, 仅计算usdt资产
	AvailableBalance            float64 `json:"availableBalance,string"`            // 可用余额, 仅计算usdt资产
	MaxWithdrawAmount           float64 `json:"maxWithdrawAmount,string"`           // 最大可转出余额, 仅计算usdt资产
	Assets                      []struct {
		Asset                  string  `json:"asset"`                         //资产
		WalletBalance          float64 `json:"walletBalance,string"`          //余额
		UnrealizedProfit       float64 `json:"unrealizedProfit,string"`       // 未实现盈亏
		MarginBalance          float64 `json:"marginBalance,string"`          // 保证金余额
		MaintMargin            float64 `json:"maintMargin,string"`            // 维持保证金
		InitialMargin          float64 `json:"initialMargin,string"`          // 当前所需起始保证金
		PositionInitialMargin  float64 `json:"positionInitialMargin,string"`  // 持仓所需起始保证金(基于最新标记价格)
		PpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"` // 当前挂单所需起始保证金(基于最新标记价格)
		CrossWalletBalance     float64 `json:"crossWalletBalance,string"`     //全仓账户余额
		CrossUnPnl             float64 `json:"crossUnPnl,string"`             // 全仓持仓未实现盈亏
		AvailableBalance       float64 `json:"availableBalance,string"`       // 可用余额
		MaxWithdrawAmount      float64 `json:"maxWithdrawAmount,string"`      // 最大可转出余额
	} `json:"assets"`
	Positions []struct {
		Symbol                 string       `json:"symbol"`                        // 交易对
		InitialMargin          float64      `json:"initialMargin,string"`          // 当前所需起始保证金(基于最新标记价格)
		MaintMargin            float64      `json:"maintMargin,string"`            //维持保证金
		UnrealizedProfit       float64      `json:"unrealizedProfit,string"`       // 持仓未实现盈亏
		PositionInitialMargin  float64      `json:"positionInitialMargin,string"`  // 持仓所需起始保证金(基于最新标记价格)
		OpenOrderInitialMargin float64      `json:"openOrderInitialMargin,string"` // 当前挂单所需起始保证金(基于最新标记价格)
		Leverage               float64      `json:"leverage,string"`               // 杠杆倍率
		Isolated               bool         `json:"isolated"`                      // 是否是逐仓模式
		EntryPrice             float64      `json:"entryPrice,string"`             // 持仓成本价
		MaxNotional            float64      `json:"maxNotional,string"`            // 当前杠杆下用户可用的最大名义价值
		PositionSide           PositionSide `json:"positionSide"`                  // 持仓方向
		PositionAmt            float64      `json:"positionAmt,string"`            // 仓位
	} `json:"positions"` // 头寸,将返回所有市场symbol
}

AccountInfoFuture U本位合约 账户信息V2 (

type AccountSnapshotRequest

type AccountSnapshotRequest struct {
	Type      asset.Item `json:"type"`
	Price     float64    `json:"price"`
	Limit     int64      `json:"limit"`
	StartTime int64      `json:"startTime"`
	EndTime   int64      `json:"endTime"`
}

AccountSnapshotRequest 查询每日资产快照 (USER_DATA)

type AccountSnapshotResponse

type AccountSnapshotResponse struct {
	TotalAssetOfBtc float64    `json:"totalAssetOfBtc"`
	Asset           asset.Item `json:"asset"`
	Symbol          string     `json:"symbol"`
	Free            float64    `json:"free"`
	Locked          float64    `json:"locked"`
	UpdateTime      time.Time  `json:"updateTime"`
}

AccountSnapshotResponse 查询每日资产快照 (USER_DATA) - 返回信息

type AccountUpdateEventBalance

type AccountUpdateEventBalance struct {
	Asset         string  `json:"a"`         // 资产名称
	WalletBalance float64 `json:"wb,string"` // 钱包余额
	RealyBalance  float64 `json:"cw,string"` // 除去逐仓仓位保证金的钱包余额
}

type AccountUpdateEventPosition

type AccountUpdateEventPosition struct {
	Symbol                currency.Pair `json:"s"`         // 交易对
	PositionAmt           float64       `json:"pa,string"` // 仓位
	EntryPrice            float64       `json:"ep,string"` // 入仓价格
	RealizedProfitAndLoss float64       `json:"cr,string"` // (费前)累计实现损益
	UnRealizedProfit      float64       `json:"up,string"` // 持仓未实现盈亏
	MarginType            MarginType    `json:"mt"`        // 保证金模式
	IsolatedMargin        float64       `json:"iw,string"` // 若为逐仓,仓位保证金
	PositionSide          PositionSide  `json:"ps"`        // 若为逐仓,仓位保证金
}

type AccountUpdateStream

type AccountUpdateStream struct {
	EventType          string `json:"e"` // 事件类型
	EventTime          int64  `json:"E"` // 事件时间
	TimeStamp          int64  `json:"T"` // 撮合时间
	AccountUpdateEvent struct {
		EventCause string `json:"m"` // 事件推出原因
		Balance    []struct {
			Asset         string  `json:"a"`         // 资产名称
			WalletBalance float64 `json:"wb,string"` // 钱包余额
			RealyBalance  float64 `json:"cw,string"` // 除去逐仓仓位保证金的钱包余额
		} `json:"B"` // 余额信息
		Position []struct {
			Symbol                string  `json:"s"`         // 交易对
			PositionAmt           float64 `json:"pa,string"` // 仓位
			EntryPrice            float64 `json:"ep,string"` // 入仓价格
			RealizedProfitAndLoss float64 `json:"cr,string"` // (费前)累计实现损益
			UnRealizedProfit      float64 `json:"up,string"` // 持仓未实现盈亏
			MarginType            string  `json:"mt"`        // 保证金模式
			IsolatedMargin        float64 `json:"iw,string"` // 若为逐仓,仓位保证金
			PositionSide          string  `json:"ps"`        // 若为逐仓,仓位保证金
		} `json:"P"` // 持仓信息
	} `json:"a"` // 账户更新事件
}

AccountUpdateStream holds the ticker stream data

type AccountUpdateStreamResponse

type AccountUpdateStreamResponse struct {
	EventType string    `json:"e"` // 事件类型
	EventTime time.Time `json:"E"` // 事件时间
	TimeStamp time.Time `json:"T"` // 撮合时间

	AssetType          asset.Item
	Exchange           string
	AccountUpdateEvent struct {
		EventCause string                       // 事件推出原因
		Balance    []AccountUpdateEventBalance  // 余额信息
		Position   []AccountUpdateEventPosition // 持仓信息
	} // 账户更新事件
}

type AdlQuantileResponse

type AdlQuantileResponse struct {
	Symbol      string `json:"symbol"`
	AdlQuantile struct {
		LONG  float64 `json:"LONG"`
		SHORT float64 `json:"SHORT"`
		HEDGE float64 `json:"HEDGE"`
		BOTH  float64 `json:"BOTH"`
	} `json:"adlQuantile"`
}

AdlQuantileResponse 持仓ADL队列估算 (USER_DATA)

type AggregatedTrade

type AggregatedTrade struct {
	ATradeID       int64     `json:"a"`
	Price          float64   `json:"p,string"`
	Quantity       float64   `json:"q,string"`
	FirstTradeID   int64     `json:"f"`
	LastTradeID    int64     `json:"l"`
	TimeStamp      time.Time `json:"T"`
	Maker          bool      `json:"m"`
	BestMatchPrice bool      `json:"M"`
}

AggregatedTrade holds aggregated trade information

func (*AggregatedTrade) UnmarshalJSON

func (a *AggregatedTrade) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type AggregatedTradeRequestParams

type AggregatedTradeRequestParams struct {
	Symbol currency.Pair // Required field; example LTCBTC, BTCUSDT
	// The first trade to retrieve
	FromID int64
	// The API seems to accept (start and end time) or FromID and no other combinations
	StartTime time.Time
	EndTime   time.Time
	// Default 500; max 1000.
	Limit int
}

AggregatedTradeRequestParams holds request params

type AllLiquidationOrders

type AllLiquidationOrders struct {
	Symbol       string  `json:"symbol"`
	Price        float64 `json:"price,string"`
	OrigQty      float64 `json:"origQty,string"`
	ExecutedQty  float64 `json:"executedQty,string"`
	AveragePrice float64 `json:"averagePrice,string"`
	Status       string  `json:"status"`
	TimeInForce  string  `json:"timeInForce"`
	OrderType    string  `json:"type"`
	Side         string  `json:"side"`
	Time         int64   `json:"time"`
}

AllLiquidationOrders gets all liquidation orders

type AutoCancelAllOrdersData

type AutoCancelAllOrdersData struct {
	Symbol        string `json:"symbol"`
	CountdownTime int64  `json:"countdownTime,string"`
}

AutoCancelAllOrdersData gives data of auto cancelling all open orders

type AveragePrice

type AveragePrice struct {
	Mins  int64   `json:"mins"`
	Price float64 `json:"price,string"`
}

AveragePrice holds current average symbol price

type Balance

type Balance struct {
	Asset  string `json:"asset"`
	Free   string `json:"free"`
	Locked string `json:"locked"`
}

Balance holds query order data

type BatchCancelOrderData

type BatchCancelOrderData struct {
	ClientOrderID string  `json:"clientOrderID"`
	CumQty        float64 `json:"cumQty,string"`
	CumBase       float64 `json:"cumBase,string"`
	ExecuteQty    float64 `json:"executeQty,string"`
	OrderID       int64   `json:"orderID,string"`
	AvgPrice      float64 `json:"avgPrice,string"`
	OrigQty       float64 `json:"origQty,string"`
	Price         float64 `json:"price,string"`
	ReduceOnly    bool    `json:"reduceOnly"`
	Side          string  `json:"side"`
	PositionSide  string  `json:"positionSide"`
	Status        string  `json:"status"`
	StopPrice     int64   `json:"stopPrice"`
	ClosePosition bool    `json:"closePosition"`
	Symbol        string  `json:"symbol"`
	Pair          string  `json:"pair"`
	TimeInForce   string  `json:"TimeInForce"`
	OrderType     string  `json:"type"`
	OrigType      string  `json:"origType"`
	ActivatePrice float64 `json:"activatePrice,string"`
	PriceRate     float64 `json:"priceRate,string"`
	UpdateTime    int64   `json:"updateTime"`
	WorkingType   string  `json:"workingType"`
	PriceProtect  bool    `json:"priceProtect"`
	Code          int64   `json:"code"`
	Msg           string  `json:"msg"`
}

BatchCancelOrderData stores batch cancel order data

type BestPrice

type BestPrice struct {
	Symbol   string  `json:"symbol"`
	BidPrice float64 `json:"bidPrice,string"`
	BidQty   float64 `json:"bidQty,string"`
	AskPrice float64 `json:"askPrice,string"`
	AskQty   float64 `json:"askQty,string"`
}

BestPrice holds best price data

type Binance

type Binance struct {
	exchange.Base

	UFuturesWebsocket *stream.Websocket
	CFuturesWebsocket *stream.Websocket
	// contains filtered or unexported fields
}

Binance is the overarching type across the Binance package

func (*Binance) AllOrders

func (b *Binance) AllOrders(ctx context.Context, symbol currency.Pair, orderID, limit string) ([]QueryOrderData, error)

AllOrders Get all account orders; active, canceled, or filled. orderId optional param limit optional param, default 500; max 500

func (*Binance) AutoCancelAllOpenOrders

func (b *Binance) AutoCancelAllOpenOrders(ctx context.Context, symbol currency.Pair, countdownTime int64) (AutoCancelAllOrdersData, error)

AutoCancelAllOpenOrders cancels all open futures orders countdownTime 1000 = 1s, example - to cancel all orders after 30s (countdownTime: 30000)

func (*Binance) CancelAllOrders

func (b *Binance) CancelAllOrders(ctx context.Context, req *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*Binance) CancelBatchOrders

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

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*Binance) CancelExistingOrder

func (b *Binance) CancelExistingOrder(ctx context.Context, symbol currency.Pair, orderID int64, origClientOrderID string) (CancelOrderResponse, error)

CancelExistingOrder sends a cancel order to Binance

func (*Binance) CancelOrder

func (b *Binance) CancelOrder(ctx context.Context, o *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*Binance) CheckLimit

func (b *Binance) CheckLimit(limit int) error

CheckLimit checks value against a variable list

func (*Binance) DepositHistory

func (b *Binance) DepositHistory(ctx context.Context, c currency.Code, status string, startTime, endTime time.Time, offset, limit int) ([]DepositHistory, error)

DepositHistory returns the deposit history based on the supplied params status `param` used as string to prevent default value 0 (for int) interpreting as EmailSent status

func (*Binance) Dual

func (b *Binance) Dual(ctx context.Context, assetType asset.Item, dualSide bool) (flag bool, err error)

Dual 更改持仓模式(TRADE) 变换用户在 所有symbol 合约上的持仓模式:双向持仓或单向持仓。"true": 双向持仓模式;"false": 单向持仓模式

func (*Binance) DualQuery

func (b *Binance) DualQuery(ctx context.Context, assetType asset.Item) (flag bool, err error)

DualQuery 查询持仓模式(USER_DATA) "true": 双向持仓模式;"false": 单向持仓模式

func (*Binance) FetchAccountInfo

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

FetchAccountInfo retrieves balances for all enabled currencies

func (*Binance) FetchCoinMarginExchangeLimits

func (b *Binance) FetchCoinMarginExchangeLimits(ctx context.Context) ([]order.MinMaxLevel, error)

FetchCoinMarginExchangeLimits fetches coin margined order execution limits

func (*Binance) FetchOrderbook

func (b *Binance) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*Binance) FetchSpotExchangeLimits

func (b *Binance) FetchSpotExchangeLimits(ctx context.Context) ([]order.MinMaxLevel, error)

FetchSpotExchangeLimits fetches spot order execution limits

func (*Binance) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*Binance) FetchTradablePairs

func (b *Binance) FetchTradablePairs(ctx context.Context, a asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*Binance) FetchUSDTMarginExchangeLimits

func (b *Binance) FetchUSDTMarginExchangeLimits(ctx context.Context) ([]order.MinMaxLevel, error)

FetchUSDTMarginExchangeLimits fetches USDT margined order execution limits

func (*Binance) FormatExchangeCurrency

func (b *Binance) FormatExchangeCurrency(p currency.Pair, a asset.Item) (currency.Pair, error)

FormatExchangeCurrency is a method that formats and returns a currency pair based on the user currency display preferences overrides default implementation to use optional delimiter

func (*Binance) FormatExchangeKlineInterval

func (b *Binance) FormatExchangeKlineInterval(interval kline.Interval) string

FormatExchangeKlineInterval returns Interval to exchange formatted string

func (*Binance) FormatSymbol

func (b *Binance) FormatSymbol(p currency.Pair, a asset.Item) (string, error)

FormatSymbol formats the given pair to a string suitable for exchange API requests overrides default implementation to use optional delimiter

func (*Binance) FuturesBatchCancelOrders

func (b *Binance) FuturesBatchCancelOrders(ctx context.Context, symbol currency.Pair, orderList, origClientOrderIDList []string) ([]BatchCancelOrderData, error)

FuturesBatchCancelOrders sends a batch request to cancel orders

func (*Binance) FuturesBatchOrder

func (b *Binance) FuturesBatchOrder(ctx context.Context, data []PlaceBatchOrderData) ([]FuturesOrderPlaceData, error)

FuturesBatchOrder sends a batch order request

func (*Binance) FuturesCancelAllOpenOrders

func (b *Binance) FuturesCancelAllOpenOrders(ctx context.Context, symbol currency.Pair) (GenericAuthResponse, error)

FuturesCancelAllOpenOrders cancels a futures order

func (*Binance) FuturesCancelOrder

func (b *Binance) FuturesCancelOrder(ctx context.Context, symbol currency.Pair, orderID, origClientOrderID string) (FuturesOrderGetData, error)

FuturesCancelOrder cancels a futures order

func (*Binance) FuturesChangeInitialLeverage

func (b *Binance) FuturesChangeInitialLeverage(ctx context.Context, symbol currency.Pair, leverage int64) (FuturesLeverageData, error)

FuturesChangeInitialLeverage changes initial leverage for the account

func (*Binance) FuturesChangeMarginType

func (b *Binance) FuturesChangeMarginType(ctx context.Context, symbol currency.Pair, marginType string) (GenericAuthResponse, error)

FuturesChangeMarginType changes margin type

func (*Binance) FuturesExchangeInfo

func (b *Binance) FuturesExchangeInfo(ctx context.Context) (CExchangeInfo, error)

FuturesExchangeInfo stores CoinMarginedFutures, data

func (*Binance) FuturesForceOrders

func (b *Binance) FuturesForceOrders(ctx context.Context, symbol currency.Pair, autoCloseType string, startTime, endTime time.Time) ([]ForcedOrdersData, error)

FuturesForceOrders gets futures forced orders

func (*Binance) FuturesGetFundingHistory

func (b *Binance) FuturesGetFundingHistory(ctx context.Context, symbol currency.Pair, limit int64, startTime, endTime time.Time) ([]FundingRateHistory, error)

FuturesGetFundingHistory gets funding history for CoinMarginedFutures,

func (*Binance) FuturesGetOrderData

func (b *Binance) FuturesGetOrderData(ctx context.Context, symbol currency.Pair, orderID, origClientOrderID string) (FuturesOrderGetData, error)

FuturesGetOrderData gets futures order data

func (*Binance) FuturesIncomeHistory

func (b *Binance) FuturesIncomeHistory(ctx context.Context, symbol currency.Pair, incomeType string, startTime, endTime time.Time, limit int64) ([]FuturesIncomeHistoryData, error)

FuturesIncomeHistory gets income history for CoinMarginedFutures,

func (*Binance) FuturesMarginChangeHistory

func (b *Binance) FuturesMarginChangeHistory(ctx context.Context, symbol currency.Pair, changeType string, startTime, endTime time.Time, limit int64) ([]GetPositionMarginChangeHistoryData, error)

FuturesMarginChangeHistory gets past margin changes for positions

func (*Binance) FuturesNewOrder

func (b *Binance) FuturesNewOrder(ctx context.Context, x *FuturesNewOrderRequest) (
	FuturesOrderPlaceData,
	error,
)

FuturesNewOrder sends a new futures order to the exchange

func (*Binance) FuturesNotionalBracket

func (b *Binance) FuturesNotionalBracket(ctx context.Context, pair string) ([]NotionalBracketData, error)

FuturesNotionalBracket gets futures notional bracket

func (*Binance) FuturesOpenOrderData

func (b *Binance) FuturesOpenOrderData(ctx context.Context, symbol currency.Pair, orderID, origClientOrderID string) (FuturesOrderGetData, error)

FuturesOpenOrderData gets open order data for CoinMarginedFutures,

func (*Binance) FuturesPositionsADLEstimate

func (b *Binance) FuturesPositionsADLEstimate(ctx context.Context, symbol currency.Pair) ([]ADLEstimateData, error)

FuturesPositionsADLEstimate estimates ADL on positions

func (*Binance) FuturesPositionsInfo

func (b *Binance) FuturesPositionsInfo(ctx context.Context, marginAsset, pair string) ([]FuturesPositionInformation, error)

FuturesPositionsInfo gets futures positions info

func (*Binance) FuturesTradeHistory

func (b *Binance) FuturesTradeHistory(ctx context.Context, symbol currency.Pair, pair string, startTime, endTime time.Time, limit, fromID int64) ([]FuturesAccountTradeList, error)

FuturesTradeHistory gets trade history for CoinMarginedFutures, account

func (*Binance) GenerateSubscriptions

func (b *Binance) GenerateSubscriptions() ([]stream.ChannelSubscription, error)

GenerateSubscriptions generates the default subscription set

func (*Binance) GetAccount

func (b *Binance) GetAccount(ctx context.Context) (*Account, error)

GetAccount returns binance user accounts

func (*Binance) GetActiveOrders

func (b *Binance) GetActiveOrders(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*Binance) GetAggregatedTrades

func (b *Binance) GetAggregatedTrades(ctx context.Context, arg *AggregatedTradeRequestParams) ([]AggregatedTrade, error)

GetAggregatedTrades returns aggregated trade activity. If more than one hour of data is requested or asked limit is not supported by exchange then the trades are collected with multiple backend requests. https://binance-docs.github.io/apidocs/spot/en/#compressed-aggregate-trades-list

func (*Binance) GetAllCoinsInfo

func (b *Binance) GetAllCoinsInfo(ctx context.Context) ([]CoinInfo, error)

GetAllCoinsInfo returns details about all supported coins

func (*Binance) GetAllFuturesOrders

func (b *Binance) GetAllFuturesOrders(ctx context.Context, symbol currency.Pair, pair string, startTime, endTime time.Time, orderID, limit int64) ([]FuturesOrderData, error)

GetAllFuturesOrders gets all orders active cancelled or filled

func (*Binance) GetAvailableTransferChains

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

GetAvailableTransferChains returns the available transfer blockchains for the specific cryptocurrency

func (*Binance) GetAveragePrice

func (b *Binance) GetAveragePrice(ctx context.Context, symbol currency.Pair) (AveragePrice, error)

GetAveragePrice returns current average price for a symbol.

symbol: string of currency pair

func (*Binance) GetBestPrice

func (b *Binance) GetBestPrice(ctx context.Context, symbol currency.Pair) (BestPrice, error)

GetBestPrice returns the latest best price for symbol

symbol: string of currency pair

func (*Binance) GetContinuousKlineData

func (b *Binance) GetContinuousKlineData(ctx context.Context, pair, contractType, interval string, limit int64, startTime, endTime time.Time) ([]FuturesCandleStick, error)

GetContinuousKlineData gets continuous kline data

func (*Binance) GetContractTradeFee

func (b *Binance) GetContractTradeFee(ctx context.Context, assetType asset.Item, symbol string) (*ContractTradeFeeResponse, error)

GetContractTradeFee 获取合约手续费

func (*Binance) GetCrossMarginInterestHistory

func (b *Binance) GetCrossMarginInterestHistory(ctx context.Context) (CrossMarginInterestData, error)

GetCrossMarginInterestHistory gets cross-margin interest history for currency/currencies provided

func (*Binance) GetDefaultConfig

func (b *Binance) GetDefaultConfig() (*config.Exchange, error)

GetDefaultConfig returns a default exchange config

func (*Binance) GetDepositAddress

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

GetDepositAddress returns a deposit address for a specified currency

func (*Binance) GetDepositAddressForCurrency

func (b *Binance) GetDepositAddressForCurrency(ctx context.Context, currency, chain string) (*DepositAddress, error)

GetDepositAddressForCurrency retrieves the wallet address for a given currency

func (*Binance) GetExchangeInfo

func (b *Binance) GetExchangeInfo(ctx context.Context) (ExchangeInfo, error)

GetExchangeInfo returns exchange information. Check binance_types for more information

func (*Binance) GetFee

func (b *Binance) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*Binance) GetFeeByType

func (b *Binance) GetFeeByType(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*Binance) GetFundingHistory

func (b *Binance) GetFundingHistory(ctx context.Context) ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*Binance) GetFundingRates

func (b *Binance) GetFundingRates(ctx context.Context, symbol currency.Pair, limit string, startTime, endTime time.Time) ([]FundingRateData, error)

GetFundingRates gets funding rate history for perpetual contracts

func (*Binance) GetFuturesAccountBalance

func (b *Binance) GetFuturesAccountBalance(ctx context.Context) ([]FuturesAccountBalanceData, error)

GetFuturesAccountBalance gets account balance data for CoinMarginedFutures, account

func (*Binance) GetFuturesAccountInfo

func (b *Binance) GetFuturesAccountInfo(ctx context.Context) (FuturesAccountInformation, error)

GetFuturesAccountInfo gets account info data for CoinMarginedFutures, account

func (*Binance) GetFuturesAggregatedTradesList

func (b *Binance) GetFuturesAggregatedTradesList(ctx context.Context, symbol currency.Pair, fromID, limit int64, startTime, endTime time.Time) ([]AggregatedTrade, error)

GetFuturesAggregatedTradesList gets aggregated trades list for CoinMarginedFutures,

func (*Binance) GetFuturesAllOpenOrders

func (b *Binance) GetFuturesAllOpenOrders(ctx context.Context, symbol currency.Pair, pair string) ([]FuturesOrderData, error)

GetFuturesAllOpenOrders gets all open orders data for CoinMarginedFutures,

func (*Binance) GetFuturesBasisData

func (b *Binance) GetFuturesBasisData(ctx context.Context, pair, contractType, period string, limit int64, startTime, endTime time.Time) ([]FuturesBasisData, error)

GetFuturesBasisData gets futures basis data

func (*Binance) GetFuturesHistoricalTrades

func (b *Binance) GetFuturesHistoricalTrades(ctx context.Context, symbol currency.Pair, fromID string, limit int64) ([]UPublicTradesData, error)

GetFuturesHistoricalTrades gets historical public trades for CoinMarginedFutures,

func (*Binance) GetFuturesKlineData

func (b *Binance) GetFuturesKlineData(ctx context.Context, symbol currency.Pair, interval string, limit int64, startTime, endTime time.Time) ([]FuturesCandleStick, error)

GetFuturesKlineData gets futures kline data for CoinMarginedFutures,

func (*Binance) GetFuturesLiquidationOrders

func (b *Binance) GetFuturesLiquidationOrders(ctx context.Context, symbol currency.Pair, pair string, limit int64, startTime, endTime time.Time) ([]AllLiquidationOrders, error)

GetFuturesLiquidationOrders gets forced liquidation orders

func (*Binance) GetFuturesOrderbook

func (b *Binance) GetFuturesOrderbook(ctx context.Context, symbol currency.Pair, limit int64) (OrderBook, error)

GetFuturesOrderbook gets orderbook data for CoinMarginedFutures,

func (*Binance) GetFuturesOrderbookTicker

func (b *Binance) GetFuturesOrderbookTicker(ctx context.Context, symbol currency.Pair, pair string) ([]SymbolOrderBookTicker, error)

GetFuturesOrderbookTicker gets orderbook ticker for symbol

func (*Binance) GetFuturesPublicTrades

func (b *Binance) GetFuturesPublicTrades(ctx context.Context, symbol currency.Pair, limit int64) ([]FuturesPublicTradesData, error)

GetFuturesPublicTrades gets recent public trades for CoinMarginedFutures,

func (*Binance) GetFuturesSwapTickerChangeStats

func (b *Binance) GetFuturesSwapTickerChangeStats(ctx context.Context, symbol currency.Pair, pair string) ([]PriceChangeStats, error)

GetFuturesSwapTickerChangeStats gets 24hr ticker change stats for CoinMarginedFutures,

func (*Binance) GetFuturesSymbolPriceTicker

func (b *Binance) GetFuturesSymbolPriceTicker(ctx context.Context, symbol currency.Pair, pair string) ([]SymbolPriceTicker, error)

GetFuturesSymbolPriceTicker gets price ticker for symbol

func (*Binance) GetFuturesTakerVolume

func (b *Binance) GetFuturesTakerVolume(ctx context.Context, pair, contractType, period string, limit int64, startTime, endTime time.Time) ([]TakerBuySellVolume, error)

GetFuturesTakerVolume gets futures taker buy/sell volumes

func (*Binance) GetHistoricCandles

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

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

func (*Binance) GetHistoricCandlesExtended

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

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

func (*Binance) GetHistoricTrades

func (b *Binance) GetHistoricTrades(ctx context.Context, p currency.Pair, a asset.Item, from, to time.Time) ([]trade.Data, error)

GetHistoricTrades returns historic trade data within the timeframe provided

func (*Binance) GetHistoricalTrades

func (b *Binance) GetHistoricalTrades(ctx context.Context, symbol string, limit int, fromID int64) ([]HistoricalTrade, error)

GetHistoricalTrades returns historical trade activity

symbol: string of currency pair limit: Optional. Default 500; max 1000. fromID:

func (*Binance) GetIndexAndMarkPrice

func (b *Binance) GetIndexAndMarkPrice(ctx context.Context, symbol, pair string) ([]IndexMarkPrice, error)

GetIndexAndMarkPrice gets index and mark prices for CoinMarginedFutures,

func (*Binance) GetIndexPriceKlines

func (b *Binance) GetIndexPriceKlines(ctx context.Context, pair, interval string, limit int64, startTime, endTime time.Time) ([]FuturesCandleStick, error)

GetIndexPriceKlines gets continuous kline data

func (*Binance) GetInterestHistory

func (b *Binance) GetInterestHistory(ctx context.Context) (MarginInfoData, error)

GetInterestHistory gets interest history for currency/currencies provided

func (*Binance) GetLatestSpotPrice

func (b *Binance) GetLatestSpotPrice(ctx context.Context, symbol currency.Pair) (SymbolPrice, error)

GetLatestSpotPrice returns latest spot price of symbol

symbol: string of currency pair

func (*Binance) GetMarginAccount

func (b *Binance) GetMarginAccount(ctx context.Context) (*MarginAccount, error)

GetMarginAccount returns account information for margin accounts

func (*Binance) GetMarginMarkets

func (b *Binance) GetMarginMarkets(ctx context.Context) (PerpsExchangeInfo, error)

GetMarginMarkets returns exchange information. Check binance_types for more information

func (*Binance) GetMarkPriceKline

func (b *Binance) GetMarkPriceKline(ctx context.Context, symbol currency.Pair, interval string, limit int64, startTime, endTime time.Time) ([]FuturesCandleStick, error)

GetMarkPriceKline gets mark price kline data

func (*Binance) GetMarketRatio

func (b *Binance) GetMarketRatio(ctx context.Context, pair, period string, limit int64, startTime, endTime time.Time) ([]TopTraderPositionRatio, error)

GetMarketRatio gets global long/short ratio

func (*Binance) GetMostRecentTrades

func (b *Binance) GetMostRecentTrades(ctx context.Context, rtr RecentTradeRequestParams) ([]RecentTrade, error)

GetMostRecentTrades returns recent trade activity limit: Up to 500 results returned

func (*Binance) GetOpenInterest

func (b *Binance) GetOpenInterest(ctx context.Context, symbol currency.Pair) (OpenInterestData, error)

GetOpenInterest gets open interest data for a symbol

func (*Binance) GetOpenInterestStats

func (b *Binance) GetOpenInterestStats(ctx context.Context, pair, contractType, period string, limit int64, startTime, endTime time.Time) ([]OpenInterestStats, error)

GetOpenInterestStats gets open interest stats for a symbol

func (*Binance) GetOrderBook

func (b *Binance) GetOrderBook(ctx context.Context, obd OrderBookDataRequestParams) (OrderBook, error)

GetOrderBook returns full orderbook information

OrderBookDataRequestParams contains the following members symbol: string of currency pair limit: returned limit amount

func (*Binance) GetOrderHistory

func (b *Binance) GetOrderHistory(ctx context.Context, req *order.GetOrdersRequest) ([]order.Detail, error)

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

func (*Binance) GetOrderInfo

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

GetOrderInfo returns information on a current open order

func (*Binance) GetPastPublicTrades

func (b *Binance) GetPastPublicTrades(ctx context.Context, symbol currency.Pair, limit, fromID int64) ([]FuturesPublicTradesData, error)

GetPastPublicTrades gets past public trades for CoinMarginedFutures,

func (*Binance) GetPerpMarkets

func (b *Binance) GetPerpMarkets(ctx context.Context) (PerpsExchangeInfo, error)

GetPerpMarkets returns exchange information. Check binance_types for more information

func (*Binance) GetPriceChangeStats

func (b *Binance) GetPriceChangeStats(ctx context.Context, symbol currency.Pair) (PriceChangeStats, error)

GetPriceChangeStats returns price change statistics for the last 24 hours

symbol: string of currency pair

func (*Binance) GetRecentTrades

func (b *Binance) 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 (*Binance) GetSpotKline

func (b *Binance) GetSpotKline(ctx context.Context, arg *KlinesRequestParams) ([]CandleStick, error)

GetSpotKline returns kline data

KlinesRequestParams supports 5 parameters symbol: the symbol to get the kline data for limit: optinal interval: the interval time for the data startTime: startTime filter for kline data endTime: endTime filter for the kline data

func (*Binance) GetSpotTradeFee

func (b *Binance) GetSpotTradeFee(ctx context.Context, symbol string) ([]SpotTradeFeeResponse, error)

GetSpotTradeFee 查询现货手续费 (USER_DATA)

func (*Binance) GetTickers

func (b *Binance) GetTickers(ctx context.Context) ([]PriceChangeStats, error)

GetTickers returns the ticker data for the last 24 hrs

func (*Binance) GetTraderFuturesAccountRatio

func (b *Binance) GetTraderFuturesAccountRatio(ctx context.Context, pair, period string, limit int64, startTime, endTime time.Time) ([]TopTraderAccountRatio, error)

GetTraderFuturesAccountRatio gets a traders futures account long/short ratio

func (*Binance) GetTraderFuturesPositionsRatio

func (b *Binance) GetTraderFuturesPositionsRatio(ctx context.Context, pair, period string, limit int64, startTime, endTime time.Time) ([]TopTraderPositionRatio, error)

GetTraderFuturesPositionsRatio gets a traders futures positions' long/short ratio

func (*Binance) GetWithdrawalsHistory

func (b *Binance) GetWithdrawalsHistory(ctx context.Context, c currency.Code) (resp []exchange.WithdrawalHistory, err error)

GetWithdrawalsHistory returns previous withdrawals data

func (*Binance) GetWsAuthStreamKey

func (b *Binance) GetWsAuthStreamKey(ctx context.Context) (string, error)

GetWsAuthStreamKey will retrieve a key to use for authorised WS streaming

func (*Binance) KeepAuthKeyAlive

func (b *Binance) KeepAuthKeyAlive()

KeepAuthKeyAlive will continuously send messages to keep the WS auth key active

func (*Binance) MaintainWsAuthStreamKey

func (b *Binance) MaintainWsAuthStreamKey(ctx context.Context) error

MaintainWsAuthStreamKey will keep the key alive

func (*Binance) ModifyIsolatedPositionMargin

func (b *Binance) ModifyIsolatedPositionMargin(ctx context.Context, symbol currency.Pair, positionSide, changeType string, amount float64) (GenericAuthResponse, error)

ModifyIsolatedPositionMargin changes margin for an isolated position

func (*Binance) ModifyOrder

func (b *Binance) ModifyOrder(ctx context.Context, action *order.Modify) (order.Modify, error)

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

func (*Binance) NewOrder

func (b *Binance) NewOrder(ctx context.Context, o *NewOrderRequest) (NewOrderResponse, error)

NewOrder sends a new order to Binance

func (*Binance) NewOrderTest

func (b *Binance) NewOrderTest(ctx context.Context, o *NewOrderRequest) error

NewOrderTest sends a new test order to Binance

func (*Binance) OpenOrders

func (b *Binance) OpenOrders(ctx context.Context, pair currency.Pair) ([]QueryOrderData, error)

OpenOrders Current open orders. Get all open orders on a symbol. Careful when accessing this with no symbol: The number of requests counted against the rate limiter is significantly higher

func (*Binance) Ping

func (b *Binance) Ping(ctx context.Context, assetType asset.Item) (ping bool, err error)

Ping 测试服务器连通性

func (*Binance) ProcessUpdate

func (b *Binance) ProcessUpdate(cp currency.Pair, a asset.Item, ws *WebsocketDepthStream) error

ProcessUpdate processes the websocket orderbook update

func (*Binance) QueryOrder

func (b *Binance) QueryOrder(ctx context.Context, symbol currency.Pair, origClientOrderID string, orderID int64) (QueryOrderData, error)

QueryOrder returns information on a past order

func (*Binance) Run

func (b *Binance) Run()

Run implements the Binance wrapper

func (*Binance) SeedLocalCache

func (b *Binance) SeedLocalCache(ctx context.Context, p currency.Pair) error

SeedLocalCache seeds depth data

func (*Binance) SeedLocalCacheWithBook

func (b *Binance) SeedLocalCacheWithBook(p currency.Pair, orderbookNew *OrderBook) error

SeedLocalCacheWithBook seeds the local orderbook cache

func (*Binance) SendAPIKeyHTTPRequest

func (b *Binance) SendAPIKeyHTTPRequest(ctx context.Context, ePath exchange.URL, path string, f request.EndpointLimit, result interface{}) error

SendAPIKeyHTTPRequest is a special API request where the api key is appended to the headers without a secret

func (*Binance) SendAuthHTTPRequest

func (b *Binance) SendAuthHTTPRequest(ctx context.Context, ePath exchange.URL, method, path string, params url.Values, f request.EndpointLimit, result interface{}) error

SendAuthHTTPRequest sends an authenticated HTTP request

func (*Binance) SendHTTPRequest

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

SendHTTPRequest sends an unauthenticated request

func (*Binance) SetDefaults

func (b *Binance) SetDefaults()

SetDefaults sets the basic defaults for Binance

func (*Binance) SetValues

func (b *Binance) SetValues()

SetValues sets the default valid values

func (*Binance) Setup

func (b *Binance) Setup(exch *config.Exchange) error

Setup takes in the supplied exchange configuration details and sets params

func (*Binance) Start

func (b *Binance) Start(wg *sync.WaitGroup) error

Start starts the Binance go routine

func (*Binance) SubmitOrder

func (b *Binance) SubmitOrder(ctx context.Context, s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*Binance) Subscribe

func (b *Binance) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error

Subscribe subscribes to a set of channels

func (*Binance) SynchroniseWebsocketOrderbook

func (b *Binance) SynchroniseWebsocketOrderbook()

SynchroniseWebsocketOrderbook synchronises full orderbook for currency pair asset

func (*Binance) Transfer

func (b *Binance) Transfer(ctx context.Context, transferType TransferType, symbolBase string, amount float64) (tranId int64, err error)

Transfer 用户万向划转

func (*Binance) U24HTickerPriceChangeStats

func (b *Binance) U24HTickerPriceChangeStats(ctx context.Context, symbol currency.Pair) ([]U24HrPriceChangeStats, error)

U24HTickerPriceChangeStats gets 24hr ticker price change stats for USDTMarginedFutures

func (*Binance) UAccountBalanceV2

func (b *Binance) UAccountBalanceV2(ctx context.Context) ([]UAccountBalanceV2Data, error)

UAccountBalanceV2 gets V2 account balance data

func (*Binance) UAccountForcedOrders

func (b *Binance) UAccountForcedOrders(ctx context.Context, symbol currency.Pair, autoCloseType string, limit int64, startTime, endTime time.Time) ([]UForceOrdersData, error)

UAccountForcedOrders gets account's forced (liquidation) orders for USDTMarginedFutures

func (*Binance) UAccountIncomeHistory

func (b *Binance) UAccountIncomeHistory(ctx context.Context, symbol currency.Pair, incomeType string, limit int64, startTime, endTime time.Time) ([]UAccountIncomeHistory, error)

UAccountIncomeHistory gets account's income history data for USDTMarginedFutures

func (*Binance) UAccountInformationV2

func (b *Binance) UAccountInformationV2(ctx context.Context) (UAccountInformationV2Data, error)

UAccountInformationV2 gets V2 account balance data

func (*Binance) UAccountTradesHistory

func (b *Binance) UAccountTradesHistory(ctx context.Context, symbol currency.Pair, fromID string, limit int64, startTime, endTime time.Time) ([]UAccountTradeHistory, error)

UAccountTradesHistory gets account's trade history data for USDTMarginedFutures

func (*Binance) UAllAccountOpenOrders

func (b *Binance) UAllAccountOpenOrders(ctx context.Context, symbol currency.Pair) ([]UOrderData, error)

UAllAccountOpenOrders gets all account's orders for USDTMarginedFutures

func (*Binance) UAllAccountOrders

func (b *Binance) UAllAccountOrders(ctx context.Context, symbol currency.Pair, orderID, limit int64, startTime, endTime time.Time) ([]UFuturesOrderData, error)

UAllAccountOrders gets all account's orders for USDTMarginedFutures

func (*Binance) UAutoCancelAllOpenOrders

func (b *Binance) UAutoCancelAllOpenOrders(ctx context.Context, symbol currency.Pair, countdownTime int64) (AutoCancelAllOrdersData, error)

UAutoCancelAllOpenOrders auto cancels all ufutures open orders for a symbol after the set countdown time

func (*Binance) UCancelAllOpenOrders

func (b *Binance) UCancelAllOpenOrders(ctx context.Context, symbol currency.Pair) (GenericAuthResponse, error)

UCancelAllOpenOrders cancels all open orders for a symbol ufutures

func (*Binance) UCancelBatchOrders

func (b *Binance) UCancelBatchOrders(ctx context.Context, symbol currency.Pair, orderIDList, origCliOrdIDList []string) ([]UOrderData, error)

UCancelBatchOrders cancel batch order for USDTMarginedFutures

func (*Binance) UCancelOrder

func (b *Binance) UCancelOrder(ctx context.Context, symbol currency.Pair, orderID, cliOrderID string) (UOrderData, error)

UCancelOrder cancel an order for USDTMarginedFutures

func (*Binance) UChangeInitialLeverageRequest

func (b *Binance) UChangeInitialLeverageRequest(ctx context.Context, symbol currency.Pair, leverage int64) (UChangeInitialLeverage, error)

UChangeInitialLeverageRequest sends a request to change account's initial leverage

func (*Binance) UChangeInitialMarginType

func (b *Binance) UChangeInitialMarginType(ctx context.Context, symbol currency.Pair, marginType string) error

UChangeInitialMarginType sends a request to change account's initial margin type

func (*Binance) UCompositeIndexInfo

func (b *Binance) UCompositeIndexInfo(ctx context.Context, symbol currency.Pair) ([]UCompositeIndexInfoData, error)

UCompositeIndexInfo stores composite indexs' info for usdt margined futures

func (*Binance) UCompressedTrades

func (b *Binance) UCompressedTrades(ctx context.Context, symbol currency.Pair, fromID string, limit int64, startTime, endTime time.Time) ([]UCompressedTradeData, error)

UCompressedTrades gets compressed public trades for usdt margined futures

func (*Binance) UExchangeInfo

func (b *Binance) UExchangeInfo(ctx context.Context) (UFuturesExchangeInfo, error)

UExchangeInfo stores usdt margined futures data

func (*Binance) UFetchOpenOrder

func (b *Binance) UFetchOpenOrder(ctx context.Context, symbol currency.Pair, orderID, origClientOrderID string) (UOrderData, error)

UFetchOpenOrder sends a request to fetch open order data for USDTMarginedFutures

func (*Binance) UFutureGetWsAuthStreamKey

func (b *Binance) UFutureGetWsAuthStreamKey(ctx context.Context) (string, error)

UFutureGetWsAuthStreamKey will retrieve a key to use for authorised WS streaming

func (*Binance) UFutureMaintainWsAuthStreamKey

func (b *Binance) UFutureMaintainWsAuthStreamKey(ctx context.Context) error

UFutureMaintainWsAuthStreamKey will keep the key alive

func (*Binance) UFuturesGenerateSubscriptions

func (b *Binance) UFuturesGenerateSubscriptions() ([]stream.ChannelSubscription, error)

UFuturesGenerateSubscriptions generates the default subscription set

func (*Binance) UFuturesHistoricalTrades

func (b *Binance) UFuturesHistoricalTrades(ctx context.Context, symbol currency.Pair, fromID string, limit int64) ([]interface{}, error)

UFuturesHistoricalTrades gets historical public trades for USDTMarginedFutures

func (*Binance) UFuturesKeepAuthKeyAlive

func (b *Binance) UFuturesKeepAuthKeyAlive()

UFuturesKeepAuthKeyAlive will continuously send messages to keep the WS auth key active

func (*Binance) UFuturesNewOrder

func (b *Binance) UFuturesNewOrder(ctx context.Context, symbol currency.Pair, side, positionSide, orderType, timeInForce,
	newClientOrderID, closePosition, workingType, newOrderRespType string,
	quantity, price, stopPrice, activationPrice, callbackRate float64, reduceOnly bool) (UOrderData, error)

UFuturesNewOrder sends a new order for USDTMarginedFutures

func (*Binance) UFuturesOrderbook

func (b *Binance) UFuturesOrderbook(ctx context.Context, symbol currency.Pair, limit int64) (OrderBook, error)

UFuturesOrderbook gets orderbook data for usdt margined futures

func (*Binance) UFuturesSubscribe

func (b *Binance) UFuturesSubscribe(channelsToSubscribe []stream.ChannelSubscription) error

UFuturesSubscribe subscribes to a set of channels

func (*Binance) UFuturesSynchroniseWebsocketOrderbook

func (b *Binance) UFuturesSynchroniseWebsocketOrderbook()

UFuturesSynchroniseWebsocketOrderbook synchronises full orderbook for currency pair asset

func (*Binance) UFuturesUnsubscribe

func (b *Binance) UFuturesUnsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error

UFuturesUnsubscribe unsubscribes from a set of channels

func (*Binance) UFuturesWsConnect

func (b *Binance) UFuturesWsConnect() error

UFuturesWsConnect initiates a websocket connection

func (*Binance) UGetFundingHistory

func (b *Binance) UGetFundingHistory(ctx context.Context, symbol currency.Pair, limit int64, startTime, endTime time.Time) ([]FundingRateHistory, error)

UGetFundingHistory gets funding history for USDTMarginedFutures

func (*Binance) UGetMarkPrice

func (b *Binance) UGetMarkPrice(ctx context.Context, symbol currency.Pair) ([]UMarkPrice, error)

UGetMarkPrice gets mark price data for USDTMarginedFutures

func (*Binance) UGetNotionalAndLeverageBrackets

func (b *Binance) UGetNotionalAndLeverageBrackets(ctx context.Context, symbol currency.Pair) ([]UNotionalLeverageAndBrakcetsData, error)

UGetNotionalAndLeverageBrackets gets account's notional and leverage brackets for USDTMarginedFutures

func (*Binance) UGetOrderData

func (b *Binance) UGetOrderData(ctx context.Context, symbol currency.Pair, orderID, cliOrderID string) (UOrderData, error)

UGetOrderData gets order data for USDTMarginedFutures

func (*Binance) UGlobalLongShortRatio

func (b *Binance) UGlobalLongShortRatio(ctx context.Context, symbol currency.Pair, period string, limit int64, startTime, endTime time.Time) ([]ULongShortRatio, error)

UGlobalLongShortRatio gets the global long/short ratio data for USDTMarginedFutures

func (*Binance) UKlineData

func (b *Binance) UKlineData(ctx context.Context, symbol currency.Pair, interval string, limit int64, startTime, endTime time.Time) ([]FuturesCandleStick, error)

UKlineData gets kline data for usdt margined futures

func (*Binance) ULiquidationOrders

func (b *Binance) ULiquidationOrders(ctx context.Context, symbol currency.Pair, limit int64, startTime, endTime time.Time) ([]ULiquidationOrdersData, error)

ULiquidationOrders gets public liquidation orders

func (*Binance) UModifyIsolatedPositionMarginReq

func (b *Binance) UModifyIsolatedPositionMarginReq(ctx context.Context, symbol currency.Pair, positionSide, changeType string, amount float64) (UModifyIsolatedPosMargin, error)

UModifyIsolatedPositionMarginReq sends a request to modify isolated margin for USDTMarginedFutures

func (*Binance) UOpenInterest

func (b *Binance) UOpenInterest(ctx context.Context, symbol currency.Pair) (UOpenInterestData, error)

UOpenInterest gets open interest data for USDTMarginedFutures

func (*Binance) UOpenInterestStats

func (b *Binance) UOpenInterestStats(ctx context.Context, symbol currency.Pair, period string, limit int64, startTime, endTime time.Time) ([]UOpenInterestStats, error)

UOpenInterestStats gets open interest stats for USDTMarginedFutures

func (*Binance) UPlaceBatchOrders

func (b *Binance) UPlaceBatchOrders(ctx context.Context, data []PlaceBatchOrderData) ([]UOrderData, error)

UPlaceBatchOrders places batch orders

func (*Binance) UPositionMarginChangeHistory

func (b *Binance) UPositionMarginChangeHistory(ctx context.Context, symbol currency.Pair, changeType string, limit int64, startTime, endTime time.Time) ([]UPositionMarginChangeHistoryData, error)

UPositionMarginChangeHistory gets margin change history for USDTMarginedFutures

func (*Binance) UPositionsADLEstimate

func (b *Binance) UPositionsADLEstimate(ctx context.Context, symbol currency.Pair) (UPositionADLEstimationData, error)

UPositionsADLEstimate gets estimated ADL data for USDTMarginedFutures positions

func (*Binance) UPositionsInfoV2

func (b *Binance) UPositionsInfoV2(ctx context.Context, symbol currency.Pair) ([]UPositionInformationV2, error)

UPositionsInfoV2 gets positions' info for USDTMarginedFutures

func (*Binance) URecentTrades

func (b *Binance) URecentTrades(ctx context.Context, symbol currency.Pair, fromID string, limit int64) ([]UPublicTradesData, error)

URecentTrades gets recent trades for usdt margined futures

func (*Binance) UServerTime

func (b *Binance) UServerTime(ctx context.Context) (time.Time, error)

UServerTime gets the server time

func (*Binance) USymbolOrderbookTicker

func (b *Binance) USymbolOrderbookTicker(ctx context.Context, symbol currency.Pair) ([]USymbolOrderbookTicker, error)

USymbolOrderbookTicker gets symbol orderbook ticker

func (*Binance) USymbolPriceTicker

func (b *Binance) USymbolPriceTicker(ctx context.Context, symbol currency.Pair) ([]USymbolPriceTicker, error)

USymbolPriceTicker gets symbol price ticker for USDTMarginedFutures

func (*Binance) UTakerBuySellVol

func (b *Binance) UTakerBuySellVol(ctx context.Context, symbol currency.Pair, period string, limit int64, startTime, endTime time.Time) ([]UTakerVolumeData, error)

UTakerBuySellVol gets takers' buy/sell ratio for USDTMarginedFutures

func (*Binance) UTopAcccountsLongShortRatio

func (b *Binance) UTopAcccountsLongShortRatio(ctx context.Context, symbol currency.Pair, period string, limit int64, startTime, endTime time.Time) ([]ULongShortRatio, error)

UTopAcccountsLongShortRatio gets long/short ratio data for top trader accounts in ufutures

func (*Binance) UTopPostionsLongShortRatio

func (b *Binance) UTopPostionsLongShortRatio(ctx context.Context, symbol currency.Pair, period string, limit int64, startTime, endTime time.Time) ([]ULongShortRatio, error)

UTopPostionsLongShortRatio gets long/short ratio data for top positions' in ufutures

func (*Binance) Unsubscribe

func (b *Binance) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error

Unsubscribe unsubscribes from a set of channels

func (*Binance) UpdateAccountInfo

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

UpdateAccountInfo retrieves balances for all enabled currencies for the Binance exchange

func (*Binance) UpdateLocalBuffer

func (b *Binance) UpdateLocalBuffer(wsdp *WebsocketDepthStream) (bool, error)

UpdateLocalBuffer updates and returns the most recent iteration of the orderbook

func (*Binance) UpdateOrderExecutionLimits

func (b *Binance) UpdateOrderExecutionLimits(ctx context.Context, a asset.Item) error

UpdateOrderExecutionLimits sets exchange executions for a required asset type

func (*Binance) UpdateOrderbook

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

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Binance) UpdateTicker

func (b *Binance) UpdateTicker(ctx context.Context, p currency.Pair, a asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Binance) UpdateTickers

func (b *Binance) UpdateTickers(ctx context.Context, a asset.Item) error

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

func (*Binance) UpdateTradablePairs

func (b *Binance) UpdateTradablePairs(ctx context.Context, forceUpdate bool) error

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

func (*Binance) ValidateCredentials

func (b *Binance) ValidateCredentials(ctx context.Context, assetType asset.Item) error

ValidateCredentials validates current credentials used for wrapper functionality

func (*Binance) WithdrawCrypto

func (b *Binance) WithdrawCrypto(ctx context.Context, cryptoAsset, withdrawOrderID, network, address, addressTag, name, amount string, transactionFeeFlag bool) (string, error)

WithdrawCrypto sends cryptocurrency to the address of your choosing

func (*Binance) WithdrawCryptocurrencyFunds

func (b *Binance) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Binance) WithdrawFiatFunds

func (b *Binance) WithdrawFiatFunds(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Binance) WithdrawFiatFundsToInternationalBank

func (b *Binance) WithdrawFiatFundsToInternationalBank(_ context.Context, _ *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*Binance) WithdrawHistory

func (b *Binance) WithdrawHistory(ctx context.Context, c currency.Code, status string, startTime, endTime time.Time, offset, limit int) ([]WithdrawStatusResponse, error)

WithdrawHistory gets the status of recent withdrawals status `param` used as string to prevent default value 0 (for int) interpreting as EmailSent status

func (*Binance) WsConnect

func (b *Binance) WsConnect() error

WsConnect initiates a websocket connection

type CExchangeInfo

type CExchangeInfo struct {
	ExchangeFilters []interface{} `json:"exchangeFilters"`
	RateLimits      []struct {
		Interval      string `json:"interval"`
		IntervalNum   int64  `json:"intervalNul"`
		Limit         int64  `json:"limit"`
		RateLimitType string `json:"rateLimitType"`
	} `json:"rateLimits"`
	ServerTime int64 `json:"serverTime"`
	Symbols    []struct {
		Filters []struct {
			FilterType        string  `json:"filterType"`
			MinPrice          float64 `json:"minPrice,string"`
			MaxPrice          float64 `json:"maxPrice,string"`
			StepSize          float64 `json:"stepSize,string"`
			TickSize          float64 `json:"tickSize,string"`
			MaxQty            float64 `json:"maxQty,string"`
			MinQty            float64 `json:"minQty,string"`
			Limit             int64   `json:"limit"`
			MultiplierDown    float64 `json:"multiplierDown,string"`
			MultiplierUp      float64 `json:"multiplierUp,string"`
			MultiplierDecimal float64 `json:"multiplierDecimal,string"`
		} `json:"filters"`
		OrderTypes            []string `json:"orderType"`
		TimeInForce           []string `json:"timeInForce"`
		Symbol                string   `json:"symbol"`
		Pair                  string   `json:"pair"`
		ContractType          string   `json:"contractType"`
		DeliveryDate          int64    `json:"deliveryDate"`
		OnboardDate           int64    `json:"onboardDate"`
		ContractStatus        string   `json:"contractStatus"`
		ContractSize          int64    `json:"contractSize"`
		QuoteAsset            string   `json:"quoteAsset"`
		BaseAsset             string   `json:"baseAsset"`
		MarginAsset           string   `json:"marginAsset"`
		PricePrecision        int64    `json:"pricePrecision"`
		QuantityPrecision     int64    `json:"quantityPrecision"`
		BaseAssetPrecision    int64    `json:"baseAssetPrecision"`
		QuotePrecision        int64    `json:"quotePrecision"`
		MaintMarginPercent    float64  `json:"maintMarginPercent,string"`
		RequiredMarginPercent float64  `json:"requiredMarginPercent,string"`
	} `json:"symbols"`
	Timezone string `json:"timezone"`
}

CExchangeInfo stores exchange info for cfutures

type CancelOrderResponse

type CancelOrderResponse struct {
	Symbol            string `json:"symbol"`
	OrigClientOrderID string `json:"origClientOrderId"`
	OrderID           int64  `json:"orderId"`
	ClientOrderID     string `json:"clientOrderId"`
}

CancelOrderResponse is the return structured response from the exchange

type CandleStick

type CandleStick struct {
	OpenTime                 time.Time
	Open                     float64
	High                     float64
	Low                      float64
	Close                    float64
	Volume                   float64
	CloseTime                time.Time
	QuoteAssetVolume         float64
	TradeCount               float64
	TakerBuyAssetVolume      float64
	TakerBuyQuoteAssetVolume float64
}

CandleStick holds kline data

type CoinInfo

type CoinInfo struct {
	Coin              string  `json:"coin"`
	DepositAllEnable  bool    `json:"depositAllEnable"`
	WithdrawAllEnable bool    `json:"withdrawAllEnable"`
	Free              float64 `json:"free,string"`
	Freeze            float64 `json:"freeze,string"`
	IPOAble           float64 `json:"ipoable,string"`
	IPOing            float64 `json:"ipoing,string"`
	IsLegalMoney      bool    `json:"isLegalMoney"`
	Locked            float64 `json:"locked,string"`
	Name              string  `json:"name"`
	NetworkList       []struct {
		AddressRegex        string  `json:"addressRegex"`
		Coin                string  `json:"coin"`
		DepositDescription  string  `json:"depositDesc"` // shown only when "depositEnable" is false
		DepositEnable       bool    `json:"depositEnable"`
		IsDefault           bool    `json:"isDefault"`
		MemoRegex           string  `json:"memoRegex"`
		MinimumConfirmation uint16  `json:"minConfirm"`
		Name                string  `json:"name"`
		Network             string  `json:"network"`
		ResetAddressStatus  bool    `json:"resetAddressStatus"`
		SpecialTips         string  `json:"specialTips"`
		UnlockConfirm       uint16  `json:"unLockConfirm"`
		WithdrawDescription string  `json:"withdrawDesc"` // shown only when "withdrawEnable" is false
		WithdrawEnable      bool    `json:"withdrawEnable"`
		WithdrawFee         float64 `json:"withdrawFee,string"`
		WithdrawMinimum     float64 `json:"withdrawMin,string"`
		WithdrawMaximum     float64 `json:"withdrawMax,string"`
	} `json:"networkList"`
	Storage     float64 `json:"storage,string"`
	Trading     bool    `json:"trading"`
	Withdrawing float64 `json:"withdrawing,string"`
}

CoinInfo stores information about all supported coins

type CommissionRateResponse

type CommissionRateResponse struct {
	Symbol string
	Maker  float64
	Taker  float64
}

CommissionRateResponse 交易手续费率

type CompressedTradesData

type CompressedTradesData struct {
	TradeID      int64   `json:"a"`
	Price        float64 `json:"p"`
	Quantity     float64 `json:"q"`
	FirstTradeID int64   `json:"f"`
	LastTradeID  int64   `json:"l"`
	Timestamp    int64   `json:"t"`
	BuyerMaker   bool    `json:"b"`
}

CompressedTradesData stores futures trades data in a compressed format

type ContractBalanceResponse

type ContractBalanceResponse struct {
	AccountAlias       string  `json:"accountAlias"`              //账户唯一识别码
	Asset              string  `json:"asset"`                     // 资产
	Balance            float64 `json:"balance,string"`            // 总余额
	CrossWalletBalance float64 `json:"crossWalletBalance,string"` // 全仓余额
	CrossUnPnl         float64 `json:"crossUnPnl,string"`         // 全仓持仓未实现盈亏
	AvailableBalance   float64 `json:"availableBalance,string"`   // 下单可用余额
	// MaxWithdrawAmount  float64 `json:"maxWithdrawAmount,string"`  // 最大可转出余额
	WithdrawAvailable float64 `json:"withdrawAvailable,string"` // 可转出余额
	MarginAvailable   bool    `json:"marginAvailable"`          // 是否可用作联合保证金
	UpdateTime        int64   `json:"updateTime"`
}

合约余额

type ContractTradeFeeResponse

type ContractTradeFeeResponse struct {
	Symbol          string  `json:"symbol"` // 交易对
	MakerCommission float64 `json:"makerCommissionRate,string"`
	TakerCommission float64 `json:"takerCommissionRate,string"`
}

type ContractType

type ContractType string

ContractType 合约类型

type CrossMarginInterestData

type CrossMarginInterestData struct {
	Code          int64  `json:"code,string"`
	Message       string `json:"message"`
	MessageDetail string `json:"messageDetail"`
	Data          []struct {
		AssetName string `json:"assetName"`
		Specs     []struct {
			VipLevel          string `json:"vipLevel"`
			DailyInterestRate string `json:"dailyInterestRate"`
			BorrowLimit       string `json:"borrowLimit"`
		} `json:"specs"`
	} `json:"data"`
	Success bool `json:"success"`
}

CrossMarginInterestData stores cross margin data for borrowing

type DepositAddress

type DepositAddress struct {
	Address string `json:"address"`
	Coin    string `json:"coin"`
	Tag     string `json:"tag"`
	URL     string `json:"url"`
}

DepositAddress stores the deposit address info

type DepositHistory

type DepositHistory struct {
	Amount        float64 `json:"amount,string"`
	Coin          string  `json:"coin"`
	Network       string  `json:"network"`
	Status        uint8   `json:"status"`
	Address       string  `json:"address"`
	AddressTag    string  `json:"adressTag"`
	TransactionID string  `json:"txId"`
	InsertTime    float64 `json:"insertTime"`
	TransferType  uint8   `json:"transferType"`
	ConfirmTimes  string  `json:"confirmTimes"`
}

DepositHistory stores deposit history info

type DepthUpdateParams

type DepthUpdateParams []struct {
	PriceLevel float64
	Quantity   float64
	// contains filtered or unexported fields
}

DepthUpdateParams is used as an embedded type for WebsocketDepthStream

type ExchangeInfo

type ExchangeInfo struct {
	Code       int       `json:"code"`
	Msg        string    `json:"msg"`
	Timezone   string    `json:"timezone"`
	Servertime time.Time `json:"serverTime"`
	RateLimits []struct {
		RateLimitType string `json:"rateLimitType"`
		Interval      string `json:"interval"`
		Limit         int    `json:"limit"`
	} `json:"rateLimits"`
	ExchangeFilters interface{} `json:"exchangeFilters"`
	Symbols         []struct {
		Symbol                     string   `json:"symbol"`
		Status                     string   `json:"status"`
		BaseAsset                  string   `json:"baseAsset"`
		BaseAssetPrecision         int      `json:"baseAssetPrecision"`
		QuoteAsset                 string   `json:"quoteAsset"`
		QuotePrecision             int      `json:"quotePrecision"`
		OrderTypes                 []string `json:"orderTypes"`
		IcebergAllowed             bool     `json:"icebergAllowed"`
		OCOAllowed                 bool     `json:"ocoAllowed"`
		QuoteOrderQtyMarketAllowed bool     `json:"quoteOrderQtyMarketAllowed"`
		IsSpotTradingAllowed       bool     `json:"isSpotTradingAllowed"`
		IsMarginTradingAllowed     bool     `json:"isMarginTradingAllowed"`
		Filters                    []struct {
			FilterType          string  `json:"filterType"`
			MinPrice            float64 `json:"minPrice,string"`
			MaxPrice            float64 `json:"maxPrice,string"`
			TickSize            float64 `json:"tickSize,string"`
			MultiplierUp        float64 `json:"multiplierUp,string"`
			MultiplierDown      float64 `json:"multiplierDown,string"`
			AvgPriceMinutes     int64   `json:"avgPriceMins"`
			MinQty              float64 `json:"minQty,string"`
			MaxQty              float64 `json:"maxQty,string"`
			StepSize            float64 `json:"stepSize,string"`
			MinNotional         float64 `json:"minNotional,string"`
			ApplyToMarket       bool    `json:"applyToMarket"`
			Limit               int64   `json:"limit"`
			MaxNumAlgoOrders    int64   `json:"maxNumAlgoOrders"`
			MaxNumIcebergOrders int64   `json:"maxNumIcebergOrders"`
			MaxNumOrders        int64   `json:"maxNumOrders"`
		} `json:"filters"`
		Permissions []string `json:"permissions"`
	} `json:"symbols"`
}

ExchangeInfo holds the full exchange information type

func (*ExchangeInfo) UnmarshalJSON

func (a *ExchangeInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type ForcedOrdersData

type ForcedOrdersData struct {
	OrderID       int64   `json:"orderId"`
	Symbol        string  `json:"symbol"`
	Status        string  `json:"status"`
	ClientOrderID string  `json:"clientOrderId"`
	Price         float64 `json:"price,string"`
	AvgPrice      float64 `json:"avgPrice,string"`
	OrigQty       float64 `json:"origQty,string"`
	ExecutedQty   float64 `json:"executedQty,string"`
	CumQuote      float64 `json:"cumQuote,string"`
	TimeInForce   string  `json:"timeInForce"`
	OrderType     string  `json:"orderType"`
	ReduceOnly    bool    `json:"reduceOnly"`
	ClosePosition bool    `json:"closePosition"`
	Side          string  `json:"side"`
	PositionSide  string  `json:"positionSide"`
	StopPrice     float64 `json:"stopPrice,string"`
	WorkingType   string  `json:"workingType"`
	PriceProtect  float64 `json:"priceProtect,string"`
	OrigType      string  `json:"origType"`
	Time          int64   `json:"time"`
	UpdateTime    int64   `json:"updateTime"`
}

ForcedOrdersData stores forced orders data

type FundingRateData

type FundingRateData struct {
	Symbol      string  `json:"symbol"`
	FundingRate float64 `json:"fundingRate,string"`
	FundingTime int64   `json:"fundingTime"`
}

FundingRateData stores funding rates data

type FundingRateHistory

type FundingRateHistory struct {
	Symbol      string  `json:"symbol"`
	FundingRate float64 `json:"fundingRate,string"`
	FundingTime int64   `json:"fundingTime"`
}

FundingRateHistory stores funding rate history

type FundingRateRequest

type FundingRateRequest struct {
	Symbol    currency.Pair `json:"symbol"` //交易对
	StartTime int64         `json:"startTime"`
	EndTime   int64         `json:"endTime"`
	Limit     int64         `json:"limit"`
}

type FundingRateResponeItem

type FundingRateResponeItem struct {
	Symbol      string    `json:"symbol"`
	FundingRate float64   `json:"fundingRate"`
	FundingTime time.Time `json:"fundingTime"`
}

type FutureLeverageResponse

type FutureLeverageResponse struct {
	Leverage         int    `json:"leverage,string"`          // 平均成交价
	MaxNotionalValue int64  `json:"maxNotionalValue, string"` // 用户自定义的订单号
	Symbol           string `json:"symbol"`                   //成交金额
}

type FutureQueryOrderData

type FutureQueryOrderData struct {
	AvgPrice      float64                    `json:"avgPrice,string"`    // 平均成交价
	ClientOrderID string                     `json:"clientOrderId"`      // 用户自定义的订单号
	CumBase       float64                    `json:"cumBase,string"`     //成交额(标的数量)
	CumQuote      float64                    `json:"cumQuote,string"`    //成交金额
	ExecutedQty   float64                    `json:"executedQty,string"` //成交量
	OrderID       int64                      `json:"orderId"`
	OrigQty       float64                    `json:"origQty,string"` // 原始委托数量
	OrigType      string                     `json:"origType"`
	Price         float64                    `json:"price,string"`
	ReduceOnly    bool                       `json:"reduceOnly"` // 是否仅减仓
	Side          order.Side                 `json:"side"`
	PositionSide  PositionSide               `json:"positionSide"` // 持仓方向
	Status        order.Status               `json:"status"`
	StopPrice     float64                    `json:"stopPrice,string"` // 触发价,对`TRAILING_STOP_MARKET`无效
	ClosePosition bool                       `json:"closePosition"`    // 是否条件全平仓
	Symbol        string                     `json:"symbol"`
	Time          time.Time                  `json:"time"`                 // 订单时间
	TimeInForce   RequestParamsTimeForceType `json:"timeInForce"`          // 有效方法
	Type          string                     `json:"type"`                 //订单类型
	ActivatePrice float64                    `json:"activatePrice,string"` // 跟踪止损激活价格, 仅`TRAILING_STOP_MARKET` 订单返回此字段
	PriceRate     float64                    `json:"priceRate,string"`     // 跟踪止损回调比例, 仅`TRAILING_STOP_MARKET` 订单返回此字段
	UpdateTime    time.Time                  `json:"updateTime"`
	WorkingType   WorkingType                `json:"workingType"`  // 条件价格触发类型
	PriceProtect  bool                       `json:"priceProtect"` // 是否开启条件单触发保护
}

FutureQueryOrderData holds query order data

type FuturesAccountBalanceData

type FuturesAccountBalanceData struct {
	AccountAlias       string  `json:"accountAlias"`
	Asset              string  `json:"asset"`
	Balance            float64 `json:"balance,string"`
	WithdrawAvailable  float64 `json:"withdrawAvailable,string"`
	CrossWalletBalance float64 `json:"crossWalletBalance,string"`
	CrossUnPNL         float64 `json:"crossUnPNL,string"`
	AvailableBalance   float64 `json:"availableBalance,string"`
	UpdateTime         int64   `json:"updateTime"`
}

FuturesAccountBalanceData stores account balance data for futures

type FuturesAccountInformation

type FuturesAccountInformation struct {
	Assets []struct {
		Asset                  string  `json:"asset"`
		WalletBalance          float64 `json:"walletBalance,string"`
		UnrealizedProfit       float64 `json:"unrealizedProfit,string"`
		MarginBalance          float64 `json:"marginBalance,string"`
		MaintMargin            float64 `json:"maintMargin,string"`
		InitialMargin          float64 `json:"initialMargin,string"`
		PositionInitialMargin  float64 `json:"positionInitialMargin,string"`
		OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
		MaxWithdrawAmount      float64 `json:"maxWithdrawAmount,string"`
		CrossWalletBalance     float64 `json:"crossWalletBalance,string"`
		CrossUnPNL             float64 `json:"crossUnPnl,string"`
		AvailableBalance       float64 `json:"availableBalance,string"`
	} `json:"assets"`
	Positions   []FuturesAccountInformationPositions `json:"positions"`
	CanDeposit  bool                                 `json:"canDeposit"`
	CanTrade    bool                                 `json:"canTrade"`
	CanWithdraw bool                                 `json:"canWithdraw"`
	FeeTier     int64                                `json:"feeTier"`
	UpdateTime  time.Time                            `json:"updateTime"`
}

FuturesAccountInformation stores account information for futures account

func (*FuturesAccountInformation) UnmarshalJSON

func (a *FuturesAccountInformation) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type FuturesAccountInformationPositions

type FuturesAccountInformationPositions struct {
	Symbol                 string    `json:"symbol"`
	Amount                 float64   `json:"positionAmt,string"`
	InitialMargin          float64   `json:"initialMargin,string"`
	MaintMargin            float64   `json:"maintMargin,string"`
	UnrealizedProfit       float64   `json:"unrealizedProfit,string"`
	PositionInitialMargin  float64   `json:"positionInitialMargin,string"`
	OpenOrderInitialMargin float64   `json:"openOrderInitialMargin,string"`
	Leverage               float64   `json:"leverage,string"`
	Isolated               bool      `json:"isolated"`
	PositionSide           string    `json:"positionSide"`
	EntryPrice             float64   `json:"entryPrice,string"`
	MaxQty                 float64   `json:"maxQty,string"`
	UpdateTime             time.Time `json:"updateTime"`
	NotionalValue          float64   `json:"notionalValue,string"`
	IsolatedWallet         float64   `json:"isolatedWallet,string"`
}

FuturesAccountInformationPositions holds account position data

func (*FuturesAccountInformationPositions) UnmarshalJSON

func (a *FuturesAccountInformationPositions) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type FuturesAccountTradeList

type FuturesAccountTradeList struct {
	Symbol          string  `json:"symbol"`
	ID              int64   `json:"id"`
	OrderID         int64   `json:"orderID"`
	Pair            string  `json:"pair"`
	Side            string  `json:"side"`
	Price           string  `json:"price"`
	Qty             float64 `json:"qty"`
	RealizedPNL     float64 `json:"realizedPNL"`
	MarginAsset     string  `json:"marginAsset"`
	BaseQty         float64 `json:"baseQty"`
	Commission      float64 `json:"commission"`
	CommissionAsset string  `json:"commissionAsset"`
	Timestamp       int64   `json:"timestamp"`
	PositionSide    string  `json:"positionSide"`
	Buyer           bool    `json:"buyer"`
	Maker           bool    `json:"maker"`
}

FuturesAccountTradeList stores account trade list data

type FuturesBasisData

type FuturesBasisData struct {
	Pair         string  `json:"pair"`
	ContractType string  `json:"contractType"`
	FuturesPrice float64 `json:"futuresPrice,string"`
	IndexPrice   float64 `json:"indexPrice,string"`
	Basis        float64 `json:"basis,string"`
	BasisRate    float64 `json:"basisRate,string"`
	Timestamp    int64   `json:"timestamp"`
}

FuturesBasisData gets futures basis data

type FuturesCandleStick

type FuturesCandleStick struct {
	OpenTime                time.Time
	Open                    float64
	High                    float64
	Low                     float64
	Close                   float64
	Volume                  float64
	CloseTime               time.Time
	BaseAssetVolume         float64
	NumberOfTrades          int64
	TakerBuyVolume          float64
	TakerBuyBaseAssetVolume float64
}

FuturesCandleStick holds kline data

type FuturesIncomeHistoryData

type FuturesIncomeHistoryData struct {
	Symbol     string  `json:"symbol"`
	IncomeType string  `json:"incomeType"`
	Income     float64 `json:"income,string"`
	Asset      string  `json:"asset"`
	Info       string  `json:"info"`
	Timestamp  int64   `json:"time"`
}

FuturesIncomeHistoryData stores futures income history data

type FuturesLeverageData

type FuturesLeverageData struct {
	Leverage int64   `json:"leverage"`
	MaxQty   float64 `json:"maxQty,string"`
	Symbol   string  `json:"symbol"`
}

FuturesLeverageData stores leverage data for futures

type FuturesNewOrderRequest

type FuturesNewOrderRequest struct {
	Symbol           currency.Pair
	Side             string
	PositionSide     string
	OrderType        string
	TimeInForce      string
	NewClientOrderID string
	ClosePosition    string
	WorkingType      string
	NewOrderRespType string
	Quantity         float64
	Price            float64
	StopPrice        float64
	ActivationPrice  float64
	CallbackRate     float64
	ReduceOnly       bool
	PriceProtect     bool
}

FuturesNewOrderRequest stores all the data needed to submit a delivery/coin-margined-futures order.

type FuturesOrderData

type FuturesOrderData struct {
	AvgPrice      float64   `json:"avgPrice,string"`
	ClientOrderID string    `json:"clientOrderId"`
	CumBase       string    `json:"cumBase"`
	ExecutedQty   float64   `json:"executedQty,string"`
	OrderID       int64     `json:"orderId"`
	OrigQty       float64   `json:"origQty,string"`
	OrigType      string    `json:"origType"`
	Price         float64   `json:"price,string"`
	ReduceOnly    bool      `json:"reduceOnly"`
	Side          string    `json:"side"`
	PositionSide  string    `json:"positionSide"`
	Status        string    `json:"status"`
	StopPrice     float64   `json:"stopPrice,string"`
	ClosePosition bool      `json:"closePosition"`
	Symbol        string    `json:"symbol"`
	Pair          string    `json:"pair"`
	Time          time.Time `json:"time"`
	TimeInForce   string    `json:"timeInForce"`
	OrderType     string    `json:"type"`
	ActivatePrice float64   `json:"activatePrice,string"`
	PriceRate     float64   `json:"priceRate,string"`
	UpdateTime    time.Time `json:"updateTime"`
	WorkingType   string    `json:"workingType"`
	PriceProtect  bool      `json:"priceProtect"`
}

FuturesOrderData stores order data for futures

func (*FuturesOrderData) UnmarshalJSON

func (a *FuturesOrderData) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type FuturesOrderGetData

type FuturesOrderGetData struct {
	AveragePrice       float64   `json:"avgPrice,string"`
	ClientOrderID      string    `json:"clientOrderID"`
	CumulativeQuantity float64   `json:"cumQty,string"`
	CumulativeBase     float64   `json:"cumBase,string"`
	ExecutedQuantity   float64   `json:"executedQty,string"`
	OrderID            int64     `json:"orderId"`
	OriginalQuantity   float64   `json:"origQty,string"`
	OriginalType       string    `json:"origType"`
	Price              float64   `json:"price,string"`
	ReduceOnly         bool      `json:"reduceOnly"`
	Side               string    `json:"buy"`
	PositionSide       string    `json:"positionSide"`
	Status             string    `json:"status"`
	StopPrice          float64   `json:"stopPrice,string"`
	ClosePosition      bool      `json:"closePosition"`
	Symbol             string    `json:"symbol"`
	Pair               string    `json:"pair"`
	TimeInForce        string    `json:"timeInForce"`
	OrderType          string    `json:"type"`
	ActivatePrice      float64   `json:"activatePrice,string"`
	PriceRate          float64   `json:"priceRate,string"`
	Time               time.Time `json:"time"`
	UpdateTime         time.Time `json:"updateTime"`
	WorkingType        string    `json:"workingType"`
	PriceProtect       bool      `json:"priceProtect"`
}

FuturesOrderGetData stores futures order data for get requests

func (*FuturesOrderGetData) UnmarshalJSON

func (a *FuturesOrderGetData) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type FuturesOrderPlaceData

type FuturesOrderPlaceData struct {
	ClientOrderID string  `json:"clientOrderId"`
	CumQty        float64 `json:"cumQty,string"`
	CumBase       float64 `json:"cumBase,string"`
	ExecuteQty    float64 `json:"executedQty,string"`
	OrderID       int64   `json:"orderId"`
	AvgPrice      float64 `json:"avgPrice,string"`
	OrigQty       float64 `json:"origQty,string"`
	Price         float64 `json:"price,string"`
	ReduceOnly    bool    `json:"reduceOnly"`
	Side          string  `json:"side"`
	PositionSide  string  `json:"positionSide"`
	Status        string  `json:"status"`
	StopPrice     float64 `json:"stopPrice,string"`
	ClosePosition bool    `json:"closePosition"`
	Symbol        string  `json:"symbol"`
	Pair          string  `json:"pair"`
	TimeInForce   string  `json:"TimeInForce"`
	OrderType     string  `json:"type"`
	OrigType      string  `json:"origType"`
	ActivatePrice float64 `json:"activatePrice,string"`
	PriceRate     float64 `json:"priceRate,string"`
	UpdateTime    int64   `json:"updateTime"`
	WorkingType   string  `json:"workingType"`
	PriceProtect  bool    `json:"priceProtect"`
}

FuturesOrderPlaceData stores futures order data

type FuturesPositionInformation

type FuturesPositionInformation struct {
	Symbol           string  `json:"symbol"`
	PositionAmount   float64 `json:"positionAmt,string"`
	EntryPrice       float64 `json:"entryPrice,string"`
	MarkPrice        float64 `json:"markPrice,string"`
	UnrealizedProfit float64 `json:"unRealizedProfit,string"`
	LiquidationPrice float64 `json:"liquidation,string"`
	Leverage         int64   `json:"leverage"`
	MaxQty           float64 `json:"maxQty"`
	MarginType       string  `json:"marginType"`
	IsolatedMargin   float64 `json:"isolatedMargin,string"`
	IsAutoAddMargin  bool    `json:"isAutoAddMargin"`
	PositionSide     string  `json:"positionSide"`
}

FuturesPositionInformation stores futures position info

type FuturesPublicTradesData

type FuturesPublicTradesData struct {
	ID           int64   `json:"id"`
	Price        float64 `json:"price,string"`
	Qty          float64 `json:"qty,string"`
	QuoteQty     float64 `json:"quoteQty,string"`
	Time         int64   `json:"time"`
	IsBuyerMaker bool    `json:"isBuyerMaker"`
}

FuturesPublicTradesData stores recent public trades for futures

type GenericAuthResponse

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

GenericAuthResponse is a general data response for a post auth request

type GetPositionMarginChangeHistoryData

type GetPositionMarginChangeHistoryData struct {
	Amount           float64 `json:"amount"`
	Asset            string  `json:"asset"`
	Symbol           string  `json:"symbol"`
	Timestamp        int64   `json:"time"`
	MarginChangeType int64   `json:"type"`
	PositionSide     string  `json:"positionSide"`
}

GetPositionMarginChangeHistoryData gets margin change history for positions

type GlobalLongShortRatio

type GlobalLongShortRatio struct {
	Symbol         string  `json:"symbol"`
	LongShortRatio float64 `json:"longShortRatio"`
	LongAccount    float64 `json:"longAccount"`
	ShortAccount   float64 `json:"shortAccount"`
	Timestamp      string  `json:"timestamp"`
}

GlobalLongShortRatio stores ratio data of all longs vs shorts

type HistoricalTrade

type HistoricalTrade struct {
	ID            int64     `json:"id"`
	Price         float64   `json:"price,string"`
	Quantity      float64   `json:"qty,string"`
	QuoteQuantity float64   `json:"quoteQty,string"`
	Time          time.Time `json:"time"`
	IsBuyerMaker  bool      `json:"isBuyerMaker"`
	IsBestMatch   bool      `json:"isBestMatch"`
}

HistoricalTrade holds recent trade data

func (*HistoricalTrade) UnmarshalJSON

func (a *HistoricalTrade) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type IncomeRequest

type IncomeRequest struct {
	Symbol     string     `json:"symbol"`     //交易对
	IncomeType IncomeType `json:"incomeType"` // 收益类型
	StartTime  int64      `json:"startTime"`
	EndTime    int64      `json:"endTime"`
	Limit      int64      `json:"limit"`
}

type IncomeResponse

type IncomeResponse struct {
	Symbol     string     `json:"symbol"`         //交易对
	Income     float64    `json:"income, string"` //资金流数量,正数代表流入,负数代表流出
	IncomeType IncomeType `json:"incomeType"`     // 收益类型
	Asset      string     `json:"asset"`
	Info       string     `json:"info,string"`
	Time       time.Time  `json:"time"`
	TranId     int64      `json:"tranId,string"`
	TradeId    int64      `json:"tradeId"`
}

type IncomeType

type IncomeType string

IncomeType收益类型

type IndexMarkPrice

type IndexMarkPrice struct {
	Symbol               string  `json:"symbol"`
	Pair                 string  `json:"pair"`
	MarkPrice            float64 `json:"markPrice,string"`
	IndexPrice           float64 `json:"indexPrice,string"`
	EstimatedSettlePrice float64 `json:"estimatedSettlePrice,string"`
	LastFundingRate      string  `json:"lastFundingRate"`
	NextFundingTime      int64   `json:"nextFundingTime"`
	Time                 int64   `json:"time"`
}

IndexMarkPrice stores data for index and mark prices

type InterestHistoryData

type InterestHistoryData struct {
	Asset       string  `json:"asset"`
	Interest    float64 `json:"interest"`
	LendingType string  `json:"lendingType"`
	ProductName string  `json:"productName"`
	Time        string  `json:"time"`
}

InterestHistoryData gets interest history data

type KlineStream

type KlineStream struct {
	EventType string          `json:"e"`
	EventTime time.Time       `json:"E"`
	Symbol    string          `json:"s"`
	Kline     KlineStreamData `json:"k"`
}

KlineStream holds the kline stream data

func (*KlineStream) UnmarshalJSON

func (a *KlineStream) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type KlineStreamData

type KlineStreamData struct {
	StartTime                time.Time `json:"t"`
	CloseTime                time.Time `json:"T"`
	Symbol                   string    `json:"s"`
	Interval                 string    `json:"i"`
	FirstTradeID             int64     `json:"f"`
	LastTradeID              int64     `json:"L"`
	OpenPrice                float64   `json:"o,string"`
	ClosePrice               float64   `json:"c,string"`
	HighPrice                float64   `json:"h,string"`
	LowPrice                 float64   `json:"l,string"`
	Volume                   float64   `json:"v,string"`
	NumberOfTrades           int64     `json:"n"`
	KlineClosed              bool      `json:"x"`
	Quote                    float64   `json:"q,string"`
	TakerBuyBaseAssetVolume  float64   `json:"V,string"`
	TakerBuyQuoteAssetVolume float64   `json:"Q,string"`
}

KlineStreamData defines kline streaming data

type KlinesContractRequestParams

type KlinesContractRequestParams struct {
	Pair string // Required field; example LTCBTC, BTCUSDT

	Interval  string // Time interval period
	Limit     int    // Default 500; max 500.
	StartTime int64
	EndTime   int64
	// contains filtered or unexported fields
}

KlinesContractRequestParams represents Klines request data.

type KlinesRequestParams

type KlinesRequestParams struct {
	Symbol    currency.Pair // Required field; example LTCBTC, BTCUSDT
	Interval  string        // Time interval period
	Limit     int           // Default 500; max 500.
	StartTime time.Time
	EndTime   time.Time
}

KlinesRequestParams represents Klines request data.

type LevelDetail

type LevelDetail struct {
	Level         string  `json:"level"`
	MaxBorrowable float64 `json:"maxBorrowable,string"`
	InterestRate  float64 `json:"interestRate,string"`
}

LevelDetail stores level detail data

type MarginAccount

type MarginAccount struct {
	BorrowEnabled       bool                 `json:"borrowEnabled"`
	MarginLevel         float64              `json:"marginLevel,string"`
	TotalAssetOfBtc     float64              `json:"totalAssetOfBtc,string"`
	TotalLiabilityOfBtc float64              `json:"totalLiabilityOfBtc,string"`
	TotalNetAssetOfBtc  float64              `json:"totalNetAssetOfBtc,string"`
	TradeEnabled        bool                 `json:"tradeEnabled"`
	TransferEnabled     bool                 `json:"transferEnabled"`
	UserAssets          []MarginAccountAsset `json:"userAssets"`
}

MarginAccount holds the margin account data

type MarginAccountAsset

type MarginAccountAsset struct {
	Asset    string  `json:"asset"`
	Borrowed float64 `json:"borrowed,string"`
	Free     float64 `json:"free,string"`
	Interest float64 `json:"interest,string"`
	Locked   float64 `json:"locked,string"`
	NetAsset float64 `json:"netAsset,string"`
}

MarginAccountAsset holds each individual margin account asset

type MarginInfoData

type MarginInfoData struct {
	Data []struct {
		MarginRatio string `json:"marginRatio"`
		Base        struct {
			AssetName    string        `json:"assetName"`
			LevelDetails []LevelDetail `json:"levelDetails"`
		} `json:"base"`
		Quote struct {
			AssetName    string        `json:"assetName"`
			LevelDetails []LevelDetail `json:"levelDetails"`
		} `json:"quote"`
	} `json:"data"`
}

MarginInfoData stores margin info data

type MarginType

type MarginType string

MarginType 保证金模式

type MarkPriceData

type MarkPriceData struct {
	Symbol          string  `json:"symbol"`
	MarkPrice       float64 `json:"markPrice"`
	LastFundingRate float64 `json:"lastFundingRate"`
	NextFundingTime int64   `json:"nextFundingTime"`
	Time            int64   `json:"time"`
}

MarkPriceData stores mark price data for futures

type MarkPriceStream

type MarkPriceStream struct {
	EventType            string  `json:"e"`        // 事件类型
	EventTime            int64   `json:"E"`        // 事件时间
	Symbol               string  `json:"s"`        // 交易对
	MarkPrice            float64 `json:"p,string"` // 标记价格
	IndexPrice           float64 `json:"i,string"` // 现货指数价格
	EstimatedSettlePrice float64 `json:"P,string"` // 预估结算价,仅在结算前最后一小时有参考价值
	LastFundingRate      float64 `json:"r,string"` // 资金费率
	NextFundingTime      int64   `json:"T"`        // 下次资金时间
}

MarkPriceStream holds the ticker stream data

type MarkPriceStreamResponse

type MarkPriceStreamResponse struct {
	AssetType            asset.Item
	Exchange             string
	EventType            string        // 事件类型
	EventTime            time.Time     // 事件时间
	Symbol               currency.Pair // 交易对
	MarkPrice            float64       // 标记价格
	IndexPrice           float64       // 现货指数价格
	EstimatedSettlePrice float64       // 预估结算价,仅在结算前最后一小时有参考价值
	LastFundingRate      float64       // 资金费率
	NextFundingTime      time.Time     // 下次资金时间
}

type ModifyIsolatedMarginData

type ModifyIsolatedMarginData struct {
	Amount  float64 `json:"amount"`
	Code    int64   `json:"code"`
	Msg     string  `json:"msg"`
	ModType string  `json:"modType"`
}

ModifyIsolatedMarginData stores margin modification data

type NewOrderContractRequest

type NewOrderContractRequest struct {
	// Symbol (currency pair to trade)
	Symbol string
	// Side Buy or Sell
	Side order.Side
	// 持仓方向,单向持仓模式下非必填,默认且仅可填BOTH;在双向持仓模式下必填,且仅可选择 LONG 或 SHORT
	PositionSide PositionSide
	// Type 订单类型 LIMIT, MARKET, STOP, TAKE_PROFIT, STOP_MARKET, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET
	Type RequestParamsOrderType
	// true, false; 非双开模式下默认false;双开模式下不接受此参数; 使用closePosition不支持此参数。
	ReduceOnly string
	// 下单数量,使用closePosition不支持此参数
	Quantity float64
	//委托价格
	Price float64
	//用户自定义的订单号,不可以重复出现在挂单中。如空缺系统会自动赋值。必须满足正则规则 ^[a-zA-Z0-9-_]{1,36}$
	NewClientOrderID string
	StopPrice        float64 // Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
	// true, false;触发后全部平仓,仅支持STOP_MARKET和TAKE_PROFIT_MARKET;不与quantity合用;自带只平仓效果,不与reduceOnly 合用
	ClosePosition float64
	// 追踪止损激活价格,仅TRAILING_STOP_MARKET 需要此参数, 默认为下单当前市场价格(支持不同workingType)
	ActivationPrice float64
	// 追踪止损回调比例,可取值范围[0.1, 5],其中 1代表1% ,仅TRAILING_STOP_MARKET 需要此参数
	CallbackRate float64
	// TimeInForce specifies how long the order remains in effect.
	// Examples are (Good Till Cancel (GTC), Immediate or Cancel (IOC) and Fill Or Kill (FOK))
	TimeInForce RequestParamsTimeForceType
	//  触发类型: MARK_PRICE(标记价格), CONTRACT_PRICE(合约最新价). 默认 CONTRACT_PRICE
	WorkingType string

	NewOrderRespType string
	// contains filtered or unexported fields
}

NewOrderContractRequest request type

type NewOrderContractResponse

type NewOrderContractResponse struct {
	Symbol        string  `json:"symbol"` //交易对
	OrderID       int64   `json:"orderId"`
	ClientOrderID string  `json:"clientOrderId"`
	AvgPrice      float64 `json:"avgPrice, string"` //平均成交价
	Price         float64 `json:"price,string"`     //委托价格
	OrigQty       float64 `json:"origQty,string"`   //原始委托数量
	CumQty        float64 `json:"cumQty,string"`
	CumQuote      float64 `json:"cumQuote,string"` //成交金额
	// The cumulative amount of the quote that has been spent (with a BUY order) or received (with a SELL order).
	ExecutedQty   float64                    `json:"executedQty,string"` //成交量
	Status        order.Status               `json:"status"`             //订单状态
	TimeInForce   RequestParamsTimeForceType `json:"timeInForce"`        //有效方法
	Type          order.Type                 `json:"type"`               //订单类型
	Side          order.Side                 `json:"side"`               //买卖方向
	PositionSide  string                     `json:"positionSide"`       //持仓方向
	StopPrice     string                     `json:"stopPrice"`          //触发价,对`TRAILING_STOP_MARKET`无效
	ClosePosition bool                       `json:"closePosition"`      //是否条件全平仓
	OrigType      string                     `json:"origType"`           //触发前订单类型
	ActivatePrice string                     `json:"activatePrice"`      //跟踪止损激活价格, 仅`TRAILING_STOP_MARKET` 订单返回此字段
	PriceRate     string                     `json:"priceRate"`          //跟踪止损回调比例, 仅`TRAILING_STOP_MARKET` 订单返回此字段

	UpdateTime   time.Time   `json:"updateTime"`   // 更新时间
	WorkingType  WorkingType `json:"workingType"`  // 条件价格触发类型
	PriceProtect bool        `json:"priceProtect"` // 是否开启条件单触发保护
}

NewOrderContractResponse is the return structured response from the exchange

type NewOrderRequest

type NewOrderRequest struct {
	// Symbol (currency pair to trade)
	Symbol currency.Pair
	// Side Buy or Sell
	Side string
	// TradeType (market or limit order)
	TradeType RequestParamsOrderType
	// TimeInForce specifies how long the order remains in effect.
	// Examples are (Good Till Cancel (GTC), Immediate or Cancel (IOC) and Fill Or Kill (FOK))
	TimeInForce RequestParamsTimeForceType
	// Quantity is the total base qty spent or received in an order.
	Quantity float64
	// QuoteOrderQty is the total quote qty spent or received in a MARKET order.
	QuoteOrderQty    float64
	Price            float64
	NewClientOrderID string
	StopPrice        float64 // Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
	IcebergQty       float64 // Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.
	NewOrderRespType string
}

NewOrderRequest request type

type NewOrderResponse

type NewOrderResponse struct {
	Code            int       `json:"code"`
	Msg             string    `json:"msg"`
	Symbol          string    `json:"symbol"`
	OrderID         int64     `json:"orderId"`
	ClientOrderID   string    `json:"clientOrderId"`
	TransactionTime time.Time `json:"transactTime"`
	Price           float64   `json:"price,string"`
	OrigQty         float64   `json:"origQty,string"`
	ExecutedQty     float64   `json:"executedQty,string"`
	// The cumulative amount of the quote that has been spent (with a BUY order) or received (with a SELL order).
	CumulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
	Status             string  `json:"status"`
	TimeInForce        string  `json:"timeInForce"`
	Type               string  `json:"type"`
	Side               string  `json:"side"`
	Fills              []struct {
		Price           float64 `json:"price,string"`
		Qty             float64 `json:"qty,string"`
		Commission      float64 `json:"commission,string"`
		CommissionAsset string  `json:"commissionAsset"`
	} `json:"fills"`
}

NewOrderResponse is the return structured response from the exchange

func (*NewOrderResponse) UnmarshalJSON

func (a *NewOrderResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type NotionalBracketData

type NotionalBracketData struct {
	Pair     string `json:"pair"`
	Brackets []struct {
		Bracket          int64   `json:"bracket"`
		InitialLeverage  float64 `json:"initialLeverage"`
		QtyCap           float64 `json:"qtyCap"`
		QtylFloor        float64 `json:"qtyFloor"`
		MaintMarginRatio float64 `json:"maintMarginRatio"`
	}
}

NotionalBracketData stores notional bracket data

type OpenInterestData

type OpenInterestData struct {
	Symbol       string  `json:"symbol"`
	Pair         string  `json:"pair"`
	OpenInterest float64 `json:"openInterest,string"`
	ContractType string  `json:"contractType"`
	Time         int64   `json:"time"`
}

OpenInterestData stores open interest data

type OpenInterestStats

type OpenInterestStats struct {
	Pair                 string  `json:"pair"`
	ContractType         string  `json:"contractType"`
	SumOpenInterest      float64 `json:"sumOpenInterest,string"`
	SumOpenInterestValue float64 `json:"sumOpenInterestValue,string"`
	Timestamp            int64   `json:"timestamp"`
}

OpenInterestStats stores stats for open interest data

type OrderBook

type OrderBook struct {
	Symbol       string
	LastUpdateID int64
	Code         int
	Msg          string
	Bids         []OrderbookItem
	Asks         []OrderbookItem
}

OrderBook actual structured data that can be used for orderbook

type OrderBookData

type OrderBookData struct {
	Code         int         `json:"code"`
	Msg          string      `json:"msg"`
	LastUpdateID int64       `json:"lastUpdateId"`
	Bids         [][2]string `json:"bids"`
	Asks         [][2]string `json:"asks"`
}

OrderBookData is resp data from orderbook endpoint

type OrderBookDataRequestParams

type OrderBookDataRequestParams struct {
	Symbol currency.Pair `json:"symbol"` // Required field; example LTCBTC,BTCUSDT
	Limit  int           `json:"limit"`  // Default 100; max 1000. Valid limits:[5, 10, 20, 50, 100, 500, 1000]
}

OrderBookDataRequestParams represents Klines request data.

type OrderVars

type OrderVars struct {
	Side      order.Side
	Status    order.Status
	OrderType order.Type
	Fee       float64
}

OrderVars stores side, status and type for any order/trade

type OrderbookData

type OrderbookData struct {
	LastUpdateID int64       `json:"lastUpdateID"`
	Timestamp    int64       `json:"T"`
	Bids         [][2]string `json:"bids"`
	Asks         [][2]string `json:"asks"`
}

OrderbookData stores ob data for umargined and cmargined futures

type OrderbookItem

type OrderbookItem struct {
	Price    float64
	Quantity float64
}

OrderbookItem stores an individual orderbook item

type PerpsExchangeInfo

type PerpsExchangeInfo struct {
	Symbols []SymbolsData `json:"symbols"`
}

PerpsExchangeInfo stores data for perps

type PlaceBatchOrderData

type PlaceBatchOrderData struct {
	Symbol           string  `json:"symbol"`
	Side             string  `json:"side"`
	PositionSide     string  `json:"positionSide,omitempty"`
	OrderType        string  `json:"type"`
	TimeInForce      string  `json:"timeInForce,omitempty"`
	Quantity         float64 `json:"quantity"`
	ReduceOnly       string  `json:"reduceOnly,omitempty"`
	Price            float64 `json:"price"`
	NewClientOrderID string  `json:"newClientOrderId,omitempty"`
	StopPrice        float64 `json:"stopPrice,omitempty"`
	ActivationPrice  float64 `json:"activationPrice,omitempty"`
	CallbackRate     float64 `json:"callbackRate,omitempty"`
	WorkingType      string  `json:"workingType,omitempty"`
	PriceProtect     string  `json:"priceProtect,omitempty"`
	NewOrderRespType string  `json:"newOrderRespType,omitempty"`
}

PlaceBatchOrderData stores batch order data for placing

type PositionMarginHistoryRequest

type PositionMarginHistoryRequest struct {
	Symbol    currency.Pair `json:"symbol"`
	Type      int           `json:"type"`
	StartTime int64         `json:"startTime"`
	EndTime   int64         `json:"endTime"`
	Limit     int64         `json:"limit"`
}

PositionMarginHistoryRequest 逐仓保证金变动历史 (TRADE)

type PositionMarginHistoryResponse

type PositionMarginHistoryResponse struct {
	Amount       float64            `json:"amount"` // 保证金资金
	Symbol       string             `json:"symbol"`
	Asset        string             `json:"asset"` //  持仓方向
	Type         PositionMarginType `json:"type"`
	Time         time.Time          `json:"time"`
	PositionSide PositionSide       `json:"positionSide"` //  持仓方向
}

PositionMarginHistoryResponse 逐仓保证金变动历史 (TRADE)

type PositionMarginRequest

type PositionMarginRequest struct {
	Symbol       currency.Pair      `json:"symbol"`
	PositionSide PositionSide       `json:"positionSide"` //  持仓方向
	Amount       float64            `json:"amount"`       // 保证金资金
	Type         PositionMarginType `json:"type"`
}

PositionMarginRequest 调整逐仓保证金

type PositionMarginType

type PositionMarginType int

PositionMarginType 调整逐仓保证金-调整方向

type PositionRiskResponse

type PositionRiskResponse struct {
	EntryPrice       float64      `json:"entryPrice,string"` //开仓均价
	MarginType       MarginType   `json:"marginType"`        //逐仓模式或全仓模式
	IsAutoAddMargin  bool         `json:"isAutoAddMargin, string"`
	IsolatedMargin   float64      `json:"isolatedMargin, string"`   //  逐仓保证金
	Leverage         int64        `json:"leverage, string"`         // 当前杠杆倍数
	LiquidationPrice float64      `json:"liquidationPrice, string"` // 参考强平价格
	MarkPrice        float64      `json:"markPrice, string"`        // 当前标记价格
	MaxNotionalValue float64      `json:"maxNotionalValue, string"` // 当前杠杆倍数允许的名义价值上限
	PositionAmt      float64      `json:"positionAmt, string"`      // 头寸数量,符号代表多空方向, 正数为多,负数为空
	Symbol           string       `json:"symbol"`                   // 交易对
	UnRealizedProfit float64      `json:"unRealizedProfit, string"` // 持仓未实现盈亏
	PositionSide     PositionSide `json:"positionSide"`             //  持仓方向
}

PositionRiskResponse 用户持仓风险

type PositionSide

type PositionSide string

PositionSide 持仓方向

type PreminuIndexResponse

type PreminuIndexResponse struct {
	Symbol          string    `json:"symbol"`          // Required field; example LTCBTC, BTCUSDT
	MarkPrice       float64   `json:"markPrice"`       // 标记价格
	IndexPrice      float64   `json:"indexPrice"`      // 指数价格
	LastFundingRate float64   `json:"lastFundingRate"` // 最近更新的资金费率
	NextFundingTime time.Time `json:"nextFundingTime"` // 下次资金费时间
	InterestRate    float64   `json:"interestRate"`    // 标的资产基础利率
	Time            time.Time `json:"time"`            // 更新时间
}

PreminuIndexResponse represents Klines request data.

type PriceChangeStats

type PriceChangeStats struct {
	Symbol             string    `json:"symbol"`
	PriceChange        float64   `json:"priceChange,string"`
	PriceChangePercent float64   `json:"priceChangePercent,string"`
	WeightedAvgPrice   float64   `json:"weightedAvgPrice,string"`
	PrevClosePrice     float64   `json:"prevClosePrice,string"`
	LastPrice          float64   `json:"lastPrice,string"`
	LastQty            float64   `json:"lastQty,string"`
	BidPrice           float64   `json:"bidPrice,string"`
	AskPrice           float64   `json:"askPrice,string"`
	OpenPrice          float64   `json:"openPrice,string"`
	HighPrice          float64   `json:"highPrice,string"`
	LowPrice           float64   `json:"lowPrice,string"`
	Volume             float64   `json:"volume,string"`
	QuoteVolume        float64   `json:"quoteVolume,string"`
	OpenTime           time.Time `json:"openTime"`
	CloseTime          time.Time `json:"closeTime"`
	FirstID            int64     `json:"firstId"`
	LastID             int64     `json:"lastId"`
	Count              int64     `json:"count"`
}

PriceChangeStats contains statistics for the last 24 hours trade

func (*PriceChangeStats) UnmarshalJSON

func (a *PriceChangeStats) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type QueryOrderData

type QueryOrderData struct {
	Code                int       `json:"code"`
	Msg                 string    `json:"msg"`
	Symbol              string    `json:"symbol"`
	OrderID             int64     `json:"orderId"`
	ClientOrderID       string    `json:"clientOrderId"`
	Price               float64   `json:"price,string"`
	OrigQty             float64   `json:"origQty,string"`
	ExecutedQty         float64   `json:"executedQty,string"`
	Status              string    `json:"status"`
	TimeInForce         string    `json:"timeInForce"`
	Type                string    `json:"type"`
	Side                string    `json:"side"`
	StopPrice           float64   `json:"stopPrice,string"`
	IcebergQty          float64   `json:"icebergQty,string"`
	Time                time.Time `json:"time"`
	IsWorking           bool      `json:"isWorking"`
	CummulativeQuoteQty float64   `json:"cummulativeQuoteQty,string"`
	OrderListID         int64     `json:"orderListId"`
	OrigQuoteOrderQty   float64   `json:"origQuoteOrderQty,string"`
	UpdateTime          time.Time `json:"updateTime"`
}

QueryOrderData holds query order data

func (*QueryOrderData) UnmarshalJSON

func (a *QueryOrderData) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type RateLimit

type RateLimit struct {
	SpotRate           *rate.Limiter
	SpotOrdersRate     *rate.Limiter
	UFuturesRate       *rate.Limiter
	UFuturesOrdersRate *rate.Limiter
	CFuturesRate       *rate.Limiter
	CFuturesOrdersRate *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 RecentTrade

type RecentTrade struct {
	ID           int64     `json:"id"`
	Price        float64   `json:"price,string"`
	Quantity     float64   `json:"qty,string"`
	Time         time.Time `json:"time"`
	IsBuyerMaker bool      `json:"isBuyerMaker"`
	IsBestMatch  bool      `json:"isBestMatch"`
}

RecentTrade holds recent trade data

func (*RecentTrade) UnmarshalJSON

func (a *RecentTrade) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type RecentTradeRequestParams

type RecentTradeRequestParams struct {
	Symbol currency.Pair `json:"symbol"` // Required field. example LTCBTC, BTCUSDT
	Limit  int           `json:"limit"`  // Default 500; max 500.
}

RecentTradeRequestParams represents Klines request data.

type RequestParamsOrderType

type RequestParamsOrderType string

RequestParamsOrderType trade order type

type RequestParamsTimeForceType

type RequestParamsTimeForceType string

RequestParamsTimeForceType Time in force

type Response

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

Response holds basic binance api response data

type SpotSubmit

type SpotSubmit struct {
	AssetType        asset.Item
	Symbol           currency.Pair
	Side             order.Side
	Type             order.Type
	TimeInForce      RequestParamsTimeForceType
	QuoteOrderQty    float64
	Quantity         float64
	Price            float64
	NewClientOrderId string
	StopPrice        float64
	IcebergQty       float64
}

Submit contains all properties of an order that may be required for an order to be created on an exchange Each exchange has their own requirements, so not all fields are required to be populated

type SpotTradeFeeResponse

type SpotTradeFeeResponse struct {
	Symbol          string  `json:"symbol"` // 交易对
	MakerCommission float64 `json:"makerCommission,string"`
	TakerCommission float64 `json:"takerCommission,string"`
}

type SymbolOrderBookTicker

type SymbolOrderBookTicker struct {
	Symbol   string  `json:"symbol"`
	BidPrice float64 `json:"bidPrice,string"`
	AskPrice float64 `json:"askPrice,string"`
	BidQty   float64 `json:"bidQty,string"`
	AskQty   float64 `json:"askQty,string"`
	Time     int64   `json:"time"`
}

SymbolOrderBookTicker stores orderbook ticker data

type SymbolPrice

type SymbolPrice struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
}

SymbolPrice holds basic symbol price

type SymbolPriceTicker

type SymbolPriceTicker struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
	Time   int64   `json:"time"`
}

SymbolPriceTicker stores ticker price stats

type SymbolsData

type SymbolsData struct {
	Symbol string `json:"symbol"`
}

SymbolsData stores perp futures' symbols

type TakerBuySellVolume

type TakerBuySellVolume struct {
	Pair           string  `json:"pair"`
	ContractType   string  `json:"contractType"`
	TakerBuyVolume float64 `json:"takerBuyVol,string"`
	BuySellRatio   float64 `json:"takerSellVol,string"`
	BuyVol         float64 `json:"takerBuyVolValue,string"`
	SellVol        float64 `json:"takerSellVolValue,string"`
	Timestamp      int64   `json:"timestamp"`
}

TakerBuySellVolume stores taker buy sell volume

type TickerStream

type TickerStream struct {
	EventType              string    `json:"e"`
	EventTime              time.Time `json:"E"`
	Symbol                 string    `json:"s"`
	PriceChange            float64   `json:"p,string"`
	PriceChangePercent     float64   `json:"P,string"`
	WeightedAvgPrice       float64   `json:"w,string"`
	ClosePrice             float64   `json:"x,string"`
	LastPrice              float64   `json:"c,string"`
	LastPriceQuantity      float64   `json:"Q,string"`
	BestBidPrice           float64   `json:"b,string"`
	BestBidQuantity        float64   `json:"B,string"`
	BestAskPrice           float64   `json:"a,string"`
	BestAskQuantity        float64   `json:"A,string"`
	OpenPrice              float64   `json:"o,string"`
	HighPrice              float64   `json:"h,string"`
	LowPrice               float64   `json:"l,string"`
	TotalTradedVolume      float64   `json:"v,string"`
	TotalTradedQuoteVolume float64   `json:"q,string"`
	OpenTime               time.Time `json:"O"`
	CloseTime              time.Time `json:"C"`
	FirstTradeID           int64     `json:"F"`
	LastTradeID            int64     `json:"L"`
	NumberOfTrades         int64     `json:"n"`
}

TickerStream holds the ticker stream data

func (*TickerStream) UnmarshalJSON

func (a *TickerStream) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type TopTraderAccountRatio

type TopTraderAccountRatio struct {
	Pair           string  `json:"pair"`
	LongShortRatio float64 `json:"longShortRatio,string"`
	LongAccount    float64 `json:"longAccount,string"`
	ShortAccount   float64 `json:"shortAccount,string"`
	Timestamp      int64   `json:"timestamp"`
}

TopTraderAccountRatio stores account ratio data for top traders

type TopTraderPositionRatio

type TopTraderPositionRatio struct {
	Pair           string  `json:"pair"`
	LongShortRatio float64 `json:"longShortRatio,string"`
	LongPosition   float64 `json:"longPosition,string"`
	ShortPosition  float64 `json:"shortPosition,string"`
	Timestamp      int64   `json:"timestamp"`
}

TopTraderPositionRatio stores position ratio for top trader accounts

type TradeStream

type TradeStream struct {
	EventType      string    `json:"e"`
	EventTime      time.Time `json:"E"`
	Symbol         string    `json:"s"`
	TradeID        int64     `json:"t"`
	Price          string    `json:"p"`
	Quantity       string    `json:"q"`
	BuyerOrderID   int64     `json:"b"`
	SellerOrderID  int64     `json:"a"`
	TimeStamp      time.Time `json:"T"`
	Maker          bool      `json:"m"`
	BestMatchPrice bool      `json:"M"`
}

TradeStream holds the trade stream data

func (*TradeStream) UnmarshalJSON

func (a *TradeStream) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type TransferType

type TransferType string

TransferType 用户万向划转 类型

type U24HrPriceChangeStats

type U24HrPriceChangeStats struct {
	Symbol             string  `json:"symbol"`
	PriceChange        float64 `json:"priceChange,string"`
	PriceChangePercent float64 `json:"priceChangePercent,string"`
	WeightedAvgPrice   float64 `json:"weightedAvgPrice,string"`
	PrevClosePrice     float64 `json:"prevClosePrice,string"`
	LastPrice          float64 `json:"lastPrice,string"`
	LastQty            float64 `json:"lastQty,string"`
	OpenPrice          float64 `json:"openPrice,string"`
	HighPrice          float64 `json:"highPrice,string"`
	LowPrice           float64 `json:"lowPrice,string"`
	Volume             float64 `json:"volume,string"`
	QuoteVolume        float64 `json:"quoteVolume,string"`
	OpenTime           int64   `json:"openTime"`
	CloseTime          int64   `json:"closeTime"`
	FirstID            int64   `json:"firstId"`
	LastID             int64   `json:"lastId"`
	Count              int64   `json:"count"`
}

U24HrPriceChangeStats stores price change stats data

type UAccountBalanceV2Data

type UAccountBalanceV2Data struct {
	AccountAlias       string  `json:"accountAlias"`
	Asset              string  `json:"asset"`
	Balance            float64 `json:"balance,string"`
	CrossWalletBalance float64 `json:"crossWalletBalance,string"`
	CrossUnrealizedPNL float64 `json:"crossUnPnl,string"`
	AvailableBalance   float64 `json:"availableBalance,string"`
	MaxWithdrawAmount  float64 `json:"maxWithdrawAmount,string"`
}

UAccountBalanceV2Data stores account balance data for ufutures

type UAccountIncomeHistory

type UAccountIncomeHistory struct {
	Symbol     string  `json:"symbol"`
	IncomeType string  `json:"incomeType"`
	Income     float64 `json:"income,string"`
	Asset      string  `json:"asset"`
	Info       string  `json:"info"`
	Time       int64   `json:"time"`
	TranID     int64   `json:"tranId"`
	TradeID    string  `json:"tradeId"`
}

UAccountIncomeHistory stores income history data

type UAccountInformationV2Data

type UAccountInformationV2Data struct {
	FeeTier                     int64   `json:"feeTier"`
	CanTrade                    bool    `json:"canTrade"`
	CanDeposit                  bool    `json:"canDeposit"`
	CanWithdraw                 bool    `json:"canWithdraw"`
	UpdateTime                  int64   `json:"updateTime"`
	TotalInitialMargin          float64 `json:"totalInitialMargin,string"`
	TotalMaintenance            float64 `json:"totalMaintMargin,string"`
	TotalWalletBalance          float64 `json:"totalWalletBalance,string"`
	TotalUnrealizedProfit       float64 `json:"totalUnrealizedProfit,string"`
	TotalMarginBalance          float64 `json:"totalMarginBalance,string"`
	TotalPositionInitialMargin  float64 `json:"totalPositionInitialMargin,string"`
	TotalOpenOrderInitialMargin float64 `json:"totalOpenOrderInitialMargin,string"`
	TotalCrossWalletBalance     float64 `json:"totalCrossWalletBalance,string"`
	TotalCrossUnrealizedPNL     float64 `json:"totalCrossUnPnl,string"`
	AvailableBalance            float64 `json:"availableBalance,string"`
	MaxWithdrawAmount           float64 `json:"maxWithdrawAmount,string"`
	Assets                      []struct {
		Asset                  string  `json:"asset"`
		WalletBalance          float64 `json:"walletBalance,string"`
		UnrealizedProfit       float64 `json:"unrealizedProfit,string"`
		MarginBalance          float64 `json:"marginBalance,string"`
		MaintMargin            float64 `json:"maintMargin,string"`
		InitialMargin          float64 `json:"initialMargin,string"`
		PositionInitialMargin  float64 `json:"positionInitialMargin,string"`
		OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
		CrossWalletBalance     float64 `json:"crossWalletBalance,string"`
		CrossUnPnl             float64 `json:"crossUnPnl,string"`
		AvailableBalance       float64 `json:"availableBalance,string"`
		MaxWithdrawAmount      float64 `json:"maxWithdrawAmount,string"`
	} `json:"assets"`
	Positions []struct {
		Symbol                 string  `json:"symbol"`
		InitialMargin          float64 `json:"initialMargin,string"`
		MaintenanceMargin      float64 `json:"maintMargin,string"`
		UnrealizedProfit       float64 `json:"unrealizedProfit,string"`
		PositionInitialMargin  float64 `json:"positionInitialMargin,string"`
		OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"`
		Leverage               float64 `json:"leverage,string"`
		Isolated               bool    `json:"isolated"`
		EntryPrice             float64 `json:"entryPrice,string"`
		MaxNotional            float64 `json:"maxNotional,string"`
		PositionSide           string  `json:"positionSide"`
	} `json:"positions"`
}

UAccountInformationV2Data stores account info for ufutures

type UAccountTradeHistory

type UAccountTradeHistory struct {
	Buyer           bool    `json:"buyer"`
	Commission      float64 `json:"commission,string"`
	CommissionAsset string  `json:"commissionAsset"`
	ID              int64   `json:"id"`
	Maker           bool    `json:"maker"`
	OrderID         int64   `json:"orderId"`
	Price           float64 `json:"price,string"`
	Qty             float64 `json:"qty,string"`
	QuoteQty        float64 `json:"quoteQty"`
	RealizedPNL     float64 `json:"realizedPnl,string"`
	Side            string  `json:"side"`
	PositionSide    string  `json:"positionSide"`
	Symbol          string  `json:"symbol"`
	Time            int64   `json:"time"`
}

UAccountTradeHistory stores trade data for the users account

type UChangeInitialLeverage

type UChangeInitialLeverage struct {
	Leverage         int64   `json:"leverage"`
	MaxNotionalValue float64 `json:"maxNotionalValue,string"`
	Symbol           string  `json:"symbol"`
}

UChangeInitialLeverage stores leverage change data

type UCompositeIndexInfoData

type UCompositeIndexInfoData struct {
	Symbol        string `json:"symbol"`
	Time          int64  `json:"time"`
	BaseAssetList []struct {
		BaseAsset          string  `json:"baseAsset"`
		WeightInQuantity   float64 `json:"weightInQuantity,string"`
		WeightInPercentage float64 `json:"weightInPercentage,string"`
	} `json:"baseAssetList"`
}

UCompositeIndexInfoData stores composite index data for usdt margined futures

type UCompressedTradeData

type UCompressedTradeData struct {
	AggregateTradeID int64   `json:"a"`
	Price            float64 `json:"p,string"`
	Quantity         float64 `json:"q,string"`
	FirstTradeID     int64   `json:"f"`
	LastTradeID      int64   `json:"l"`
	Timestamp        int64   `json:"t"`
	IsBuyerMaker     bool    `json:"m"`
}

UCompressedTradeData stores compressed trade data

type UForceOrdersData

type UForceOrdersData struct {
	OrderID       int64   `json:"orderId"`
	Symbol        string  `json:"symbol"`
	Status        string  `json:"status"`
	ClientOrderID string  `json:"clientOrderId"`
	Price         float64 `json:"price,string"`
	AvgPrice      float64 `json:"avgPrice,string"`
	OrigQty       float64 `json:"origQty,string"`
	ExecutedQty   float64 `json:"executedQty,string"`
	CumQuote      float64 `json:"cumQuote,string"`
	TimeInForce   string  `json:"timeInForce"`
	OrderType     string  `json:"type"`
	ReduceOnly    bool    `json:"reduceOnly"`
	ClosePosition bool    `json:"closePosition"`
	Side          string  `json:"side"`
	PositionSide  string  `json:"positionSide"`
	StopPrice     float64 `json:"stopPrice,string"`
	WorkingType   string  `json:"workingType"`
	PriceProtect  bool    `json:"priceProtect,string"`
	OrigType      string  `json:"origType"`
	Time          int64   `json:"time"`
	UpdateTime    int64   `json:"updateTime"`
}

UForceOrdersData stores liquidation orders data for the account

type UFutureKlineStream added in v0.8.7

type UFutureKlineStream struct {
	EventType string                 `json:"e"`
	EventTime int64                  `json:"E"`
	Symbol    string                 `json:"s"`
	Kline     UFutureKlineStreamData `json:"k"`
}

UFutureKlineStream holds the kline stream data

type UFutureKlineStreamData added in v0.8.7

type UFutureKlineStreamData struct {
	StartTime                int64   `json:"t"`
	CloseTime                int64   `json:"T"`
	Symbol                   string  `json:"s"`
	Interval                 string  `json:"i"`
	FirstTradeID             int64   `json:"f"`
	LastTradeID              int64   `json:"L"`
	OpenPrice                float64 `json:"o,string"`
	ClosePrice               float64 `json:"c,string"`
	HighPrice                float64 `json:"h,string"`
	LowPrice                 float64 `json:"l,string"`
	Volume                   float64 `json:"v,string"`
	NumberOfTrades           int64   `json:"n"`
	KlineClosed              bool    `json:"x"`
	Quote                    float64 `json:"q,string"`
	TakerBuyBaseAssetVolume  float64 `json:"V,string"`
	TakerBuyQuoteAssetVolume float64 `json:"Q,string"`
}

UFutureKlineStreamData defines kline streaming data

type UFuturesExchangeInfo

type UFuturesExchangeInfo struct {
	RateLimits []struct {
		Interval      string `json:"interval"`
		IntervalNum   int64  `json:"intervalNum"`
		Limit         int64  `json:"limit"`
		RateLimitType string `json:"rateLimitType"`
	} `json:"rateLimits"`
	ServerTime int64                `json:"serverTime"`
	Symbols    []UFuturesSymbolInfo `json:"symbols"`
	Timezone   string               `json:"timezone"`
}

UFuturesExchangeInfo stores exchange info for ufutures

type UFuturesOrderData

type UFuturesOrderData struct {
	AvgPrice      float64   `json:"avgPrice,string"`
	ClientOrderID string    `json:"clientOrderId"`
	CumQuote      string    `json:"cumQuote"`
	ExecutedQty   float64   `json:"executedQty,string"`
	OrderID       int64     `json:"orderId"`
	OrigQty       float64   `json:"origQty,string"`
	OrigType      string    `json:"origType"`
	Price         float64   `json:"price,string"`
	ReduceOnly    bool      `json:"reduceOnly"`
	Side          string    `json:"side"`
	PositionSide  string    `json:"positionSide"`
	Status        string    `json:"status"`
	StopPrice     float64   `json:"stopPrice,string"`
	ClosePosition bool      `json:"closePosition"`
	Symbol        string    `json:"symbol"`
	Time          time.Time `json:"time"`
	TimeInForce   string    `json:"timeInForce"`
	OrderType     string    `json:"type"`
	ActivatePrice float64   `json:"activatePrice,string"`
	PriceRate     float64   `json:"priceRate,string"`
	UpdateTime    time.Time `json:"updateTime"`
	WorkingType   string    `json:"workingType"`
}

UFuturesOrderData stores order data for ufutures

func (*UFuturesOrderData) UnmarshalJSON

func (a *UFuturesOrderData) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type UFuturesSymbolInfo

type UFuturesSymbolInfo struct {
	Symbol                   string    `json:"symbol"`
	Pair                     string    `json:"pair"`
	ContractType             string    `json:"contractType"`
	DeliveryDate             time.Time `json:"deliveryDate"`
	OnboardDate              time.Time `json:"onboardDate"`
	Status                   string    `json:"status"`
	MaintenanceMarginPercent float64   `json:"maintMarginPercent,string"`
	RequiredMarginPercent    float64   `json:"requiredMarginPercent,string"`
	BaseAsset                string    `json:"baseAsset"`
	QuoteAsset               string    `json:"quoteAsset"`
	MarginAsset              string    `json:"marginAsset"`
	PricePrecision           int64     `json:"pricePrecision"`
	QuantityPrecision        int64     `json:"quantityPrecision"`
	BaseAssetPrecision       int64     `json:"baseAssetPrecision"`
	QuotePrecision           int64     `json:"quotePrecision"`
	UnderlyingType           string    `json:"underlyingType"`
	UnderlyingSubType        []string  `json:"underlyingSubType"`
	SettlePlan               float64   `json:"settlePlan"`
	TriggerProtect           float64   `json:"triggerProtect,string"`
	Filters                  []struct {
		FilterType        string  `json:"filterType"`
		MinPrice          float64 `json:"minPrice,string"`
		MaxPrice          float64 `json:"maxPrice,string"`
		TickSize          float64 `json:"tickSize,string"`
		StepSize          float64 `json:"stepSize,string"`
		MaxQty            float64 `json:"maxQty,string"`
		MinQty            float64 `json:"minQty,string"`
		Limit             int64   `json:"limit"`
		MultiplierDown    float64 `json:"multiplierDown,string"`
		MultiplierUp      float64 `json:"multiplierUp,string"`
		MultiplierDecimal float64 `json:"multiplierDecimal,string"`
		Notional          float64 `json:"notional,string"`
	} `json:"filters"`
	OrderTypes      []string `json:"OrderType"`
	TimeInForce     []string `json:"timeInForce"`
	LiquidationFee  float64  `json:"liquidationFee,string"`
	MarketTakeBound float64  `json:"marketTakeBound,string"`
}

UFuturesSymbolInfo contains details of a currency symbol for a usdt margined future contract

func (*UFuturesSymbolInfo) UnmarshalJSON

func (u *UFuturesSymbolInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type ULiquidationOrdersData

type ULiquidationOrdersData struct {
	Symbol       string  `json:"symbol"`
	Price        float64 `json:"price,string"`
	OrigQty      float64 `json:"origQty,string"`
	ExecutedQty  float64 `json:"executedQty,string"`
	AveragePrice float64 `json:"averagePrice,string"`
	Status       string  `json:"status"`
	TimeInForce  string  `json:"timeInForce"`
	OrderType    string  `json:"type"`
	Side         string  `json:"side"`
	Time         int64   `json:"time"`
}

ULiquidationOrdersData stores liquidation orders data

type ULongShortRatio

type ULongShortRatio struct {
	Symbol         string  `json:"symbol"`
	LongShortRatio float64 `json:"longShortRatio,string"`
	LongAccount    float64 `json:"longAccount,string"`
	ShortAccount   float64 `json:"shortAccount,string"`
	Timestamp      int64   `json:"timestamp"`
}

ULongShortRatio stores top trader accounts' or positions' or global long/short ratio data

type UMarkPrice

type UMarkPrice struct {
	Symbol          string  `json:"symbol"`
	MarkPrice       float64 `json:"markPrice,string"`
	IndexPrice      float64 `json:"indexPrice,string"`
	LastFundingRate float64 `json:"lastFundingRate,string"`
	NextFundingTime int64   `json:"nextFundingTime"`
	Time            int64   `json:"time"`
}

UMarkPrice stores mark price data

type UModifyIsolatedPosMargin

type UModifyIsolatedPosMargin struct {
	Amount     float64 `json:"amount,string"`
	MarginType int64   `json:"type"`
}

UModifyIsolatedPosMargin stores modified isolated margin positions' data

type UNotionalLeverageAndBrakcetsData

type UNotionalLeverageAndBrakcetsData struct {
	Symbol   string `json:"symbol"`
	Brackets []struct {
		Bracket                int64   `json:"bracket"`
		InitialLeverage        float64 `json:"initialLeverage"`
		NotionalCap            float64 `json:"notionalCap"`
		NotionalFloor          float64 `json:"notionalFloor"`
		MaintenanceMarginRatio float64 `json:"maintMarginRatio"`
		Cumulative             float64 `json:"cum"`
	} `json:"brackets"`
}

UNotionalLeverageAndBrakcetsData stores notional and leverage brackets data for the account

type UOpenInterestData

type UOpenInterestData struct {
	OpenInterest float64 `json:"openInterest,string"`
	Symbol       string  `json:"symbol"`
	Time         int64   `json:"time"`
}

UOpenInterestData stores open interest data

type UOpenInterestStats

type UOpenInterestStats struct {
	Symbol               string  `json:"symbol"`
	SumOpenInterest      float64 `json:"sumOpenInterest,string"`
	SumOpenInterestValue float64 `json:"sumOpenInterestValue,string"`
	Timestamp            int64   `json:"timestamp"`
}

UOpenInterestStats stores open interest stats data

type UOrderData

type UOrderData struct {
	ClientOrderID      string    `json:"clientOrderId"`
	Time               time.Time `json:"time"`
	CumulativeQuantity float64   `json:"cumQty,string"`
	CumulativeQuote    float64   `json:"cumQuote,string"`
	ExecutedQuantity   float64   `json:"executedQty,string"`
	OrderID            int64     `json:"orderId"`
	AveragePrice       float64   `json:"avgPrice,string"`
	OriginalQuantity   float64   `json:"origQty,string"`
	Price              float64   `json:"price,string"`
	ReduceOnly         bool      `json:"reduceOnly"`
	Side               string    `json:"side"`
	PositionSide       string    `json:"positionSide"`
	Status             string    `json:"status"`
	StopPrice          float64   `json:"stopPrice,string"`
	ClosePosition      bool      `json:"closePosition"`
	Symbol             string    `json:"symbol"`
	TimeInForce        string    `json:"timeInForce"`
	OrderType          string    `json:"type"`
	OriginalType       string    `json:"origType"`
	ActivatePrice      float64   `json:"activatePrice,string"`
	PriceRate          float64   `json:"priceRate,string"`
	UpdateTime         time.Time `json:"updateTime"`
	WorkingType        string    `json:"workingType"`
	Code               int64     `json:"code"`
	Message            string    `json:"msg"`
}

UOrderData stores order data

func (*UOrderData) UnmarshalJSON

func (a *UOrderData) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type UPositionADLEstimationData

type UPositionADLEstimationData struct {
	Symbol      string `json:"symbol"`
	ADLQuantile struct {
		Long  int64 `json:"LONG"`
		Short int64 `json:"SHORT"`
		Hedge int64 `json:"HEDGE"`
		Both  int64 `json:"BOTH"`
	} `json:"adlQuantile"`
}

UPositionADLEstimationData stores ADL estimation data for a position

type UPositionInformationV2

type UPositionInformationV2 struct {
	EntryPrice           float64 `json:"entryPrice,string"`
	MarginType           string  `json:"marginType"`
	AutoAddMarginEnabled bool    `json:"isAutoAddMargin,string"`
	IsolatedMargin       float64 `json:"isolatedMargin,string"`
	Leverage             float64 `json:"leverage,string"`
	LiquidationPrice     float64 `json:"liquidationPrice,string"`
	MarkPrice            float64 `json:"markPrice,string"`
	MaxNotionalValue     float64 `json:"maxNotionalValue,string"`
	PositionAmount       float64 `json:"positionAmt,string"`
	Symbol               string  `json:"symbol"`
	UnrealizedProfit     float64 `json:"unrealizedProfit,string"`
	PositionSide         string  `json:"positionSide"`
}

UPositionInformationV2 stores positions data

type UPositionMarginChangeHistoryData

type UPositionMarginChangeHistoryData struct {
	Amount       float64 `json:"amount,string"`
	Asset        string  `json:"asset"`
	Symbol       string  `json:"symbol"`
	Time         int64   `json:"time"`
	MarginType   int64   `json:"type"`
	PositionSide string  `json:"positionSide"`
}

UPositionMarginChangeHistoryData gets position margin change history data

type UPublicTradesData

type UPublicTradesData struct {
	ID           int64   `json:"id"`
	Price        float64 `json:"price,string"`
	Qty          float64 `json:"qty,string"`
	QuoteQty     float64 `json:"quoteQty,string"`
	Time         int64   `json:"time"`
	IsBuyerMaker bool    `json:"isBuyerMaker"`
}

UPublicTradesData stores trade data

type USymbolOrderbookTicker

type USymbolOrderbookTicker struct {
	Symbol   string  `json:"symbol"`
	BidPrice float64 `json:"bidPrice,string"`
	BidQty   float64 `json:"bidQty,string"`
	AskPrice float64 `json:"askPrice,string"`
	AskQty   float64 `json:"askQty,string"`
	Time     int64   `json:"time"`
}

USymbolOrderbookTicker stores symbol orderbook ticker data

type USymbolPriceTicker

type USymbolPriceTicker struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
	Time   int64   `json:"time"`
}

USymbolPriceTicker stores symbol price ticker data

type UTakerVolumeData

type UTakerVolumeData struct {
	BuySellRatio float64 `json:"buySellRatio,string"`
	BuyVol       float64 `json:"buyVol,string"`
	SellVol      float64 `json:"sellVol,string"`
	Timestamp    int64   `json:"timestamp"`
}

UTakerVolumeData stores volume data on buy/sell side from takers

type UserAccountStream

type UserAccountStream struct {
	ListenKey string `json:"listenKey"`
}

UserAccountStream contains a key to maintain an authorised websocket connection

type WebsocketDepthStream

type WebsocketDepthStream struct {
	Event         string           `json:"e"`
	Timestamp     time.Time        `json:"E"`
	Pair          string           `json:"s"`
	FirstUpdateID int64            `json:"U"`
	LastUpdateID  int64            `json:"u"`
	UpdateBids    [][2]interface{} `json:"b"`
	UpdateAsks    [][2]interface{} `json:"a"`
}

WebsocketDepthStream is the difference for the update depth stream

func (*WebsocketDepthStream) UnmarshalJSON

func (a *WebsocketDepthStream) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises the JSON info, including the timestamp

type WithdrawResponse

type WithdrawResponse struct {
	ID string `json:"id"`
}

WithdrawResponse contains status of withdrawal request

type WithdrawStatusResponse

type WithdrawStatusResponse struct {
	Address         string  `json:"address"`
	Amount          float64 `json:"amount,string"`
	ApplyTime       string  `json:"applyTime"`
	Coin            string  `json:"coin"`
	ID              string  `json:"id"`
	WithdrawOrderID string  `json:"withdrawOrderId"`
	Network         string  `json:"network"`
	TransferType    uint8   `json:"transferType"`
	Status          int64   `json:"status"`
	TransactionFee  float64 `json:"transactionFee,string"`
	TransactionID   string  `json:"txId"`
	ConfirmNumber   int64   `json:"confirmNo"`
}

WithdrawStatusResponse defines a withdrawal status response

type WorkingType

type WorkingType string

WorkingType 条件价格触发类型 (workingType)

type WsAccountInfoData

type WsAccountInfoData struct {
	CanDeposit       bool      `json:"D"`
	CanTrade         bool      `json:"T"`
	CanWithdraw      bool      `json:"W"`
	EventTime        time.Time `json:"E"`
	LastUpdated      time.Time `json:"u"`
	BuyerCommission  float64   `json:"b"`
	MakerCommission  float64   `json:"m"`
	SellerCommission float64   `json:"s"`
	TakerCommission  float64   `json:"t"`
	EventType        string    `json:"e"`
	Currencies       []struct {
		Asset     string  `json:"a"`
		Available float64 `json:"f,string"`
		Locked    float64 `json:"l,string"`
	} `json:"B"`
}

WsAccountInfoData defines websocket account info data

type WsAccountPositionData

type WsAccountPositionData struct {
	Currencies []struct {
		Asset     string  `json:"a"`
		Available float64 `json:"f,string"`
		Locked    float64 `json:"l,string"`
	} `json:"B"`
	EventTime   time.Time `json:"E"`
	LastUpdated time.Time `json:"u"`
	EventType   string    `json:"e"`
}

WsAccountPositionData defines websocket account position data

type WsBalanceUpdateData

type WsBalanceUpdateData struct {
	EventTime    time.Time `json:"E"`
	ClearTime    time.Time `json:"T"`
	BalanceDelta float64   `json:"d,string"`
	Asset        string    `json:"a"`
	EventType    string    `json:"e"`
}

WsBalanceUpdateData defines websocket account balance data

type WsListStatusData

type WsListStatusData struct {
	ListClientOrderID string    `json:"C"`
	EventTime         time.Time `json:"E"`
	ListOrderStatus   string    `json:"L"`
	Orders            []struct {
		ClientOrderID string `json:"c"`
		OrderID       int64  `json:"i"`
		Symbol        string `json:"s"`
	} `json:"O"`
	TransactionTime time.Time `json:"T"`
	ContingencyType string    `json:"c"`
	EventType       string    `json:"e"`
	OrderListID     int64     `json:"g"`
	ListStatusType  string    `json:"l"`
	RejectionReason string    `json:"r"`
	Symbol          string    `json:"s"`
}

WsListStatusData defines websocket account listing status data

type WsOrderUpdateData

type WsOrderUpdateData struct {
	EventType                         string    `json:"e"`
	EventTime                         time.Time `json:"E"`
	Symbol                            string    `json:"s"`
	ClientOrderID                     string    `json:"c"`
	Side                              string    `json:"S"`
	OrderType                         string    `json:"o"`
	TimeInForce                       string    `json:"f"`
	Quantity                          float64   `json:"q,string"`
	Price                             float64   `json:"p,string"`
	StopPrice                         float64   `json:"P,string"`
	IcebergQuantity                   float64   `json:"F,string"`
	OrderListID                       int64     `json:"g"`
	CancelledClientOrderID            string    `json:"C"`
	CurrentExecutionType              string    `json:"x"`
	OrderStatus                       string    `json:"X"`
	RejectionReason                   string    `json:"r"`
	OrderID                           int64     `json:"i"`
	LastExecutedQuantity              float64   `json:"l,string"`
	CumulativeFilledQuantity          float64   `json:"z,string"`
	LastExecutedPrice                 float64   `json:"L,string"`
	Commission                        float64   `json:"n,string"`
	CommissionAsset                   string    `json:"N"`
	TransactionTime                   time.Time `json:"T"`
	TradeID                           int64     `json:"t"`
	Ignored                           int64     `json:"I"` // Must be ignored explicitly, otherwise it overwrites 'i'.
	IsOnOrderBook                     bool      `json:"w"`
	IsMaker                           bool      `json:"m"`
	Ignored2                          bool      `json:"M"` // See the comment for "I".
	OrderCreationTime                 time.Time `json:"O"`
	CumulativeQuoteTransactedQuantity float64   `json:"Z,string"`
	LastQuoteAssetTransactedQuantity  float64   `json:"Y,string"`
	QuoteOrderQuantity                float64   `json:"Q,string"`
}

WsOrderUpdateData defines websocket account order update data

type WsPayload

type WsPayload struct {
	Method string   `json:"method"`
	Params []string `json:"params"`
	ID     int64    `json:"id"`
}

WsPayload defines the payload through the websocket connection

Jump to

Keyboard shortcuts

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