binance

package
v0.0.0-...-8bcfbc3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: MIT Imports: 15 Imported by: 0

README

GoCryptoTrader package Binance

Build Status Software License GoDoc Coverage Status Go Report Card

This binance package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Binance Exchange

Current Features
  • Initial generation
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedTrade

type AggregatedTrade struct {
	ATradeID       int64   `json:"a"`
	Price          float64 `json:"p,string"`
	Quantity       float64 `json:"q,string"`
	FirstTradeID   int64   `json:"f"`
	LastTradeID    int64   `json:"l"`
	TimeStamp      int64   `json:"T"`
	Maker          bool    `json:"m"`
	BestMatchPrice bool    `json:"M"`
}

AggregatedTrade holds aggregated trade information

type BestPrice

type BestPrice struct {
	Symbol   string  `json:"symbol"`
	BidPrice float64 `json:"bidPrice,string"`
	BidQty   float64 `json:"bidQty,string"`
	AskPrice float64 `json:"askPrice,string"`
	AskQty   float64 `json:"askQty,string"`
}

BestPrice holds best price data

type Binance

type Binance struct {
	exchange.Base

	*request.Handler
	// contains filtered or unexported fields
}

Binance is the overarching type across the Bithumb package

func (*Binance) CheckIntervals

func (b *Binance) CheckIntervals(interval string) error

CheckIntervals checks value against a variable list

func (*Binance) CheckLimit

func (b *Binance) CheckLimit(limit int64) error

CheckLimit checks value against a variable list

func (*Binance) CheckSymbol

func (b *Binance) CheckSymbol(symbol string) error

CheckSymbol checks value against a variable list

func (*Binance) GetAggregatedTrades

func (b *Binance) GetAggregatedTrades(symbol string, limit int64) ([]AggregatedTrade, error)

GetAggregatedTrades returns aggregated trade activity

symbol: string of currency pair limit: returned limit amount WARNING: MAX 500!

func (*Binance) GetBestPrice

func (b *Binance) GetBestPrice(symbol string) (BestPrice, error)

GetBestPrice returns the latest best price for symbol

symbol: string of currency pair

func (*Binance) GetCandleStickData

func (b *Binance) GetCandleStickData(symbol, interval string, limit int64) ([]CandleStick, error)

GetCandleStickData returns candle stick data

symbol: limit: interval

func (*Binance) GetExchangeAccountInfo

func (b *Binance) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the Bithumb exchange

func (*Binance) GetExchangeHistory

func (b *Binance) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*Binance) GetExchangeInfo

func (b *Binance) GetExchangeInfo() (ExchangeInfo, error)

GetExchangeInfo returns exchange information. Check binance_types for more information

func (*Binance) GetExchangeValidCurrencyPairs

func (b *Binance) GetExchangeValidCurrencyPairs() ([]string, error)

GetExchangeValidCurrencyPairs returns the full pair list from the exchange at the moment do not integrate with config currency pairs automatically

func (*Binance) GetHistoricalTrades

func (b *Binance) GetHistoricalTrades(symbol string, limit, fromID int64) ([]HistoricalTrade, error)

GetHistoricalTrades returns historical trade activity

symbol: string of currency pair limit: returned limit amount WARNING: MAX 500! (NOT REQUIRED) fromID:

func (*Binance) GetLatestSpotPrice

func (b *Binance) GetLatestSpotPrice(symbol string) (SymbolPrice, error)

GetLatestSpotPrice returns latest spot price of symbol

symbol: string of currency pair

func (*Binance) GetOrderBook

func (b *Binance) GetOrderBook(symbol string, limit int64) (OrderBook, error)

GetOrderBook returns full orderbook information

symbol: string of currency pair limit: returned limit amount

func (*Binance) GetOrderbookEx

func (b *Binance) GetOrderbookEx(currency pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*Binance) GetPriceChangeStats

func (b *Binance) GetPriceChangeStats(symbol string) (PriceChangeStats, error)

GetPriceChangeStats returns price change statistics for the last 24 hours

symbol: string of currency pair

func (*Binance) GetRecentTrades

func (b *Binance) GetRecentTrades(symbol string, limit int64) ([]RecentTrade, error)

