binance

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: MIT Imports: 16 Imported by: 0

README

PkgGoDev Go Report Card

Golang Binance API

binance-api is a fast and lightweight Golang implementation for Binance API, providing complete API coverage, and supports both REST API and websockets API

This library created to help you interact with the Binance API, streaming candlestick charts data, market depth, or use other advanced features binance exposes via API.

Quickstart

package main

import (
    "log"

    "github.com/xenking/binance-api"
)

func main() {
    client := binance.NewClient("API-KEY", "SECRET")

    err := client.Ping()
    if err != nil {
        panic(err)
    }

    prices, err := client.Prices()
    if err != nil {
        panic(err)
    }

    for _, p := range prices {
        log.Printf("symbol: %s, price: %s", p.Symbol, p.Price)
    }
}

Installation

go get -u github.com/xenking/binance-api

Getting started

// Create default client
client := binance.NewClient("API-KEY", "SECRET")

// Send ping request
err := client.Ping()

// Create client with custom request window size
client := binance.NewClient("API-KEY", "SECRET").ReqWindow(5000)

// Create websocket client
wsClient := ws.NewClient()

// Connect to Klines websocket
ws, err := wsClient.Klines("ETHBTC", binance.KlineInterval1m)

// Read ws
msg, err := ws.Read()

Full documentation on pkg.go.dev

License

This library is under the MIT License. See the LICENSE file for more info.

Documentation

Index

Constants

View Source
const (
	BaseHost         = "api.binance.com"
	DefaultUserAgent = "Binance/client"
)
View Source
const (
	EndpointPing          = "/api/v3/ping"
	EndpointTime          = "/api/v3/time"
	EndpointExchangeInfo  = "/api/v3/exchangeInfo"
	EndpointDepth         = "/api/v3/depth"
	EndpointTrades        = "/api/v3/trades"
	EndpointAggTrades     = "/api/v3/aggTrades"
	EndpointKlines        = "/api/v3/klines"
	EndpointAvgPrice      = "/api/v3/avgPrice"
	EndpointTicker24h     = "/api/v3/ticker/24hr"
	EndpointTickerPrice   = "/api/v3/ticker/price"
	EndpointTickerBook    = "/api/v3/ticker/bookTicker"
	EndpointOrder         = "/api/v3/order"
	EndpointOrderTest     = "/api/v3/order/test"
	EndpointOpenOrders    = "/api/v3/openOrders"
	EndpointOrdersAll     = "/api/v3/allOrders"
	EndpointAccount       = "/api/v3/account"
	EndpointAccountTrades = "/api/v3/myTrades"
	EndpointDataStream    = "/api/v3/userDataStream"
)
View Source
const (
	OrderRespTypeAsk    = "ASK"
	OrderRespTypeResult = "RESULT"
	OrderRespTypeFull   = "FULL"
)

Variables

View Source
var (
	ErrNilRequest   = errors.New("request is nil")
	ErrEmptySymbol  = errors.New("symbol are missing")
	ErrEmptyOrderID = errors.New("order id must be set")
	ErrEmptyLimit   = errors.New("empty price or quantity")
	ErrEmptyMarket  = errors.New("quantity or quote quantity expected")
	ErrNilUnmarshal = errors.New("UnmarshalJSON on nil pointer")
	ErrInvalidJson  = errors.New("invalid json")
)

Functions

This section is empty.

Types

type APIError

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

func (*APIError) Error

func (e *APIError) Error() string

Error return error code and message

type AccountInfo

type AccountInfo 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"`
	Balances         []*Balance `json:"balances"`
}

type AccountTrades

type AccountTrades struct {
	ID              int    `json:"id"`
	Price           string `json:"price"`
	Qty             string `json:"qty"`
	Commission      string `json:"commission"`
	CommissionAsset string `json:"commissionAsset"`
	Time            uint64 `json:"time"`
	Buyer           bool   `json:"isBuyer"`
	Maker           bool   `json:"isMaker"`
	BestMatch       bool   `json:"isBestMatch"`
}

type AccountTradesReq

type AccountTradesReq struct {
	Symbol string `url:"symbol"`
	Limit  int    `url:"limit"`  // Limit is the maximal number of elements to receive. Max 500
	FromID int    `url:"fromId"` // FromID is trade ID to fetch from. Default gets most recent trades
}

type AggregatedTrade

