binance

package
v0.0.184 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BASE_URL    = "https://api.binance.com"
	BASE_URL_1  = "https://api1.binance.com"
	BASE_URL_2  = "https://api2.binance.com"
	BASE_URL_3  = "https://api3.binance.com"
	BASE_URL_US = "https://api.binance.us"
)
View Source
const (
	MAX_LEN = 36
	BROKER  = "J6MCRYME"
)
View Source
const (
	WEIGHT_ALL_ORDERS                 = 10
	WEIGHT_CANCEL_ORDER               = 1
	WEIGHT_CREATE_OCO_ORDER           = 1
	WEIGHT_CREATE_ORDER               = 1
	WEIGHT_EXCHANGE_INFO              = 10
	WEIGHT_OPEN_ORDERS_WITH_SYMBOL    = 3
	WEIGHT_OPEN_ORDERS_WITHOUT_SYMBOL = 40
	WEIGHT_TICKER_24H_WITH_SYMBOL     = 1
	WEIGHT_TICKER_24H_WITHOUT_SYMBOL  = 40
)

Variables

View Source
var (
	SERVER_TIME_OFFSET int64     // offset between device time and server time
	SERVER_TIME_UPDATE time.Time // the last time we asked for server time
)
View Source
var (
	BeforeRequest func(client *Client, weight int) error = nil
	AfterRequest  func()                                 = nil
)

Functions

func GetRequestsPerSecond

func GetRequestsPerSecond(client *Client, weight int) (float64, error)

func GetSymbol

func GetSymbol(client *Client, name string) (*exchange.Symbol, error)

func NewClientOrderID

func NewClientOrderID() string

func NewClientOrderMetadata

func NewClientOrderMetadata(metadata string) (string, error)

func ParseClientOrderMetadata

func ParseClientOrderMetadata(order *Order) (string, error)

get metadata from order.ClientOrderId

Types

type BinanceError

type BinanceError = common.APIError

func IsBinanceError

func IsBinanceError(err error) (*BinanceError, bool)

type BookEntry

type BookEntry = common.PriceLevel

type Cache added in v0.0.178

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

type Client

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

func New

func New(baseURL, apiKey, apiSecret string) *Client

func (*Client) CancelOrder

func (self *Client) CancelOrder(symbol string, orderID int64) error

Cancel an active order.

func (*Client) Depth

func (self *Client) Depth(symbol string, limit int) (*exchange.DepthResponse, error)

func (*Client) NewCreateOCOService

func (self *Client) NewCreateOCOService() *CreateOCOService

func (*Client) NewCreateOrderService

func (self *Client) NewCreateOrderService() *CreateOrderService

func (*Client) OpenOrders

func (self *Client) OpenOrders() ([]Order, error)

Get all open orders without a symbol.

func (*Client) OpenOrdersEx

func (self *Client) OpenOrdersEx(symbol string) ([]Order, error)

Get all open orders on a symbol.

func (*Client) Orders

func (self *Client) Orders(symbol string) ([]Order, error)

Get all account orders; active, canceled, or filled.

func (*Client) Ticker

func (self *Client) Ticker(symbol string) (*exchange.PriceChangeStats, error)

24 hour rolling window price change statistics.

type CreateOCOService

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

func (*CreateOCOService) Do

func (*CreateOCOService) LimitClientOrderID

func (self *CreateOCOService) LimitClientOrderID(limitClientOrderID string) *CreateOCOService

func (*CreateOCOService) Price

func (self *CreateOCOService) Price(price float64) *CreateOCOService

func (*CreateOCOService) Quantity

func (self *CreateOCOService) Quantity(quantity float64) *CreateOCOService

func (*CreateOCOService) Side

func (*CreateOCOService) StopClientOrderID

func (self *CreateOCOService) StopClientOrderID(stopClientOrderID string) *CreateOCOService

func (*CreateOCOService) StopLimitPrice

func (self *CreateOCOService) StopLimitPrice(stopLimitPrice float64) *CreateOCOService

func (*CreateOCOService) StopLimitTimeInForce

func (self *CreateOCOService) StopLimitTimeInForce(stopLimitTimeInForce exchange.TimeInForceType) *CreateOCOService

func (*CreateOCOService) StopPrice

func (self *CreateOCOService) StopPrice(stopPrice float64) *CreateOCOService

func (*CreateOCOService) Symbol

func (self *CreateOCOService) Symbol(symbol string) *CreateOCOService

type CreateOrderService

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

func (*CreateOrderService) Do

func (*CreateOrderService) NewClientOrderID

func (self *CreateOrderService) NewClientOrderID(newClientOrderID string) *CreateOrderService

func (*CreateOrderService) Price

func (self *CreateOrderService) Price(price float64) *CreateOrderService

func (*CreateOrderService) Quantity

func (self *CreateOrderService) Quantity(quantity float64) *CreateOrderService

func (*CreateOrderService) Side

func (*CreateOrderService) StopPrice

func (self *CreateOrderService) StopPrice(stopPrice float64) *CreateOrderService

func (*CreateOrderService) Symbol

func (self *CreateOrderService) Symbol(symbol string) *CreateOrderService

func (*CreateOrderService) TimeInForce

func (self *CreateOrderService) TimeInForce(timeInForce exchange.TimeInForceType) *CreateOrderService

func (*CreateOrderService) Type

type Order

type Order struct {
	*exchange.Order
}

func (*Order) CreatedAt

func (self *Order) CreatedAt() time.Time

CreatedAt returns the order creation time as time.Time

func (*Order) GetPrice

func (self *Order) GetPrice() float64

GetPrice returns the Price as float64

func (*Order) GetSize

func (self *Order) GetSize() float64

GetSize returns the Quantity as float64

func (*Order) GetStopPrice

func (self *Order) GetStopPrice() float64

GetStopPrice returns the StopPrice as float64

func (*Order) UpdatedAt

func (self *Order) UpdatedAt() time.Time

UpdatedAt returns the last time the order was updated as time.Time

type Prec

type Prec struct {
	Symbol exchange.Symbol
	Price  int
	Size   int
	Min    float64 // minimum notional value (aka price * quantity) allowed for an order
}

type Precs

type Precs []Prec

func GetPrecs

func GetPrecs(client *Client, cached bool) (Precs, error)

func (Precs) PrecFromSymbol

func (self Precs) PrecFromSymbol(symbol string) *Prec

Jump to

Keyboard shortcuts

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