项目作者: btstar

项目描述 :
golang wrapper for binance-api
高级语言: Go
项目地址: git://github.com/btstar/binance-go-api.git
创建时间: 2017-10-10T01:36:39Z
项目社区:https://github.com/btstar/binance-go-api

开源协议:

下载


Golang Binance API

golang wrapper for latest Binance API

Support latest api

API function REST API Websocket API Description
GetTicker Yes No Getting latest price of a symbol
GetTickers Yes No Getting best price/qty on the order book for all symbols
GetDepth Yes No Getting depth of a symbol or maintain a depth cache locally
LimitBuy Yes No Placing a LIMIT buy order
LimitSell Yes No Placing a LIMIT sell order
MarketBuy Yes No Placing a MARKET buy order
MarketSell Yes No Placing a MARKET sell order
GetOneOrder Yes No Checking an order’s status
CancelOrder Yes No Cancelling an order
GetUnfinishOrders Yes No Getting list of open orders
GetAccount Yes No Getting list of current position

Pre-condition

  • Install golang
  • Install binance-api library,
    1. go get github.com/BtStar/binance-go-api

Example

  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "github.com/BtStar/binance-go-api"
  6. "github.com/BtStar/binance-go-api/Utils"
  7. )
  8. func main() {
  9. //accessKey,secretKey can apply in binance website, it's necessary.
  10. accessKey := "your access key"
  11. secretKey := "your secret key"
  12. //New Binance API
  13. BN := binance.New(http.DefaultClient, accessKey, secretKey)
  14. //Getting list of current position
  15. account, err := BN.GetAccount()
  16. if err != nil {
  17. log.Fatal(err)
  18. }
  19. log.Printf("Total Asset :%.4f, Net Asset:%.4f", account.Asset, account.NetAsset)
  20. log.Printf("[BTC Asset] Avaliable:%.4f,Frozen:%.4f", account.SubAccounts[BTC].Amount, account.SubAccounts[BTC].ForzenAmount)
  21. log.Printf("[LTC Asset] Avaliable:%.4f,Frozen:%.4f", account.SubAccounts[LTC].Amount, account.SubAccounts[LTC].ForzenAmount)
  22. log.Printf("[USDT Asset] Avaliable:%.4f,Frozen:%.4f", account.SubAccounts[USDT].Amount, account.SubAccounts[USDT].ForzenAmount)
  23. }