This repo it's base amir-the-h/okex
NOTICE:
PACKAGE IS CURRENTLY UNDER HEAVY DEVELOPMENT AND THERE IS NO GUARANTY FOR STABILITY.
DISCLAIMER:
This package is provided as-is, without any express or implied warranties. The user assumes all risks associated with the use of this package. The author and contributors to this package shall not be held liable for any damages arising from the use of this package, including but not limited to direct, indirect, incidental, or consequential damages. This package is not intended to be used as a substitute for professional financial advice. Users are responsible for verifying the accuracy and reliability of the data generated by this package. Use of this package constitutes acceptance of these terms and conditions.
Okex V5 Golang API
import (
"fmt"
"github.com/james-zhang-bing/okapi"
"github.com/james-zhang-bing/okapi/api/rest"
pr "github.com/james-zhang-bing/okapi/api/websocket/private"
"github.com/james-zhang-bing/okapi/api/websocket/public"
"github.com/james-zhang-bing/okapi/requests/rest/market"
"github.com/james-zhang-bing/okapi/requests/ws/private"
)
func main() {
apikey := rest.NewAPIKey("your_key", "your_secret", "your_passphrase ")
//for rest api
restClient := rest.NewClient(apikey, okapi.AwsRestURL, okapi.AwsServer)
res, err := restClient.Market.GetCandlesticks(market.GetCandlesticks{InstID: "BTC-USDT"})
if err != nil {
panic(err)
}
fmt.Println(res.Candles[0])
//for websocket public channel
pubws, err := public.NewPublicClient(okapi.AwsPublicWsURL)
if err != nil {
panic(err)
}
candleSub := public.NewCandleChannel(string(okapi.Bar1m), "BTC-USDT-SWAP")
err = pubws.Subscribe(candleSub)
if err != nil {
panic(err)
}
for i := 0; i < 2; i++ {
candle := <-candleSub.Received
fmt.Println(candle)
}
//for websocket private channel
priws, err := pr.NewPrivateClient(okapi.AwsPrivateWsURL, apikey)
if err != nil {
panic(err)
}
balanceCh, err := priws.SubscribeAccountChannel(&private.Account{})
if err != nil {
panic(err)
}
fmt.Println(<-balanceCh)
}