type AggregatedTrade struct {
	TradeID      int    `json:"a"` // TradeID is the aggregate trade ID
	Price        string `json:"p"` // Price is the trade price
	Quantity     string `json:"q"` // Quantity is the trade quantity
	FirstTradeID int    `json:"f"`
	LastTradeID  int    `json:"l"`
	Time         uint64 `json:"T"`
	Maker        bool   `json:"m"` // Maker indicates if the buyer is the maker
	BestMatch    bool   `json:"M"` // BestMatch indicates if the trade was at the best price match
}

type AggregatedTradeReq

type AggregatedTradeReq struct {
	Symbol    string `url:"symbol"` // Symbol is the symbol to fetch data for
	FromID    int    `url:"fromId"` // FromID to get aggregate trades from INCLUSIVE.
	Limit     int    `url:"limit"`  // Limit is the maximal number of elements to receive. Max 500
	StartTime uint64 `url:"startTime,omitempty"`
	EndTime   uint64 `url:"endTime,omitempty"`
}

type AllOrdersReq

type AllOrdersReq struct {
	Symbol  string `url:"symbol"`  // Symbol is the symbol to fetch orders for
	OrderID int    `url:"orderId"` // OrderID, if set, will filter all recent orders newer from the given ID
	Limit   int    `url:"limit"`   // Limit is the maximal number of elements to receive. Max 500
}

AllOrdersReq represents the request used for querying orders of the given symbol Remark: If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned

type AvgPrice

type AvgPrice struct {
	Mins  int    `json:"mins"`
	Price string `json:"price"`
}

type AvgPriceReq

type AvgPriceReq struct {
	Symbol string `url:"symbol"`
}

type Balance

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

type BookTicker

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

type BookTickerReq

type BookTickerReq struct {
	Symbol string `url:"symbol"`
}

type CancelOpenOrdersReq

type CancelOpenOrdersReq struct {
	Symbol string `url:"symbol"`
}

type CancelOrder

type CancelOrder struct {
	Symbol              string      `json:"symbol"`
	OrigClientOrderID   string      `json:"origClientOrderId"`
	OrderID             int         `json:"orderId"`
	OrderListID         int         `json:"orderListId"`
	ClientOrderID       string      `json:"clientOrderId"`
	Price               string      `json:"price"`
	OrigQty             string      `json:"origQty"`
	ExecutedQty         string      `json:"executedQty"`
	CummulativeQuoteQty string      `json:"cummulativeQuoteQty"`
	Status              OrderStatus `json:"status"`
	TimeInForce         string      `json:"timeInForce"`
	Type                OrderType   `json:"type"`
	Side                OrderSide   `json:"side"`
}

type CancelOrderReq

type CancelOrderReq struct {
	Symbol            string `url:"symbol"`
	OrderID           int    `url:"orderId,omitempty"`
	OrigClientOrderId string `url:"origClientOrderId,omitempty"`
	NewClientOrderId  string `url:"newClientOrderId,omitempty"`
}

Remark: Either OrderID or OrigOrderID must be set

type Client

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

func NewClient

func NewClient(apikey, secret string) *Client

func (*Client) Account

func (c *Client) Account() (*AccountInfo, error)

Account get current account information

func (*Client) AccountTrades

func (c *Client) AccountTrades(req *AccountTradesReq) (*AccountTrades, error)

AccountTrades get trades for a specific account and symbol

func (*Client) AggregatedTrades

func (c *Client) AggregatedTrades(req *AggregatedTradeReq) ([]*AggregatedTrade, error)

AggregatedTrades gets compressed, aggregate trades. AccountTrades that fill at the time, from the same order, with the same price will have the quantity aggregated Remark: If both startTime and endTime are sent, limit should not be sent AND the distance between startTime and endTime must be less than 24 hours. Remark: If frondId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.

func (*Client) AllOrders

func (c *Client) AllOrders(req *AllOrdersReq) ([]*QueryOrder, error)

AllOrders get all account orders; active, canceled, or filled

func (*Client) AvgPrice

func (c *Client) AvgPrice(req *AvgPriceReq) (*AvgPrice, error)

Ticker returns 24 hour price change statistics

func (*Client) BookTicker

func (c *Client) BookTicker(req *BookTickerReq) (*BookTicker, error)

BookTicker returns best price/qty on the order book for all symbols

func (*Client) BookTickers

func (c *Client) BookTickers() ([]*BookTicker, error)

BookTickers returns best price/qty on the order book for all symbols

func (*Client) CancelOpenOrders

func (c *Client) CancelOpenOrders(req *CancelOpenOrdersReq) ([]*CancelOrder, error)

CancelOpenOrders cancel all open orders on a symbol

func (*Client) CancelOrder

func (c *Client) CancelOrder(req *CancelOrderReq) (*CancelOrder, error)

CancelOrder cancel an active order

func (*Client) DataStream

func (c *Client) DataStream() (string, error)

DatastreamReq starts a new user datastream

func (*Client) DataStreamClose

func (c *Client) DataStreamClose(listenKey string) error

DataStreamClose closes the datastream key

func (*Client) DataStreamKeepAlive

func (c *Client) DataStreamKeepAlive(listenKey string) error

DataStreamKeepAlive pings the datastream key to prevent timeout

func (*Client) Depth

func (c *Client) Depth(req *DepthReq) (*Depth, error)

Market Data endpoints Depth retrieves the order book for the given symbol

func (*Client) ExchangeInfo

func (c *Client) ExchangeInfo() (*ExchangeInfo, error)

func (*Client) Klines

func (c *Client) Klines(req *KlinesReq) ([]*Klines, error)

Klines returns kline/candlestick bars for a symbol. Klines are uniquely identified by their open time

func (*Client) NewOrder

func (c *Client) NewOrder(req *OrderReq) (*OrderRespAck, error)

NewOrder sends in a new order

func (*Client) NewOrderFull

func (c *Client) NewOrderFull(req *OrderReq) (*OrderRespFull, error)

NewOrderFull sends in a new order and return created full order info

func (*Client) NewOrderResult

func (c *Client) NewOrderResult(req *OrderReq) (*OrderRespResult, error)

NewOrderResult sends in a new order and return created order

func (*Client) NewOrderTest

func (c *Client) NewOrderTest(req *OrderReq) error

NewOrderTest tests new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine

func (*Client) OpenOrders

func (c *Client) OpenOrders(req *OpenOrdersReq) ([]*QueryOrder, error)

OpenOrders get all open orders on a symbol

func (*Client) Ping

func (c *Client) Ping() error

Ping tests connectivity to the Rest API

func (*Client) Price

func (c *Client) Price(req *TickerPriceReq) (*SymbolPrice, error)

Prices calculates the latest price for all symbols

func (*Client) Prices

func (c *Client) Prices() ([]*SymbolPrice, error)

Prices calculates the latest price for all symbols

func (*Client) QueryOrder

func (c *Client) QueryOrder(req *QueryOrderReq) (*QueryOrder, error)

QueryOrder checks an order's status

func (*Client) ReqWindow

func (c *Client) ReqWindow(window int) *Client

func (*Client) Ticker

func (c *Client) Ticker(req *TickerReq) (*TickerStats, error)

Ticker returns 24 hour price change statistics

func (*Client) Tickers

func (c *Client) Tickers() ([]*TickerStats, error)

Tickers returns 24 hour price change statistics

func (*Client) Time

func (c *Client) Time() (*ServerTime, error)

Time tests connectivity to the Rest API and get the current server time

func (*Client) Trades

func (c *Client) Trades(req *TradeReq) ([]*Trade, error)

Get trades for a specific account and symbol

type DatastreamReq

type DatastreamReq struct {
	ListenKey string `json:"listenKey" url:"listenKey"`
}

type Depth

type Depth struct {
	LastUpdateID int         `json:"lastUpdateId"`
	Bids         []DepthElem `json:"bids"`
	Asks         []DepthElem `json:"asks"`
}

type DepthElem

type DepthElem struct {
	Quantity decimal.Decimal `json:"quantity"`
	Price    decimal.Decimal `json:"price"`
}

DepthElem represents a specific order in the order book

func (*DepthElem) UnmarshalJSON

func (b *DepthElem) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the given depth raw data and converts to depth struct

type DepthReq

type DepthReq struct {
	Symbol string `url:"symbol"` // Symbol is the symbol to fetch data for
	Limit  int    `url:"limit"`  // Limit is the number of order book items to retrieve. Max 100
}

DepthReq are used to specify symbol to retrieve order book for

type ExchangeInfo

