golang sdk for https://www.okx.com/docs-v5
go get:
go get github.com/huangapple/go-okx
all examples are in the folder examples
package main
import (
"log"
"github.com/huangapple/go-okx/rest"
"github.com/huangapple/go-okx/common"
"github.com/huangapple/go-okx/rest/api/account"
)
func main() {
auth := common.NewAuth("your apikey", "your key", "your passphrase", false)
client := rest.New("", auth, nil)
param := &account.GetBalanceParam{}
req, resp := account.NewGetBalance(param)
if err := client.Do2(req, resp); err != nil {
panic(err)
}
log.Println(req, resp.(*account.GetBalanceResponse))
}
package main
import (
"log"
"github.com/huangapple/go-okx/ws/public"
)
func main() {
handler := func(c interface{}) {
log.Println(c)
}
handlerError := func(err error) {
panic(err)
}
if _, err := public.SubscribeTickers("BTC-USDT", handler, handlerError, false); err != nil {
panic(err)
}
select {}
}
package main
import (
"log"
"github.com/huangapple/go-okx/common"
"github.com/huangapple/go-okx/ws"
"github.com/huangapple/go-okx/ws/private"
)
func main() {
auth := common.NewAuth("your apikey", "your key", "your passphrase", false)
args := &ws.Args{
InstType: "SPOT",
}
handler := func(c private.EventOrders) {
log.Println(c)
}
handlerError := func(err error) {
panic(err)
}
if err := private.SubscribeOrders(args, auth, handler, handlerError); err != nil {
panic(err)
}
select {}
}
缺失的接口会慢慢完善(完善的进度看Star)。有部分接口只是调通了,没有真实数据测试(穷)。有问题欢迎Issues!!!