binance

package
v0.0.0-...-ae86ed1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 33 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 (
	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 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
	// contains filtered or unexported fields
}

Binance is the overarching type across the Binance package

func (*Binance) AllOrders

func (b *Binance) AllOrders(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(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(req *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair

func (*Binance) CancelBatchOrders

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

CancelBatchOrders cancels an orders by their corresponding ID numbers

func (*Binance) CancelExistingOrder

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

CancelExistingOrder sends a cancel order to Binance

func (*Binance) CancelOrder

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

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

FetchAccountInfo retrieves balances for all enabled currencies

func (*Binance) FetchCoinMarginExchangeLimits

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

FetchCoinMarginExchangeLimits fetches coin margined order execution limits

func (*Binance) FetchOrderbook

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

FetchOrderbook returns orderbook base on the currency pair

func (*Binance) FetchSpotExchangeLimits

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

FetchSpotExchangeLimits fetches spot order execution limits

func (*Binance) FetchTicker

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

FetchTicker returns the ticker for a currency pair

func (*Binance) FetchTradablePairs

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

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*Binance) FetchUSDTMarginExchangeLimits

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

FetchUSDTMarginExchangeLimits fetches USDT margined order execution limits

func (*Binance) FormatExchangeKlineInterval

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

FormatExchangeKlineInterval returns Interval to exchange formatted string

func (*Binance) FuturesBatchCancelOrders

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

FuturesBatchCancelOrders sends a batch request to cancel orders

func (*Binance) FuturesBatchOrder

func (b *Binance) FuturesBatchOrder(data []PlaceBatchOrderData) ([]FuturesOrderPlaceData, error)

FuturesBatchOrder sends a batch order request

func (*Binance) FuturesCancelAllOpenOrders

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

FuturesCancelAllOpenOrders cancels a futures order

func (*Binance) FuturesCancelOrder

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

FuturesCancelOrder cancels a futures order

func (*Binance) FuturesChangeInitialLeverage

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

FuturesChangeInitialLeverage changes initial leverage for the account

func (*Binance) FuturesChangeMarginType

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

FuturesChangeMarginType changes margin type

func (*Binance) FuturesExchangeInfo

func (b *Binance) FuturesExchangeInfo() (CExchangeInfo, error)

FuturesExchangeInfo stores CoinMarginedFutures, data

func (*Binance) FuturesForceOrders

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

FuturesForceOrders gets futures forced orders

func (*Binance) FuturesGetFundingHistory

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

FuturesGetFundingHistory gets funding history for CoinMarginedFutures,

func (*Binance) FuturesGetOrderData

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

FuturesGetOrderData gets futures order data

func (*Binance) FuturesIncomeHistory

func (b *Binance) FuturesIncomeHistory(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(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(symbol currency.Pair, side, positionSide, orderType, timeInForce,
	newClientOrderID, closePosition, workingType, newOrderRespType string,
	quantity, price, stopPrice, activationPrice, callbackRate float64, reduceOnly bool) (FuturesOrderPlaceData, error)

FuturesNewOrder sends a new futures order to the exchange

func (*Binance) FuturesNotionalBracket

func (b *Binance) FuturesNotionalBracket(pair string) ([]NotionalBracketData, error)

FuturesNotionalBracket gets futures notional bracket

func (*Binance) FuturesOpenOrderData

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

FuturesOpenOrderData gets open order data for CoinMarginedFutures,

func (*Binance) FuturesPositionsADLEstimate

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

FuturesPositionsADLEstimate estimates ADL on positions

func (*Binance) FuturesPositionsInfo

func (b *Binance) FuturesPositionsInfo(marginAsset, pair string) ([]FuturesPositionInformation, error)

FuturesPositionsInfo gets futures positions info

func (*Binance) FuturesTradeHistory

func (b *Binance) FuturesTradeHistory(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() (*Account, error)

GetAccount returns binance user accounts

func (*Binance) GetActiveOrders

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

GetActiveOrders retrieves any orders that are active/open

func (*Binance) GetAggregatedTrades

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

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

GetAllFuturesOrders gets all orders active cancelled or filled

func (*Binance) GetAveragePrice

func (b *Binance) GetAveragePrice(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(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(pair, contractType, interval string, limit int64, startTime, endTime time.Time) ([]FuturesCandleStick, error)

GetContinuousKlineData gets continuous kline data

func (*Binance) GetCrossMarginInterestHistory

func (b *Binance) GetCrossMarginInterestHistory() (CrossMarginInterestData, error)

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

func (*Binance) GetDefaultConfig

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

GetDefaultConfig returns a default exchange config

func (*Binance) GetDepositAddress

func (b *Binance) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*Binance) GetDepositAddressForCurrency

func (b *Binance) GetDepositAddressForCurrency(currency string) (string, error)

GetDepositAddressForCurrency retrieves the wallet address for a given currency

func (*Binance) GetExchangeInfo

func (b *Binance) GetExchangeInfo() (ExchangeInfo, error)

GetExchangeInfo returns exchange information. Check binance_types for more information

func (*Binance) GetFee

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

GetFee returns an estimate of fee based on type of transaction

func (*Binance) GetFeeByType

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

GetFeeByType returns an estimate of fee based on type of transaction

func (*Binance) GetFundingHistory

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

GetFundingHistory returns funding history, deposits and withdrawals

func (*Binance) GetFundingRates

func (b *Binance) GetFundingRates(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() ([]FuturesAccountBalanceData, error)

GetFuturesAccountBalance gets account balance data for CoinMarginedFutures, account

func (*Binance) GetFuturesAccountInfo

func (b *Binance) GetFuturesAccountInfo() (FuturesAccountInformation, error)

GetFuturesAccountInfo gets account info data for CoinMarginedFutures, account

func (*Binance) GetFuturesAggregatedTradesList

func (b *Binance) GetFuturesAggregatedTradesList(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(symbol currency.Pair, pair string) ([]FuturesOrderData, error)

GetFuturesAllOpenOrders gets all open orders data for CoinMarginedFutures,

func (*Binance) GetFuturesBasisData

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

GetFuturesBasisData gets futures basis data

func (*Binance) GetFuturesHistoricalTrades

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

GetFuturesHistoricalTrades gets historical public trades for CoinMarginedFutures,

func (*Binance) GetFuturesKlineData

func (b *Binance) GetFuturesKlineData(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(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(symbol currency.Pair, limit int64) (OrderBook, error)

GetFuturesOrderbook gets orderbook data for CoinMarginedFutures,

func (*Binance) GetFuturesOrderbookTicker

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

GetFuturesOrderbookTicker gets orderbook ticker for symbol

func (*Binance) GetFuturesPublicTrades

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

GetFuturesPublicTrades gets recent public trades for CoinMarginedFutures,

func (*Binance) GetFuturesSwapTickerChangeStats

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

GetFuturesSwapTickerChangeStats gets 24hr ticker change stats for CoinMarginedFutures,

func (*Binance) GetFuturesSymbolPriceTicker

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

GetFuturesSymbolPriceTicker gets price ticker for symbol

func (*Binance) GetFuturesTakerVolume

func (b *Binance) GetFuturesTakerVolume(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(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(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(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(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(symbol, pair string) ([]IndexMarkPrice, error)

GetIndexAndMarkPrice gets index and mark prices for CoinMarginedFutures,

func (*Binance) GetIndexPriceKlines

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

GetIndexPriceKlines gets continuous kline data

func (*Binance) GetInterestHistory

func (b *Binance) GetInterestHistory() (MarginInfoData, error)

GetInterestHistory gets interest history for currency/currencies provided

func (*Binance) GetLatestSpotPrice

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

GetLatestSpotPrice returns latest spot price of symbol

symbol: string of currency pair

func (*Binance) GetMarginAccount

func (b *Binance) GetMarginAccount() (*MarginAccount, error)

GetMarginAccount returns account information for margin accounts

func (*Binance) GetMarginMarkets

func (b *Binance) GetMarginMarkets() (PerpsExchangeInfo, error)

GetMarginMarkets returns exchange information. Check binance_types for more information

func (*Binance) GetMarkPriceKline

func (b *Binance) GetMarkPriceKline(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(pair, period string, limit int64, startTime, endTime time.Time) ([]TopTraderPositionRatio, error)

GetMarketRatio gets global long/short ratio

func (*Binance) GetMostRecentTrades

func (b *Binance) GetMostRecentTrades(rtr RecentTradeRequestParams) ([]RecentTrade, error)

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

func (*Binance) GetOpenInterest

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

GetOpenInterest gets open interest data for a symbol

func (*Binance) GetOpenInterestStats

func (b *Binance) GetOpenInterestStats(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(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(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(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(symbol currency.Pair, limit, fromID int64) ([]FuturesPublicTradesData, error)

GetPastPublicTrades gets past public trades for CoinMarginedFutures,

func (*Binance) GetPerpMarkets

func (b *Binance) GetPerpMarkets() (PerpsExchangeInfo, error)

GetPerpMarkets returns exchange information. Check binance_types for more information

func (*Binance) GetPriceChangeStats

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

func (b *Binance) GetTickers() ([]PriceChangeStats, error)

GetTickers returns the ticker data for the last 24 hrs

func (*Binance) GetTraderFuturesAccountRatio

func (b *Binance) GetTraderFuturesAccountRatio(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(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(c currency.Code) (resp []exchange.WithdrawalHistory, err error)

GetWithdrawalsHistory returns previous withdrawals data

func (*Binance) GetWsAuthStreamKey

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

MaintainWsAuthStreamKey will keep the key alive

func (*Binance) ModifyIsolatedPositionMargin

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

ModifyIsolatedPositionMargin changes margin for an isolated position

func (*Binance) ModifyOrder

func (b *Binance) ModifyOrder(action *order.Modify) (string, error)

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

func (*Binance) NewOrder

func (b *Binance) NewOrder(o *NewOrderRequest) (NewOrderResponse, error)

NewOrder sends a new order to Binance

func (*Binance) NewOrderTest

func (b *Binance) NewOrderTest(o *NewOrderRequest) error

NewOrderTest sends a new test order to Binance

func (*Binance) OpenOrders

func (b *Binance) OpenOrders(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) 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(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(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(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(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(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.ExchangeConfig) error

Setup takes in the supplied exchange configuration details and sets params

func (*Binance) Start

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

Start starts the Binance go routine

func (*Binance) SubmitOrder

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

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

U24HTickerPriceChangeStats gets 24hr ticker price change stats for USDTMarginedFutures

func (*Binance) UAccountBalanceV2

func (b *Binance) UAccountBalanceV2() ([]UAccountBalanceV2Data, error)

UAccountBalanceV2 gets V2 account balance data

func (*Binance) UAccountForcedOrders

func (b *Binance) UAccountForcedOrders(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(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() (UAccountInformationV2Data, error)

UAccountInformationV2 gets V2 account balance data

func (*Binance) UAccountTradesHistory

func (b *Binance) UAccountTradesHistory(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(symbol currency.Pair) ([]UOrderData, error)

UAllAccountOpenOrders gets all account's orders for USDTMarginedFutures

func (*Binance) UAllAccountOrders

func (b *Binance) UAllAccountOrders(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(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(symbol currency.Pair) (GenericAuthResponse, error)

UCancelAllOpenOrders cancels all open orders for a symbol ufutures

func (*Binance) UCancelBatchOrders

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

UCancelBatchOrders cancel batch order for USDTMarginedFutures

func (*Binance) UCancelOrder

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

UCancelOrder cancel an order for USDTMarginedFutures

func (*Binance) UChangeInitialLeverageRequest

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

UChangeInitialLeverageRequest sends a request to change account's initial leverage

func (*Binance) UChangeInitialMarginType

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

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

func (*Binance) UCompositeIndexInfo

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

UCompositeIndexInfo stores composite indexs' info for usdt margined futures

func (*Binance) UCompressedTrades

func (b *Binance) UCompressedTrades(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() (UFuturesExchangeInfo, error)

UExchangeInfo stores usdt margined futures data

func (*Binance) UFetchOpenOrder

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

UFetchOpenOrder sends a request to fetch open order data for USDTMarginedFutures

func (*Binance) UFuturesHistoricalTrades

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

UFuturesHistoricalTrades gets historical public trades for USDTMarginedFutures

func (*Binance) UFuturesNewOrder

func (b *Binance) UFuturesNewOrder(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(symbol currency.Pair, limit int64) (OrderBook, error)

UFuturesOrderbook gets orderbook data for usdt margined futures

func (*Binance) UGetFundingHistory

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

UGetFundingHistory gets funding history for USDTMarginedFutures

func (*Binance) UGetMarkPrice

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

UGetMarkPrice gets mark price data for USDTMarginedFutures

func (*Binance) UGetNotionalAndLeverageBrackets

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

UGetNotionalAndLeverageBrackets gets account's notional and leverage brackets for USDTMarginedFutures

func (*Binance) UGetOrderData

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

UGetOrderData gets order data for USDTMarginedFutures

func (*Binance) UGlobalLongShortRatio

func (b *Binance) UGlobalLongShortRatio(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(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(symbol currency.Pair, limit int64, startTime, endTime time.Time) ([]ULiquidationOrdersData, error)

ULiquidationOrders gets public liquidation orders

func (*Binance) UModifyIsolatedPositionMarginReq

func (b *Binance) UModifyIsolatedPositionMarginReq(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(symbol currency.Pair) (UOpenInterestData, error)

UOpenInterest gets open interest data for USDTMarginedFutures

func (*Binance) UOpenInterestStats

func (b *Binance) UOpenInterestStats(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(data []PlaceBatchOrderData) ([]UOrderData, error)

UPlaceBatchOrders places batch orders

func (*Binance) UPositionMarginChangeHistory

func (b *Binance) UPositionMarginChangeHistory(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(symbol currency.Pair) (UPositionADLEstimationData, error)

UPositionsADLEstimate gets estimated ADL data for USDTMarginedFutures positions

func (*Binance) UPositionsInfoV2

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

UPositionsInfoV2 gets positions' info for USDTMarginedFutures

func (*Binance) URecentTrades

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

URecentTrades gets recent trades for usdt margined futures

func (*Binance) UServerTime

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

UServerTime gets the server time

func (*Binance) USymbolOrderbookTicker

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

USymbolOrderbookTicker gets symbol orderbook ticker

func (*Binance) USymbolPriceTicker

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

USymbolPriceTicker gets symbol price ticker for USDTMarginedFutures

func (*Binance) UTakerBuySellVol

func (b *Binance) UTakerBuySellVol(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(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(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(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(a asset.Item) error

UpdateOrderExecutionLimits sets exchange executions for a required asset type

func (*Binance) UpdateOrderbook

func (b *Binance) UpdateOrderbook(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(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*Binance) UpdateTradablePairs

func (b *Binance) UpdateTradablePairs(forceUpdate bool) error

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

func (*Binance) ValidateCredentials

func (b *Binance) ValidateCredentials(assetType asset.Item) error

ValidateCredentials validates current credentials used for wrapper functionality

func (*Binance) WithdrawCrypto

func (b *Binance) WithdrawCrypto(asset, address, addressTag, name, amount string) (string, error)

WithdrawCrypto sends cryptocurrency to the address of your choosing

func (*Binance) WithdrawCryptocurrencyFunds

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

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*Binance) WithdrawFiatFunds

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

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*Binance) WithdrawFiatFundsToInternationalBank

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

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*Binance) WithdrawStatus

func (b *Binance) WithdrawStatus(c currency.Code, status string, startTime, endTime int64) ([]WithdrawStatusResponse, error)

WithdrawStatus 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 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 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 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 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"`
		Leverage               float64 `json:"leverage,string"`
		Isolated               bool    `json:"isolated"`
		PositionSide           string  `json:"positionSide"`
		EntryPrice             float64 `json:"entryPrice,string"`
		MaxQty                 float64 `json:"maxQty,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"`
		PositionSide           string  `json:"positionSide"`
		EntryPrice             float64 `json:"entryPrice,string"`
		MaxQty                 float64 `json:"maxQty,string"`
	} `json:"positions"`
	CanDeposit  bool  `json:"canDeposit"`
	CanTrade    bool  `json:"canTrade"`
	CanWithdraw bool  `json:"canWithdraw"`
	FeeTier     int64 `json:"feeTier"`
	UpdateTime  int64 `json:"updateTime"`
}

FuturesAccountInformation stores account information for futures account

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 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:"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"`
}

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

func (r *RateLimit) Limit(f request.EndpointLimit) error

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 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 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 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    []struct {
		Symbol                   string  `json:"symbol"`
		Status                   string  `json:"status"`
		MaintenanceMarginPercent float64 `json:"maintMarginPercent,string"`
		RequiredMarginPercent    float64 `json:"requiredMarginPercent,string"`
		BaseAsset                string  `json:"baseAsset"`
		QuoteAsset               string  `json:"quoteAsset"`
		PricePrecision           int64   `json:"pricePrecision"`
		QuantityPrecision        int64   `json:"quantityPrecision"`
		BaseAssetPrecision       int64   `json:"baseAssetPrecision"`
		QuotePrecision           int64   `json:"quotePrecision"`
		Filters                  []struct {
			MinPrice          float64 `json:"minPrice,string"`
			MaxPrice          float64 `json:"maxPrice,string"`
			FilterType        string  `json:"filterType"`
			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:"orderTypes"`
		TimeInForce []string `json:"timeInForce"`
	} `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 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"`
	} `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 {
	Success bool   `json:"success"`
	Msg     string `json:"msg"`
	ID      string `json:"id"`
}

WithdrawResponse contains status of withdrawal request

type WithdrawStatusResponse

type WithdrawStatusResponse struct {
	Amount         float64 `json:"amount"`
	TransactionFee float64 `json:"transactionFee"`
	Address        string  `json:"address"`
	TxID           string  `json:"txId"`
	ID             string  `json:"id"`
	Asset          string  `json:"asset"`
	ApplyTime      int64   `json:"applyTime"`
	Status         int64   `json:"status"`
	Network        string  `json:"network"`
}

WithdrawStatusResponse defines a withdrawal status response

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