GetRecentTrades returns recent trade activity

symbol: string of currency pair limit: returned limit amount WARNING: MAX 500!

func (*Binance) GetTickerPrice

func (b *Binance) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*Binance) GetTickers

func (b *Binance) GetTickers() ([]PriceChangeStats, error)

GetTickers returns the ticker data for the last 24 hrs

func (*Binance) NewOrder

func (b *Binance) NewOrder(o NewOrderRequest) (NewOrderResponse, error)

NewOrder sends a new order to Binance

func (*Binance) NewOrderTest

func (b *Binance) NewOrderTest() (interface{}, error)

NewOrderTest sends a new order

func (*Binance) QueryOrder

func (b *Binance) QueryOrder(symbol, origClientOrderID string, orderID int64) (QueryOrderData, error)

QueryOrder returns information on a past order

func (*Binance) Run

func (b *Binance) Run()

Run implements the OKEX wrapper

func (*Binance) SendAuthHTTPRequest

func (b *Binance) SendAuthHTTPRequest(method, path string, params url.Values, result interface{}) error

SendAuthHTTPRequest sends an authenticated HTTP request

func (*Binance) SendHTTPRequest

func (b *Binance) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated request

func (*Binance) SetDefaults

func (b *Binance) SetDefaults()

SetDefaults sets the basic defaults for Binance

func (*Binance) SetValues

func (b *Binance) SetValues()

SetValues sets the default valid values

func (*Binance) Setup

func (b *Binance) Setup(exch config.ExchangeConfig)

Setup takes in the supplied exchange configuration details and sets params

func (*Binance) Start

func (b *Binance) Start()

Start starts the OKEX go routine

func (*Binance) UpdateOrderbook

func (b *Binance) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Binance) UpdateTicker

func (b *Binance) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

type CandleStick

type CandleStick struct {
	OpenTime                 float64
	Open                     float64
	High                     float64
	Low                      float64
	Close                    float64
	Volume                   float64
	CloseTime                float64
	QuoteAssetVolume         float64
	TradeCount               float64
	TakerBuyAssetVolume      float64
	TakerBuyQuoteAssetVolume float64
}

CandleStick holds kline data

type ExchangeInfo

type ExchangeInfo struct {
	Code       int    `json:"code"`
	Msg        string `json:"msg"`
	Timezone   string `json:"timezone"`
	Servertime int64  `json:"serverTime"`
	RateLimits []struct {
		RateLimitType string `json:"rateLimitType"`
		Interval      string `json:"interval"`
		Limit         int    `json:"limit"`
	} `json:"rateLimits"`
	ExchangeFilters interface{} `json:"exchangeFilters"`
	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"`
		OrderTypes         []string `json:"orderTypes"`
		IcebergAllowed     bool     `json:"icebergAllowed"`
		Filters            []struct {
			FilterType  string  `json:"filterType"`
			MinPrice    float64 `json:"minPrice,string"`
			MaxPrice    float64 `json:"maxPrice,string"`
			TickSize    float64 `json:"tickSize,string"`
			MinQty      float64 `json:"minQty,string"`
			MaxQty      float64 `json:"maxQty,string"`
			StepSize    float64 `json:"stepSize,string"`
			MinNotional float64 `json:"minNotional,string"`
		} `json:"filters"`
	} `json:"symbols"`
}

ExchangeInfo holds the full exchange information type

type HistoricalTrade

type HistoricalTrade struct {
	Code         int     `json:"code"`
	Msg          string  `json:"msg"`
	ID           int64   `json:"id"`
	Price        float64 `json:"price,string"`
	Quantity     float64 `json:"qty,string"`
	Time         int64   `json:"time"`
	IsBuyerMaker bool    `json:"isBuyerMaker"`
	IsBestMatch  bool    `json:"isBestMatch"`
}

HistoricalTrade holds recent trade data

type NewOrderRequest

type NewOrderRequest struct {
	Symbol           string
	Side             string
	TradeType        string
	TimeInForce      string
	Quantity         float64
	Price            float64
	NewClientOrderID string
	StopPrice        float64
	IcebergQty       float64
	NewOrderRespType string
}

NewOrderRequest request type

type NewOrderResponse

