binance

package
v0.0.0-...-78b482a Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL   string
	SecretKey string
	ApiKey    string
}

Client is aclient for the Binance API.

func NewClient

func NewClient(BaseURl, SecretKey, ApiKey string) *Client

NewClient creates a new client for the Binance API

func (*Client) AccountInfo

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

AccountInfo returns teh account information.

func (*Client) AccountInfoPretty

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

AccountInfoPretty returns the account information in a pretty format.

func (*Client) ExchangeInfo

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

ExchangeInfo returns the exchange info.

func (*Client) Order

func (c *Client) Order(opts map[string]string) (*ResponseOrder, error)

Order places an order.

func (*Client) StepSize

func (c *Client) StepSize(symbols ...string) (map[string]string, error)

StepSize returns the step size for the symbol(s).

func (*Client) Time

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

Time returns the server time.

type ExchangeFilters

type ExchangeFilters struct{}

ExchangeFilters is the exchange filters for the exchange info endpoint.

type Filters

type Filters struct {
	FilterType            string `json:"filterType"`
	PriceFilter           string `json:"priceFilter"`
	MinPrice              string `json:"minPrice"`
	MaxPrice              string `json:"maxPrice"`
	TickSize              string `json:"tickSize"`
	MinQty                string `json:"minQty"`
	MaxQty                string `json:"maxQty"`
	StepSize              string `json:"stepSize"`
	Limit                 int    `json:"limit"`
	MinTrailingAboveDelta int    `json:"minTrailingAboveDelta"`
	MaxTrailingAboveDelta int    `json:"maxTrailingAboveDelta"`
	MinTrailingBelowDelta int    `json:"minTrailingBelowDelta"`
	MaxTrailingBelowDelta int    `json:"maxTrailingBelowDelta"`
	BidMultiplierUp       string `json:"bidMultiplierUp"`
	BidMultiplierDown     string `json:"bidMultiplierDown"`
	AskMultiplierUp       string `json:"askMultiplierUp"`
	AskMultiplierDown     string `json:"askMultiplierDown"`
	AvgPriceMins          int    `json:"avgPriceMins"`
	MinNotional           string `json:"minNotional"`
	MaxNotional           string `json:"maxNotional"`
	ApplyMinToMarket      bool   `json:"applyMinToMarket"`
	ApplyMaxToMarket      bool   `json:"applyMaxToMarket"`
	MaxNumOrders          int    `json:"maxNumOrders"`
	MaxNumAlgoOrders      int    `json:"maxNumAlgoOrders"`
}

Filters is the filters for the exchange info endpoint.

type OrderSide

type OrderSide string

OrderSide is an enum for the order side.

const OrderSideBuy OrderSide = "BUY"

OrderSideBuy represents the buy side of an order.

const OrderSideSell OrderSide = "SELL"

OrderSideSell represents the sell side of an order.

type OrderType

type OrderType string

OrderType is an enum for the order type.

const OrderTypeLimit OrderType = "LIMIT"

OrderTypeLimit represents a limit order.

const OrderTypeMarket OrderType = "MARKET"

OrderTypeMarket represents a market order.

type RateLimits

type RateLimits struct {
	RateLimitType string `json:"rateLimitType"`
	Interval      string `json:"interval"`
	IntervalNum   int    `json:"intervalNum"`
	Limit         int    `json:"limit"`
}

RateLimits is the rate limits for the exchange info endpoint.

type ResponseAccount

type ResponseAccount struct {
	Balances []struct {
		Asset string `json:"asset"`
		Free  string `json:"free"`
	} `json:"balances"`
}

ResponseAccount is the response from the account endpoint.

type ResponseExchangeInfo

type ResponseExchangeInfo struct {
	Timezone        string            `json:"timezone"`
	ServerTime      int64             `json:"serverTime"`
	RateLimits      []RateLimits      `json:"rateLimits"`
	ExchangeFilters []ExchangeFilters `json:"exchangeFilters"`
	Symbols         []Symbols         `json:"symbols"`
}

ResponseExchangeInfo is the response from the exchange info endpoint.

type ResponseOrder

type ResponseOrder struct {
	Code               int    `json:"code"`
	Msg                string `json:"msg"`
	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"`
	CumulativeQuoteQty string `json:"cumulativeQuoteQty"`
	Status             string `json:"status"`
	TimeInForce        string `json:"timeInForce"`
	Type               string `json:"type"`
	Side               string `json:"side"`
	WorkingTime        int64  `json:"workingTime"`
	Fills              []struct {
		Price                   string `json:"price"`
		Qty                     string `json:"qty"`
		Commission              string `json:"commission"`
		CommissionAsset         string `json:"commissionAsset"`
		TradeId                 int    `json:"tradeId"`
		SelfTradePreventionMode string `json:"selfTradePreventionMode"`
	}
}

ResponseOrder is the response from the order endpoint.

type ResponseTime

type ResponseTime struct {
	ServerTime int64 `json:"serverTime"`
}

ResponseTime is the response from the endpoint.

type Symbols

type 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"`
	QuoteAssetPrecision             int       `json:"quoteAssetPrecision"`
	OrderTypes                      []string  `json:"orderTypes"`
	IcebergAllowed                  bool      `json:"icebergAllowed"`
	OcoAllowed                      bool      `json:"ocoAllowed"`
	QuoteOrderQtyMarketAllowed      bool      `json:"quoteOrderQtyMarketAllowed"`
	AllowTrailingStop               bool      `json:"allowTrailingStop"`
	CancelReplaceAllowed            bool      `json:"cancelReplaceAllowed"`
	IsSpotTradingAllowed            bool      `json:"isSpotTradingAllowed"`
	IsMarginTradingAllowed          bool      `json:"isMarginTradingAllowed"`
	Filters                         []Filters `json:"filters"`
	Permissions                     []string  `json:"permissions"`
	DefaultSelfTradePreventionMode  string    `json:"defaultSelfTradePreventionMode"`
	AllowedSelfTradePreventionModes []string  `json:"allowedSelfTradePreventionModes"`
}

Symbols is the symbols for the exchange info endpoint.

Jump to

Keyboard shortcuts

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