BinanceAPI

package
v0.0.0-...-d060b71 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2018 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	API_BASE_URL = "https://api.binance.com/"
	API_V1       = API_BASE_URL + "api/v1/"
	API_V3       = API_BASE_URL + "api/v3/"

	TICKER_URI             = "ticker/24hr?symbol=%s"
	TICKERS_URI            = "ticker/allBookTickers"
	DEPTH_URI              = "depth?symbol=%s&limit=%d"
	ACCOUNT_URI            = "account?"
	ORDER_URI              = "order?"
	UNFINISHED_ORDERS_INFO = "openOrders?"
)
View Source
const (
	BUY = 1 + iota
	SELL
	BUY_MARKET
	SELL_MARKET
)
View Source
const (
	ORDER_UNFINISH = iota
	ORDER_PART_FINISH
	ORDER_FINISH
	ORDER_CANCEL
	ORDER_REJECT
	ORDER_CANCEL_ING
)
View Source
const (
	OPEN_BUY   = 1 + iota //开多
	OPEN_SELL             //开空
	CLOSE_BUY             //平多
	CLOSE_SELL            //平空
)
View Source
const (
	KLINE_PERIOD_1MIN = 1 + iota
	KLINE_PERIOD_5MIN
	KLINE_PERIOD_15MIN
	KLINE_PERIOD_30MIN
	KLINE_PERIOD_60MIN
	KLINE_PERIOD_4H
	KLINE_PERIOD_1DAY
	KLINE_PERIOD_1WEEK
	KLINE_PERIOD_1MONTH
	KLINE_PERIOD_1YEAR
)

k线周期

View Source
const (
	OKCOIN_CN   = "okcoin.cn"
	OKCOIN_COM  = "okcoin.com"
	OKEX        = "okex.com"
	OKEX_FUTURE = "okex.com"
	HUOBI       = "huobi.com"
	HUOBI_PRO   = "huobi.pro"
	BITSTAMP    = "bitstamp.net"
	KRAKEN      = "kraken.com"
	ZB          = "zb.com"
	BITFINEX    = "bitfinex.com"
	BINANCE     = "binance.com"
	POLONIEX    = "poloniex.com"
	COINEX      = "coinex.com"
	BITHUMB     = "bithumb.com"
	GATEIO      = "gate.io"
	BITTREX     = "bittrex.com"
	GDAX        = "gdax.com"
	WEX_NZ      = "wex.nz"
)

exchanges const

Variables