type ExchangeInfo struct {
	Symbols []SymbolInfo
}

type FilterType

type FilterType string
const (
	FilterTypePrice       FilterType = "PRICE_FILTER"
	FilterTypeLotSize     FilterType = "LOT_SIZE"
	FilterTypeMinNotional FilterType = "MIN_NOTIONAL"
)

type KlineInterval

type KlineInterval string
const (
	KlineInterval1min   KlineInterval = "1m"
	KlineInterval3min   KlineInterval = "3m"
	KlineInterval5min   KlineInterval = "5m"
	KlineInterval15min  KlineInterval = "15m"
	KlineInterval30min  KlineInterval = "30m"
	KlineInterval1hour  KlineInterval = "1h"
	KlineInterval2hour  KlineInterval = "2h"
	KlineInterval4hour  KlineInterval = "4h"
	KlineInterval6hour  KlineInterval = "6h"
	KlineInterval8hour  KlineInterval = "8h"
	KlineInterval12hour KlineInterval = "12h"
	KlineInterval1day   KlineInterval = "1d"
	KlineInterval3day   KlineInterval = "3d"
	KlineInterval1week  KlineInterval = "1w"
	KlineInterval1month KlineInterval = "1M"
)

type Klines

type Klines struct {
	OpenTime                 uint64
	OpenPrice                decimal.Decimal
	High                     decimal.Decimal
	Low                      decimal.Decimal
	ClosePrice               decimal.Decimal
	Volume                   decimal.Decimal
	CloseTime                uint64
	QuoteAssetVolume         decimal.Decimal
	Trades                   int
	TakerBuyBaseAssetVolume  decimal.Decimal
	TakerBuyQuoteAssetVolume decimal.Decimal
}

func (*Klines) UnmarshalJSON

func (b *Klines) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal the given depth raw data and converts to depth struct

type KlinesReq

type KlinesReq struct {
	Symbol    string        `url:"symbol"`   // Symbol is the symbol to fetch data for
	Interval  KlineInterval `url:"interval"` // Interval is the interval for each kline/candlestick
	Limit     int           `url:"limit"`    // Limit is the maximal number of elements to receive. Max 500
	StartTime uint64        `url:"startTime,omitempty"`
	EndTime   uint64        `url:"endTime,omitempty"`
}

type OpenOrdersReq

type OpenOrdersReq struct {
	Symbol string `url:"symbol"`
}

type OrderFailure

type OrderFailure string
const (
	OrderFailureNone              OrderFailure = "NONE"
	OrderFailureUnknownInstrument OrderFailure = "UNKNOWN_INSTRUMENT"
	OrderFailureMarketClosed      OrderFailure = "MARKET_CLOSED"
	OrderFailurePriceExceed       OrderFailure = "PRICE_QTY_EXCEED_HARD_LIMITS"
	OrderFailureUnknownOrder      OrderFailure = "UNKNOWN_ORDER"
	OrderFailureDuplicate         OrderFailure = "DUPLICATE_ORDER"
	OrderFailureUnknownAccount    OrderFailure = "UNKNOWN_ACCOUNT"
	OrderFailureInsufficientFunds OrderFailure = "INSUFFICIENT_BALANCE"
	OrderFailureAccountInaactive  OrderFailure = "ACCOUNT_INACTIVE"
	OrderFailureAccountSettle     OrderFailure = "ACCOUNT_CANNOT_SETTLE"
)

type OrderReq

type OrderReq struct {
	Symbol           string        `url:"symbol"`
	Side             OrderSide     `url:"side"`
	Type             OrderType     `url:"type"`
	Quantity         string        `url:"quantity,omitempty"`
	QuoteQuantity    string        `url:"quoteOrderQty,omitempty"`
	Price            string        `url:"price,omitempty"`
	TimeInForce      TimeInForce   `url:"timeInForce,omitempty"`
	NewClientOrderId string        `url:"newClientOrderId,omitempty"`
	StopPrice        string        `url:"stopPrice,omitempty"`
	IcebergQty       string        `url:"icebergQty,omitempty"`
	OrderRespType    OrderRespType `url:"newOrderRespType,omitempty"`
}

type OrderRespAck

type OrderRespAck struct {
	Symbol            string `json:"symbol"`
	OrderID           int    `json:"orderId"`
	OrigClientOrderID string `json:"origClientOrderId"`
	TransactTime      uint64 `json:"transactTime"`
}

