Categorygithub.com/lemtree/goex
modulepackage
1.0.6
Repository: https://github.com/lemtree/goex.git
Documentation: pkg.go.dev

# README

GoEx

GoEx目标

GoEx项目是为了统一并标准化各个数字资产交易平台的接口而设计,同一个策略可以随时切换到任意一个交易平台,而不需要更改任何代码。

English

GoEx已支持交易所 22+

交易所行情接口交易接口版本号
hbg.comYY1
hbdm.comYY1
okex.comYY3
binance.comYY1
bitstamp.netYY1
bitfinex.comYY1
zb.comYY1
kraken.comYY*
poloniex.comYY*
aacoin.comYY1
allcoin.caYY*
big.oneYY2|3
fcoin.comYY2
hitbtc.comYY*
coinex.comYY1
exx.comYY1
bithumb.comYY*
gate.ioYN1
btcbox.co.jpYN*
coinbig.comYY*
coinbene.comYY*

安装GoEx库

go get github.com/nntaoli-project/GoEx

建议go mod 管理依赖

require (
          github.com/nntaoli-project/GoEx v1.0.4
)

例子


   package main
   
   import (
   	"github.com/nntaoli-project/GoEx"
   	"github.com/nntaoli-project/GoEx/builder"
   	"log"
   	"time"
   )
   
   func main() {
   	apiBuilder := builder.NewAPIBuilder().HttpTimeout(5 * time.Second)
   	//apiBuilder := builder.NewAPIBuilder().HttpTimeout(5 * time.Second).HttpProxy("socks5://127.0.0.1:1080")
   	
   	//build spot api
   	//api := apiBuilder.APIKey("").APISecretkey("").ClientID("123").Build(goex.BITSTAMP)
   	api := apiBuilder.APIKey("").APISecretkey("").Build(goex.HUOBI_PRO)
   	log.Println(api.GetExchangeName())
   	log.Println(api.GetTicker(goex.BTC_USD))
   	log.Println(api.GetDepth(2, goex.BTC_USD))
   	//log.Println(api.GetAccount())
   	//log.Println(api.GetUnfinishOrders(goex.BTC_USD))
   
   	//build future api
   	futureApi := apiBuilder.APIKey("").APISecretkey("").BuildFuture(goex.HBDM)
   	log.Println(futureApi.GetExchangeName())
   	log.Println(futureApi.GetFutureTicker(goex.BTC_USD, goex.QUARTER_CONTRACT))
   	log.Println(futureApi.GetFutureDepth(goex.BTC_USD, goex.QUARTER_CONTRACT, 5))
   	//log.Println(futureApi.GetFutureUserinfo()) // account
   	//log.Println(futureApi.GetFuturePosition(goex.BTC_USD , goex.QUARTER_CONTRACT))//position info
   }

websocket 使用例子

import (
	"github.com/nntaoli-project/GoEx"
	"github.com/nntaoli-project/GoEx/huobi"
	//"github.com/nntaoli-project/GoEx/okcoin"
	"log"
)

func main() {

	//ws := okcoin.NewOKExFutureWs() //ok期货
	ws := huobi.NewHbdmWs() //huobi期货
	//设置回调函数
	ws.SetCallbacks(func(ticker *goex.FutureTicker) {
		log.Println(ticker)
	}, func(depth *goex.Depth) {
		log.Println(depth)
	}, func(trade *goex.Trade, contract string) {
		log.Println(contract, trade)
	})
	//订阅行情
	ws.SubscribeTrade(goex.BTC_USDT, goex.NEXT_WEEK_CONTRACT)
	ws.SubscribeDepth(goex.BTC_USDT, goex.QUARTER_CONTRACT, 5)
	ws.SubscribeTicker(goex.BTC_USDT, goex.QUARTER_CONTRACT)
}  

更多文档

GoEx.TOP

注意事项

  1. 推荐使用GoLand开发。
  2. 推荐关闭自动格式化功能,代码请使用go fmt 格式化.
  3. 不建议对现已存在的文件进行重新格式化,这样会导致commit特别糟糕。
  4. 请用OrderID2这个字段代替OrderID
  5. 请不要使用deprecated关键字标注的方法和字段,后面版本可能随时删除的
  6. 交流QQ群:574829125

欢迎为作者付一碗面钱

一碗面钱   一碗面钱

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
* * call all unfinished future orders * @return c 成功撤单数量 */.
* * call all unfinished orders */.
No description provided by the author
n :保留的小数点位数,去除末尾多余的0(StripTrailingZeros).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
for bitfinex.com*/.
No description provided by the author
No description provided by the author
* *md5签名,okcoin和huobi适用 */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
* 本函数只适合,返回两个参数的API重试调用,其中一个参数必须是error @retry 重试次数 @delay 每次重试延迟时间间隔 @method 调用的函数,比如: api.GetTicker ,注意:不是api.GetTicker(...) @params 参数,顺序一定要按照实际调用函数入参顺序一样 @return 返回 */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
No description provided by the author
No description provided by the author
平多.
平空.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
k线周期.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
exchanges const.
开多.
开空.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
= ORDER_TYPE_FAK + iota*/.
No description provided by the author
No description provided by the author
No description provided by the author
ORDER_TYPE_POST_ONLY
No description provided by the author
No description provided by the author
exchanges const.
No description provided by the author
No description provided by the author
exchanges const.
exchanges const.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
次周合约.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
季度合约.
No description provided by the author
No description provided by the author
永续合约.
周合约.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A->B(A兑换为B).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author