View Source
var (
	ACCESS_KEY string = ""
	SECRET_KEY string = ""
)
View Source
var (
	THIS_WEEK_CONTRACT = "this_week" //周合约
	NEXT_WEEK_CONTRACT = "next_week" //次周合约
	QUARTER_CONTRACT   = "quarter"   //季度合约
)
View Source
var (
	UNKNOWN = Currency{"UNKNOWN", ""}
	CNY     = Currency{"CNY", "rmb (China Yuan)"}
	USD     = Currency{"USD", "USA dollar"}
	USDT    = Currency{"USDT", "http://tether.io"}
	EUR     = Currency{"EUR", ""}
	KRW     = Currency{"KRW", ""}
	JPY     = Currency{"JPY", "japanese yen"}
	BTC     = Currency{"BTC", "bitcoin.org"}
	XBT     = Currency{"XBT", "bitcoin.org"}
	BCC     = Currency{"BCC", "bitcoin-abc"}
	BCH     = Currency{"BCH", "bitcoin-abc"}
	BCX     = Currency{"BCX", ""}
	LTC     = Currency{"LTC", "litecoin.org"}
	ETH     = Currency{"ETH", ""}
	ETC     = Currency{"ETC", ""}
	EOS     = Currency{"EOS", ""}
	BTS     = Currency{"BTS", ""}
	QTUM    = Currency{"QTUM", ""}
	SC      = Currency{"SC", "sia.tech"}
	ANS     = Currency{"ANS", "www.antshares.org"}
	ZEC     = Currency{"ZEC", ""}
	DCR     = Currency{"DCR", ""}
	XRP     = Currency{"XRP", ""}
	BTG     = Currency{"BTG", ""}
	BCD     = Currency{"BCD", ""}
	NEO     = Currency{"NEO", "neo.org"}
	HSR     = Currency{"HSR", ""}

	BTC_CNY  = CurrencyPair{BTC, CNY}
	LTC_CNY  = CurrencyPair{LTC, CNY}
	BCC_CNY  = CurrencyPair{BCC, CNY}
	ETH_CNY  = CurrencyPair{ETH, CNY}
	ETC_CNY  = CurrencyPair{ETC, CNY}
	EOS_CNY  = CurrencyPair{EOS, CNY}
	BTS_CNY  = CurrencyPair{BTS, CNY}
	QTUM_CNY = CurrencyPair{QTUM, CNY}
	SC_CNY   = CurrencyPair{SC, CNY}
	ANS_CNY  = CurrencyPair{ANS, CNY}
	ZEC_CNY  = CurrencyPair{ZEC, CNY}

	BTC_KRW = CurrencyPair{BTC, KRW}
	ETH_KRW = CurrencyPair{ETH, KRW}
	ETC_KRW = CurrencyPair{ETC, KRW}
	LTC_KRW = CurrencyPair{LTC, KRW}
	BCH_KRW = CurrencyPair{BCH, KRW}

	BTC_USD = CurrencyPair{BTC, USD}
	LTC_USD = CurrencyPair{LTC, USD}
	ETH_USD = CurrencyPair{ETH, USD}
	ETC_USD = CurrencyPair{ETC, USD}
	BCH_USD = CurrencyPair{BCH, USD}
	BCC_USD = CurrencyPair{BCC, USD}
	XRP_USD = CurrencyPair{XRP, USD}
	BCD_USD = CurrencyPair{BCD, USD}

	BTC_USDT = CurrencyPair{BTC, USDT}
	LTC_USDT = CurrencyPair{LTC, USDT}
	BCH_USDT = CurrencyPair{BCH, USDT}
	BCC_USDT = CurrencyPair{BCC, USDT}
	ETC_USDT = CurrencyPair{ETC, USDT}
	ETH_USDT = CurrencyPair{ETH, USDT}
	BCD_USDT = CurrencyPair{BCD, USDT}
	NEO_USDT = CurrencyPair{NEO, USDT}
	EOS_USDT = CurrencyPair{EOS, USDT}
	XRP_USDT = CurrencyPair{XRP, USDT}
	HSR_USDT = CurrencyPair{HSR, USDT}

	XRP_EUR = CurrencyPair{XRP, EUR}

	BTC_JPY = CurrencyPair{BTC, JPY}
	LTC_JPY = CurrencyPair{LTC, JPY}
	ETH_JPY = CurrencyPair{ETH, JPY}
	ETC_JPY = CurrencyPair{ETC, JPY}
	BCH_JPY = CurrencyPair{BCH, JPY}

	LTC_BTC = CurrencyPair{LTC, BTC}
	ETH_BTC = CurrencyPair{ETH, BTC}
	ETC_BTC = CurrencyPair{ETC, BTC}
	BCC_BTC = CurrencyPair{BCC, BTC}
	BCH_BTC = CurrencyPair{BCH, BTC}
	DCR_BTC = CurrencyPair{DCR, BTC}
	XRP_BTC = CurrencyPair{XRP, BTC}
	BTG_BTC = CurrencyPair{BTG, BTC}
	BCD_BTC = CurrencyPair{BCD, BTC}
	NEO_BTC = CurrencyPair{NEO, BTC}
	EOS_BTC = CurrencyPair{EOS, BTC}
	HSR_BTC = CurrencyPair{HSR, BTC}

	ETC_ETH = CurrencyPair{ETC, ETH}
	EOS_ETH = CurrencyPair{EOS, ETH}
	ZEC_ETH = CurrencyPair{ZEC, ETH}
	NEO_ETH = CurrencyPair{NEO, ETH}
	HSR_ETH = CurrencyPair{HSR, ETH}

	UNKNOWN_PAIR = CurrencyPair{UNKNOWN, UNKNOWN}
)

Functions

func CancelOrder

func CancelOrder(orderId string, symbol string) (bool, error)