type NewOrderResponse struct {
	Code            int     `json:"code"`
	Msg             string  `json:"msg"`
	Symbol          string  `json:"symbol"`
	OrderID         int64   `json:"orderId"`
	ClientOrderID   string  `json:"clientOrderId"`
	TransactionTime int64   `json:"transactTime"`
	Price           float64 `json:"price,string"`
	OrigQty         float64 `json:"origQty,string"`
	ExecutedQty     float64 `json:"executedQty,string"`
	Status          string  `json:"status"`
	TimeInForce     string  `json:"timeInForce"`
	Type            string  `json:"type"`
	Side            string  `json:"side"`
	Fills           []struct {
		Price           float64 `json:"price,string"`
		Qty             float64 `json:"qty,string"`
		Commission      float64 `json:"commission,string"`
		CommissionAsset float64 `json:"commissionAsset,string"`
	} `json:"fills"`
}

NewOrderResponse is the return structured response from the exchange

type OrderBook

type OrderBook struct {
	Code int
	Msg  string
	Bids []struct {
		Price    float64
		Quantity float64
	}
	Asks []struct {
		Price    float64
		Quantity float64
	}
}

OrderBook actual structured data that can be used for orderbook

type OrderBookData

type OrderBookData struct {
	Code         int           `json:"code"`
	Msg          string        `json:"msg"`
	LastUpdateID int64         `json:"lastUpdateId"`
	Bids         []interface{} `json:"bids"`
	Asks         []interface{} `json:"asks"`
}

OrderBookData is resp data from orderbook endpoint

type PriceChangeStats

type PriceChangeStats struct {
	Symbol             string  `json:"symbol"`
	PriceChange        float64 `json:"priceChange,string"`
	PriceChangePercent float64 `json:"priceChangePercent,string"`
	WeightedAvgPrice   float64 `json:"weightedAvgPrice,string"`
	PrevClosePrice     float64 `json:"prevClosePrice,string"`
	LastPrice          float64 `json:"lastPrice,string"`
	LastQty            float64 `json:"lastQty,string"`
	BidPrice           float64 `json:"bidPrice,string"`
	AskPrice           float64 `json:"askPrice,string"`
	OpenPrice          float64 `json:"openPrice,string"`
	HighPrice          float64 `json:"highPrice,string"`
	LowPrice           float64 `json:"lowPrice,string"`
	Volume             float64 `json:"volume,string"`
	QuoteVolume        float64 `json:"quoteVolume,string"`
	OpenTime           int64   `json:"openTime"`
	CloseTime          int64   `json:"closeTime"`
	FirstID            int64   `json:"fristId"`
	LastID             int64   `json:"lastId"`
	Count              int64   `json:"count"`
}

PriceChangeStats contains statistics for the last 24 hours trade

type QueryOrderData

type QueryOrderData struct {
	Code          int     `json:"code"`
	Msg           string  `json:"msg"`
	Symbol        string  `json:"symbol"`
	OrderID       int64   `json:"orderId"`
	ClientOrderID string  `json:"clientOrderId"`
	Price         float64 `json:"price,string"`
	OrigQty       float64 `json:"origQty,string"`
	ExecutedQty   float64 `json:"executedQty,string"`
	Status        string  `json:"status"`
	TimeInForce   string  `json:"timeInForce"`
	Type          string  `json:"type"`
	Side          string  `json:"side"`
	StopPrice     float64 `json:"stopPrice,string"`
	IcebergQty    float64 `json:"icebergQty,string"`
	Time          int64   `json:"time"`
	IsWorking     bool    `json:"isWorking"`
}

QueryOrderData holds query order data

type RecentTrade

type RecentTrade struct {
	Code         int     `json:"code"`
	Msg          string  `json:"msg"`
	ID           int64   `json:"id"`
	Price        float64 `json:"price,string"`
	Quantity     float64 `json:"qty,string"`
	Time         int64   `json:"time"`
	IsBuyerMaker bool    `json:"isBuyerMaker"`
	IsBestMatch  bool    `json:"isBestMatch"`
}

RecentTrade holds recent trade data

type SymbolPrice

type SymbolPrice struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
}

SymbolPrice holds basic symbol price

Jump to

Keyboard shortcuts

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