binance

package module
v0.0.0-...-d37f510 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

binance-api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Spot *SpotApi
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conf *Config) *Client

type Config

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

func NewConfig

func NewConfig(key, secret string, logger *log.Logger, debug bool) *Config

type CreateOrderRespMsg

type CreateOrderRespMsg struct {
	Symbol        string `json:"symbol"`
	OrderId       int64  `json:"orderId"`
	OrderListId   int64  `json:"orderListId"`
	ClientOrderId string `json:"clientOrderId"`
	TransactTime  int64  `json:"transactTime"`

	// ACK response does not contain the following fields
	Price               float64 `json:"price,string,omitempty"`
	OrigQty             float64 `json:"origQty,string,omitempty"`
	ExecutedQty         float64 `json:"executedQty,string,omitempty"`
	CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string,omitempty"`
	Status              string  `json:"status,omitempty"`
	TimeInForce         string  `json:"timeInForce,omitempty"`
	Type                string  `json:"type,omitempty"`
	Side                string  `json:"side,omitempty"`

	// the following fields are only for FULL response
	Fills []*OrderFill `json:"fills,omitempty"`
}

response type: ACK RESULT FULL

type ExchangeInfo

type ExchangeInfo 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"`
	QuoteAssetPrecision        int                   `json:"quoteAssetPrecision"`
	BaseCommissionPrecision    int                   `json:"baseCommissionPrecision"`
	QuoteCommissionPrecision   int                   `json:"quoteCommissionPrecision"`
	OrderTypes                 []string              `json:"orderTypes"`
	IcebergAllowed             bool                  `json:"icebergAllowed"`
	OcoAllowed                 bool                  `json:"ocoAllowed"`
	QuoteOrderQtyMarketAllowed bool                  `json:"quoteOrderQtyMarketAllowed"`
	AllowTrailingStop          bool                  `json:"allowTrailingStop"`
	IsSpotTradingAllowed       bool                  `json:"isSpotTradingAllowed"`
	IsMarginTradingAllowed     bool                  `json:"isMarginTradingAllowed"`
	Filters                    []*ExchangeInfoFilter `json:"filters"`
	Permissions                []string              `json:"permissions"`
}

type ExchangeInfoFilter

type ExchangeInfoFilter struct {
	FilterType string `json:"filterType"`

	// for PRICE_FILTER
	MinPrice float64 `json:"minPrice,string,omitempty"`
	MaxPrice float64 `json:"maxPrice,string,omitempty"`
	TickSize float64 `json:"tickSize,string,omitempty"`

	// for PERCENT_PRICE
	MultiplierUp   float64 `json:"multiplierUp,string,omitempty"`
	MultiplierDown float64 `json:"multiplierDown,string,omitempty"`
	AvgPriceMins   int     `json:"avgPriceMins,omitempty"` // also for MIN_NOTIONAL

	// for LOT_SIZE and MARKET_LOT_SIZE
	MinQty   float64 `json:"minQty,string,omitempty"`
	MaxQty   float64 `json:"maxQty,string,omitempty"`
	StepSize float64 `json:"stepSize,string,omitempty"`

	// for MIN_NOTIONAL
	MinNotional   float64 `json:"minNotional,string,omitempty"`
	ApplyToMarket bool    `json:"applyToMarket,omitempty"`

	// for ICEBERG_PARTS
	Limit int `json:"limit,omitempty"`

	// for MAX_NUM_ORDERS
	MaxNumOrders int `json:"maxNumOrders,omitempty"`

	// for MAX_NUM_ALGO_ORDERS
	MaxNumAlgoOrders int `json:"maxNumAlgoOrders,omitempty"`
}

type ExchangeInfoMsg

type ExchangeInfoMsg struct {
	// other fields are not used, wait for later complemention
	ExchangeInfoList []*ExchangeInfo `json:"symbols"`
}

type HmacSigner

type HmacSigner struct {
	Key []byte
}

HmacSigner uses HMAC SHA256 for signing payloads.

func (*HmacSigner) Sign

func (hs *HmacSigner) Sign(payload []byte) string

Sign signs provided payload and returns encoded string sum.

type OrderFill

type OrderFill struct {
	Price           float64 `json:"price,string"`
	Qty             float64 `json:"qty,string"`
	Commission      float64 `json:"commission,string"`
	CommissionAsset string  `json:"commissionAsset"`
	TradeId         int64   `json:"tradeId"`
}

type Signer

type Signer interface {
	// Sign signs provided payload and returns encoded string sum.
	Sign(payload []byte) string
}

Signer signs provided payloads.

type SpotApi

type SpotApi Client

func (*SpotApi) CancelOrderById

func (spot *SpotApi) CancelOrderById(symbol string, orderId string) (*http.Response, error)

func (*SpotApi) CancelOrdersBySymbol

func (spot *SpotApi) CancelOrdersBySymbol(symbol string) (*http.Response, error)

func (*SpotApi) CreateLimitOrder

func (spot *SpotApi) CreateLimitOrder(symbol string, side string, quantity string, price string, timeInForce string) (*CreateOrderRespMsg, error)

func (*SpotApi) CreateMarketBaseQuantityOrder

func (spot *SpotApi) CreateMarketBaseQuantityOrder(symbol string, side string, quantity string) (*CreateOrderRespMsg, error)

func (*SpotApi) CreateMarketQuoteQuantityOrder

func (spot *SpotApi) CreateMarketQuoteQuantityOrder(symbol string, side string, quoteOrderQty string) (*CreateOrderRespMsg, error)

func (*SpotApi) GetExchangeInfo

func (spot *SpotApi) GetExchangeInfo() (*ExchangeInfoMsg, error)

func (*SpotApi) Ping

func (spot *SpotApi) Ping() (*http.Response, error)

func (*SpotApi) QueryAllOpenOrders

func (spot *SpotApi) QueryAllOpenOrders() (*http.Response, error)

func (*SpotApi) QueryOpenOrdersBySymbol

func (spot *SpotApi) QueryOpenOrdersBySymbol(symbol string) (*http.Response, error)

func (*SpotApi) QueryOrderById

func (spot *SpotApi) QueryOrderById(symbol string, orderId string) (*http.Response, error)

Jump to

Keyboard shortcuts

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