func GetAccount

func GetAccount() (map[string]interface{}, error)

func GetDepth

func GetDepth(size int, symbol string) (map[string]interface{}, error)

func GetOneOrder

func GetOneOrder(orderId string, symbol string) (map[string]interface{}, error)

func GetParamHmacMD5Sign

func GetParamHmacMD5Sign(secret, params string) (string, error)

func GetParamHmacSHA1Sign

func GetParamHmacSHA1Sign(secret, params string) (string, error)

func GetParamHmacSHA256Base64Sign

func GetParamHmacSHA256Base64Sign(secret, params string) (string, error)

func GetParamHmacSHA256Sign

func GetParamHmacSHA256Sign(secret, params string) (string, error)

func GetParamHmacSHA512Base64Sign

func GetParamHmacSHA512Base64Sign(hmac_key string, hmac_data string) string

func GetParamHmacSHA512Sign

func GetParamHmacSHA512Sign(secret, params string) (string, error)

func GetParamHmacSha384Sign

func GetParamHmacSha384Sign(secret, params string) (string, error)

for bitfinex.com

func GetParamMD5Sign

func GetParamMD5Sign(secret, params string) (string, error)

*

*md5签名,okcoin和huobi适用

func GetSHA

func GetSHA(text string) (string, error)

func GetUnfinishOrders

func GetUnfinishOrders(symbol string) ([]interface{}, error)

func HttpDeleteForm

func HttpDeleteForm(client *http.Client, reqUrl string, postData url.Values, headers map[string]string) ([]byte, error)

func HttpGet

func HttpGet(client *http.Client, reqUrl string) (map[string]interface{}, error)

func HttpGet2

func HttpGet2(client *http.Client, reqUrl string, headers map[string]string) (map[string]interface{}, error)

func HttpGet3

func HttpGet3(client *http.Client, reqUrl string, headers map[string]string) ([]interface{}, error)

func HttpPostForm

func HttpPostForm(client *http.Client, reqUrl string, postData url.Values) ([]byte, error)

func HttpPostForm2

func HttpPostForm2(client *http.Client, reqUrl string, postData url.Values, headers map[string]string) ([]byte, error)

func HttpPostForm3

func HttpPostForm3(client *http.Client, reqUrl string, postData string, headers map[string]string) ([]byte, error)

func LimitBuy

func LimitBuy(amount, price string, symbol string) (map[string]interface{}, error)

func LimitSell

func LimitSell(amount, price string, symbol string) (map[string]interface{}, error)

func MarketBuy

func MarketBuy(amount, price string, symbol string) (map[string]interface{}, error)

func MarketSell

func MarketSell(amount, price string, symbol string) (map[string]interface{}, error)

func NewHttpRequest

func NewHttpRequest(client *http.Client, reqType string, reqUrl string, postData string, requstHeaders map[string]string) ([]byte, error)

func ToFloat64

func ToFloat64(v interface{}) float64

func ToInt

func ToInt(v interface{}) int

func ToUint64

func ToUint64(v interface{}) uint64

Types

type Currency

type Currency struct {
	Symbol string
	Desc   string
}

func NewCurrency

func NewCurrency(symbol, desc string) Currency

func (Currency) String

func (c Currency) String() string

type CurrencyPair

type CurrencyPair struct {
	CurrencyA Currency
	CurrencyB Currency
}

A->B(A兑换为B)

func NewCurrencyPair

func NewCurrencyPair(currencyA Currency, currencyB Currency) CurrencyPair

func NewCurrencyPair2

func NewCurrencyPair2(currencyPairSymbol string) CurrencyPair

func (CurrencyPair) String

func (c CurrencyPair) String() string

func (CurrencyPair) ToSymbol

func (pair CurrencyPair) ToSymbol(joinChar string) string

func (CurrencyPair) ToSymbol2

func (pair CurrencyPair) ToSymbol2(joinChar string) string

type TradeSide

type TradeSide int

func (TradeSide) String

func (ts TradeSide) String() string

type TradeStatus

type TradeStatus int

func (TradeStatus) String

func (ts TradeStatus) String() string

Jump to

Keyboard shortcuts

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