Giter Site home page Giter Site logo

gamert / goex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nntaoli-project/goex

0.0 1.0 0.0 998 KB

Exchange Rest And WebSocket API For Golang Wrapper support okcoin,okex,huobipro,hbdm,coinex,poloniex,bitfinex,bitstamp,binance,kraken,bithumb,zb,hitbtc,fcoin

License: MIT License

Go 100.00%

goex's Introduction

GoEx目标

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

GoEx已支持交易所 22+

交易所 行情接口 交易接口 版本号
hbg.com Y Y 1
hbdm.com Y Y 1
okex.com (spot/future) Y (REST / WS) Y 1
okex.com (swap future) Y Y 2
binance.com Y Y 1
bitstamp.net Y Y 1
bitfinex.com Y Y 1
zb.com Y Y 1
kraken.com Y Y *
poloniex.com Y Y *
aacoin.com Y Y 1
allcoin.ca Y Y *
big.one Y Y 2|3
fcoin.com Y Y 2
hitbtc.com Y Y *
coinex.com Y Y 1
exx.com Y Y 1
bithumb.com Y Y *
gate.io Y N 1
btcbox.co.jp Y N *
bittrex.com Y N 1.1
btcchina.com Y Y 1
coinbig.com Y Y *

###安装GoEx库 go get github.com/nntaoli-project/GoEx

例子

   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)
}  

注意事项

  1. 推荐使用GoLand开发。
  2. 推荐关闭自动格式化功能。
  3. 不建议对现已存在的文件进行重新格式化,这样会导致commit特别糟糕。
  4. 请用OrderID2这个字段代替OrderID
  5. 交流QQ群:574829125

欢迎为作者付一碗面钱

一碗面钱   一碗面钱

goex's People

Contributors

nntaoli avatar beaquant avatar burdenbear avatar locxiang avatar memclutter avatar nlat31 avatar theblueresearcher avatar oudingfan avatar evzpav avatar aleksandrshepelev avatar f0cii avatar hxzqlh avatar mistyworm avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.