Back to godoc.org

Package binance

v0.1.2
Latest Go to latest

The latest major version is .

Published: Jan 9, 2020 | License: MIT | Module: github.com/KyberNetwork/reserve-data

Index

type Client

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

Client object stand for Binance endpoint including signer for api call authentication, interf for calling api in different env timedelta to make sure calling api in time

func NewBinanceClient

func NewBinanceClient(signer Signer, interf EndpointsInterface) *Client

NewBinanceClient return new endpoint instance for using binance

func (*Client) CancelOrder

func (ep *Client) CancelOrder(symbol string, id uint64) (exchange.Binacancel, error)

CancelOrder cancel an open order

func (*Client) DepositHistory

func (ep *Client) DepositHistory(startTime, endTime uint64) (exchange.Binadeposits, error)

DepositHistory get deposit history from binance

func (*Client) GetAccountTradeHistory

func (ep *Client) GetAccountTradeHistory(
	base, quote common.Token,
	fromID string) (exchange.BinaAccountTradeHistory, error)

GetAccountTradeHistory return trade history from our account on binance

func (*Client) GetDepositAddress

func (ep *Client) GetDepositAddress(asset string) (exchange.Binadepositaddress, error)

GetDepositAddress get deposit address of token from binance

func (*Client) GetDepthOnePair

func (ep *Client) GetDepthOnePair(baseID, quoteID string) (exchange.Binaresp, error)

GetDepthOnePair return list of orderbook for one pair of tokens

func (*Client) GetExchangeInfo

func (ep *Client) GetExchangeInfo() (exchange.BinanceExchangeInfo, error)

GetExchangeInfo return info from exchange include base, quote asset precision min, max price, min notional

func (*Client) GetInfo

func (ep *Client) GetInfo() (exchange.Binainfo, error)

GetInfo return account info including balance info

func (*Client) GetResponse

func (ep *Client) GetResponse(
	method string, url string,
	params map[string]string, signNeeded bool, timepoint uint64) ([]byte, error)

GetResponse function to do the request to binance

func (*Client) GetTradeHistory

func (ep *Client) GetTradeHistory(symbol string) (exchange.BinanceTradeHistory, error)

GetTradeHistory return trade history from an account

func (*Client) OpenOrdersForOnePair

func (ep *Client) OpenOrdersForOnePair(pair common.TokenPair) (exchange.Binaorders, error)

OpenOrdersForOnePair get open orders for one pair of token and quote

func (*Client) OrderStatus

func (ep *Client) OrderStatus(symbol string, id uint64) (exchange.Binaorder, error)

OrderStatus check order status

func (*Client) Trade

func (ep *Client) Trade(tradeType string, base, quote common.Token, rate, amount float64) (exchange.Binatrade, error)

Trade Relevant params: symbol ("%s%s", base, quote) side (BUY/SELL) type (LIMIT/MARKET) timeInForce (GTC/IOC) quantity price

In this version, we only support LIMIT order which means only buy/sell with acceptable price, and GTC time in force which means that the order will be active until it's implicitly canceled

func (*Client) UpdateTimeDelta

func (ep *Client) UpdateTimeDelta() error

UpdateTimeDelta check binance time server then adjust timeDelta params to make sure the request valid

func (*Client) Withdraw

func (ep *Client) Withdraw(token common.Token, amount *big.Int, address ethereum.Address) (string, error)

Withdraw token from binance to our reserve

func (*Client) WithdrawHistory

func (ep *Client) WithdrawHistory(startTime, endTime uint64) (exchange.Binawithdrawals, error)

WithdrawHistory get withdraw history

type Endpoints

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

func (*Endpoints) AuthenticatedEndpoint

func (r *Endpoints) AuthenticatedEndpoint() string

func (*Endpoints) PublicEndpoint

func (r *Endpoints) PublicEndpoint() string

type EndpointsInterface

type EndpointsInterface interface {
	// PublicEndpoint returns the endpoint that does not requires authentication.
	PublicEndpoint() string
	// AuthenticatedEndpoint returns the endpoint that requires authentication.
	// In simulation mode, authenticated endpoint is the Binance mock server.
	AuthenticatedEndpoint() string
}

EndpointsInterface is Binance exchange API endpoints interface.

func NewEndpoints

func NewEndpoints(baseURL string) EndpointsInterface

NewEndpoints ...

type Signer

type Signer struct {
	Key    string `json:"binance_key"`
	Secret string `json:"binance_secret"`
}

func NewSigner

func NewSigner(key, secret string) (*Signer, error)

func (Signer) GetKey

func (s Signer) GetKey() string

func (Signer) Sign

func (s Signer) Sign(msg string) string

type Storage

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

Storage storage binance information including trade history

func NewBoltStorage

func NewBoltStorage(path string) (*Storage, error)

NewBoltStorage create database and related bucket for binance storage

func (*Storage) GetLastIDTradeHistory

func (bs *Storage) GetLastIDTradeHistory(pair string) (string, error)

GetLastIDTradeHistory return last id of trade history of a token using for query trade history from binance

func (*Storage) GetTradeHistory

func (bs *Storage) GetTradeHistory(fromTime, toTime uint64) (common.ExchangeTradeHistory, error)

GetTradeHistory return trade history from binance from time to time

func (*Storage) StoreTradeHistory

func (bs *Storage) StoreTradeHistory(data common.ExchangeTradeHistory) error

StoreTradeHistory store binance trade history

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier