binance

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.2

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 added in v0.1.2

func NewBinanceClient(signer Signer, interf EndpointsInterface) *Client

NewBinanceClient return new endpoint instance for using binance

func (*Client) CancelOrder added in v0.1.2

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

CancelOrder cancel an open order

func (*Client) DepositHistory added in v0.1.2

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

DepositHistory get deposit history from binance

func (*Client) GetAccountTradeHistory added in v0.1.2

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 added in v0.1.2

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

GetDepositAddress get deposit address of token from binance

func (*Client) GetDepthOnePair added in v0.1.2

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

GetDepthOnePair return list of orderbook for one pair of tokens

func (*Client) GetExchangeInfo added in v0.1.2

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 added in v0.1.2

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

GetInfo return account info including balance info

func (*Client) GetResponse added in v0.1.2

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 added in v0.1.2

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

GetTradeHistory return trade history from an account

func (*Client) OpenOrdersForOnePair added in v0.1.2

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

OpenOrdersForOnePair get open orders for one pair of token and quote

func (*Client) OrderStatus added in v0.1.2

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

OrderStatus check order status

func (*Client) Trade added in v0.1.2

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 added in v0.1.2

func (ep *Client) UpdateTimeDelta() error

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

func (*Client) Withdraw added in v0.1.2

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 added in v0.1.2

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

WithdrawHistory get withdraw history

type Endpoints added in v0.1.2

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

func (*Endpoints) AuthenticatedEndpoint added in v0.1.2

func (r *Endpoints) AuthenticatedEndpoint() string

func (*Endpoints) PublicEndpoint added in v0.1.2

func (r *Endpoints) PublicEndpoint() string

type EndpointsInterface added in v0.1.2

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 added in v0.1.2

func NewEndpoints(baseURL string) EndpointsInterface

NewEndpoints ...

type Signer

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

func NewSigner added in v0.1.1

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

func (Signer) GetKey added in v0.1.1

func (s Signer) GetKey() string

func (Signer) Sign added in v0.1.1

func (s Signer) Sign(msg string) string

type Storage added in v0.1.1

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

Storage storage binance information including trade history

func NewBoltStorage added in v0.1.1

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

NewBoltStorage create database and related bucket for binance storage

func (*Storage) GetLastIDTradeHistory added in v0.1.1

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 added in v0.1.1

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

GetTradeHistory return trade history from binance from time to time

func (*Storage) StoreTradeHistory added in v0.1.1

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

StoreTradeHistory store binance trade history

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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