type OrderRespFull

type OrderRespFull struct {
	Symbol              string              `json:"symbol"`
	OrderID             int                 `json:"orderId"`
	OrderListID         int                 `json:"orderListId"`
	ClientOrderID       string              `json:"clientOrderId"`
	TransactTime        int64               `json:"transactTime"`
	Price               string              `json:"price"`
	OrigQty             string              `json:"origQty"`
	ExecutedQty         string              `json:"executedQty"`
	CummulativeQuoteQty string              `json:"cummulativeQuoteQty"`
	Status              OrderStatus         `json:"status"`
	TimeInForce         string              `json:"timeInForce"`
	Type                OrderType           `json:"type"`
	Side                OrderSide           `json:"side"`
	Fills               []OrderRespFullFill `json:"fills"`
}

type OrderRespFullFill

type OrderRespFullFill struct {
	Price           string `json:"price"`
	Qty             string `json:"qty"`
	Commission      string `json:"commission"`
	CommissionAsset string `json:"commissionAsset"`
}

type OrderRespResult

type OrderRespResult struct {
	Symbol              string      `json:"symbol"`
	OrderID             int         `json:"orderId"`
	OrderListID         int         `json:"orderListId"`
	ClientOrderID       string      `json:"clientOrderId"`
	TransactTime        int64       `json:"transactTime"`
	Price               string      `json:"price"`
	OrigQty             string      `json:"origQty"`
	ExecutedQty         string      `json:"executedQty"`
	CummulativeQuoteQty string      `json:"cummulativeQuoteQty"`
	Status              OrderStatus `json:"status"`
	TimeInForce         string      `json:"timeInForce"`
	Type                OrderType   `json:"type"`
	Side                OrderSide   `json:"side"`
}

type OrderRespType

type OrderRespType string

type OrderSide

type OrderSide string
const (
	OrderSideBuy  OrderSide = "BUY"
	OrderSideSell OrderSide = "SELL"
)

type OrderStatus

type OrderStatus string
const (
	OrderStatusNew      OrderStatus = "NEW"
	OrderStatusPartial  OrderStatus = "PARTIALLY_FILLED"
	OrderStatusFilled   OrderStatus = "FILLED"
	OrderStatusCanceled OrderStatus = "CANCELED"
	OrderStatusPending  OrderStatus = "PENDING_CANCEL"
	OrderStatusRejected OrderStatus = "REJECTED"
	OrderStatusExpired  OrderStatus = "EXPIRED"
	OrderStatusReplaced OrderStatus = "REPLACED"
	OrderStatusTrade    OrderStatus = "TRADE"
)

type OrderType

type OrderType string

OrderType represents the order type

const (
	OrderTypeMarket          OrderType = "MARKET"
	OrderTypeLimit           OrderType = "LIMIT"
	OrderTypeStopLoss        OrderType = "STOP_LOSS"
	OrderTypeStopLossLimit   OrderType = "STOP_LOSS_LIMIT"
	OrderTypeTakeProfit      OrderType = "TAKE_PROFIT"
	OrderTypeTakeProfitLimit OrderType = "TAKE_PROFIT_LIMIT"
	OrderTypeLimitMaker      OrderType = "LIMIT_MAKER"
)

type QueryOrder

type QueryOrder struct {
	Symbol              string      `json:"symbol"`
	OrderID             int         `json:"orderId"`
	OrderListID         int         `json:"orderListId"`
	ClientOrderID       string      `json:"clientOrderId"`
	Price               string      `json:"price"`
	OrigQty             string      `json:"origQty"`
	ExecutedQty         string      `json:"executedQty"`
	CummulativeQuoteQty string      `json:"cummulativeQuoteQty"`
	Status              OrderStatus `json:"status"`
	TimeInForce         TimeInForce `json:"timeInForce"`
	Type                OrderType   `json:"type"`
	Side                OrderSide   `json:"side"`
	StopPrice           string      `json:"stopPrice"`
	IcebergQty          string      `json:"IcebergQty"`
	Time                uint64      `json:"time"`
	UpdateTime          uint64      `json:"updateTime"`
	OrigQuoteOrderQty   string      `json:"origQuoteOrderQty"`
}

type QueryOrderReq

type QueryOrderReq struct {
	Symbol            string `url:"symbol"`
	OrderID           int    `url:"orderId,omitempty"`
	OrigClientOrderId string `url:"origClientOrderId,omitempty"`
}

QueryOrderReq represents the request for querying an order Remark: Either OrderID or OrigOrderiD must be set

type ServerTime

type ServerTime struct {
	ServerTime uint64 `json:"serverTime"`
}

type SymbolInfo

type SymbolInfo struct {
	Symbol                   string             `json:"symbol"`
	Status                   SymbolStatus       `json:"status"`
	BaseAsset                string             `json:"baseAsset"`
	BaseAssetPrecision       int                `json:"baseAssetPrecision"`
	QuoteAsset               string             `json:"quoteAsset"`
	QuoteAssetPrecision      int                `json:"quoteAssetPrecision"`
	BaseCommissionPrecision  int                `json:"baseCommissionPrecision"`
	QuoteCommissionPrecision int                `json:"quoteCommissionPrecision"`
	OrderTypes               []OrderType        `json:"orderTypes"`
	IcebergAllowed           bool               `json:"icebergAllowed"`
	OCOAllowed               bool               `json:"ocoAllowed"`
	QuoteQtyAllowed          bool               `json:"quoteOrderQtyMarketAllowed"`
	Filters                  []SymbolInfoFilter `json:"filters"`
}

type SymbolInfoFilter

type SymbolInfoFilter struct {
	Type FilterType `json:"filterType"`

	// PRICE_FILTER parameters
	MinPrice string `json:"minPrice"`
	MaxPrice string `json:"maxPrice"`
	TickSize string `json:"tickSize"`

	// LOT_SIZE parameters
	MinQty   string `json:"minQty"`
	MaxQty   string `json:"maxQty"`
	StepSize string `json:"stepSize"`

	// MIN_NOTIONAL parameters
	MinNotional string `json:"minNotional"`
}

type SymbolPrice

type SymbolPrice struct {
	Symbol string
	Price  string
}

type SymbolStatus

type SymbolStatus string
const (
	SymbolStatusTrading SymbolStatus = "TRADING"
)

type TickerPriceReq

type TickerPriceReq struct {
	Symbol string `url:"symbol"`
}

type TickerReq

type TickerReq struct {
	Symbol string `url:"symbol"`
}

TickerReq represents the request for a specified ticker

type TickerStats

type TickerStats struct {
	Symbol                string `json:"symbol"`
	PriceChange           string `json:"priceChange"`
	PriceChangePercentage string `json:"priceChangePercent"`
	WeightedAvgPrice      string `json:"weightedAvgPrice"`
	PrevClosePrice        string `json:"prevClosePrice"`
	LastPrice             string `json:"lastPrice"`
	BidPrice              string `json:"bidPrice"`
	AskPrice              string `json:"askPrice"`
	OpenPrice             string `json:"openPrice"`
	HighPrice             string `json:"highPrice"` // HighPrice is 24hr high price
	LowPrice              string `json:"lowPrice"`  // LowPrice is 24hr low price
	Volume                string `json:"volume"`
	QuoteVolume           string `json:"quoteVolume"`
	OpenTime              uint64 `json:"openTime"`
	CloseTime             uint64 `json:"closeTime"`
	FirstID               int    `json:"firstId"`
	LastID                int    `json:"lastId"`
	Count                 int    `json:"count"`
}

TickerStats is the stats for a specific symbol

type TimeInForce

type TimeInForce string
const (
	TimeInForceGTC TimeInForce = "GTC" // Good Till Cancel
	TimeInForceIOC TimeInForce = "IOC" // Immediate or Cancel
	TimeInForceFOK TimeInForce = "FOK" // Fill or Kill
)

type Trade

type Trade struct {
	ID           int    `json:"id"`
	Price        string `json:"price"`
	Qty          string `json:"qty"`
	QuoteQty     string `json:"quoteQty"`
	Time         int64  `json:"time"`
	IsBuyerMaker bool   `json:"isBuyerMaker"`
	IsBestMatch  bool   `json:"isBestMatch"`
}

type TradeReq

type TradeReq struct {
	Symbol string `url:"symbol"` // Symbol is the symbol to fetch data for
	Limit  int    `url:"limit"`  // Limit is the maximal number of elements to receive. Default 500 Max 1000
}

TradeReq are used to specify symbol to get recent trades

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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