Categorygithub.com/frankrap/okex-api
modulepackage
1.0.4
Repository: https://github.com/frankrap/okex-api.git
Documentation: pkg.go.dev

# README

okex-api

OKEx Open API V3 SDK (Golang Version)


1.Downloads or updates OKEX code's dependencies, in your command line:

go get -u github.com/frankrap/okex-api

2.Write the go file. warm tips: test go file, must suffix *_test.go, eg: okex_open_api_v3_test.go

package gotest

import (
	"fmt"
	"github.com/frankrap/okex-api"
	"testing"
)

func TestOKExServerTime(t *testing.T) {
	serverTime, err := okex.NewOKExClient().GetServerTime()
	if err != nil {
		t.Error(err)
	}
	fmt.Println("OKEx's server time: ", serverTime)
}

func NewOKExClient() *okex.Client {
	var config okex.Config
	config.Endpoint = "https://www.okex.com/"
	config.ApiKey = ""
	config.SecretKey = ""
	config.Passphrase = ""
	config.TimeoutSecond = 45
	config.IsPrint = true
	config.I18n = okex.ENGLISH

	client := okex.NewClient(config)
	return client
}

3. run test go:

go test -v -run TestOKExServerTime okex_open_api_v3_test.go

# Functions

Get api v1 requestPath + requestParams params := okex.NewParams() params["symbol"] = "btc_usd" params["contract_type"] = "this_week" params["status"] = "1" requestPath := "/api/v1/future_explosive.do" return eg: /api/v1/future_explosive.do?api_key=88af5759-61f2-47e9-b2e9-17ce3a390488&contract_type=this_week&status=1&symbol=btc_usd&sign=966ACD0DE5F729BC9C9C03D92ABBEB68 */.
build http get request params, and order eg: params := make(map[string]string) params["bb"] = "222" params["aa"] = "111" params["cc"] = "333" return string: eg: aa=111&bb=222&cc=333 */.
Get api requestPath + requestParams params := NewParams() params["depth"] = "200" params["conflated"] = "0" url := BuildParams("/api/futures/v3/products/BTC-USD-0310/book", params) return eg:/api/futures/v3/products/BTC-USD-0310/book?conflated=0&depth=200 */.
Get a epoch time eg: 1521221737.376 */.
No description provided by the author
call fmt.Println(...) */.
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
Set http request headers: Accept: application/json Content-Type: application/json; charset=UTF-8 (default) Cookie: locale=en_US (English) OK-ACCESS-KEY: (Your setting) OK-ACCESS-SIGN: (Use your setting, auto sign and add) OK-ACCESS-TIMESTAMP: (Auto add) OK-ACCESS-PASSPHRASE: Your setting */.
signing a message using: hmac sha256 + base64 eg: message = Pre_hash function comment secretKey = E65791902180E9EF4510DB6A77F6EBAE return signed string = TO6uwdqz+31SIPkd4I+9NiZGmVH74dXi+Fd5X0EzzSQ= */.
int convert string */.
int64 convert string */.
return decimalism string 9223372036854775807 -> "9223372036854775807" */.
No description provided by the author
Get a iso time eg: 2018-03-16T18:02:48.284Z */.
iso time change to time.Time eg: "2018-11-18T16:51:55.933Z" -> 2018-11-18 16:51:55.000000933 +0000 UTC */.
json byte array convert struct */.
json string convert struct */.
Get utc +8 -- 1540365300000 -> 2018-10-24 15:15:00 +0800 CST */.
1540365300000 -> 2018-10-24 15:15:00 */.
md5 sign */.
Get a http client */.
No description provided by the author
NewFuturesWS 创建合约WS wsURL: wss://real.okex.com:8443/ws/v3.
Get a new map.eg: {string:string} */.
NewSwapWS 创建永续合约WS wsURL: wss://real.okex.com:8443/ws/v3.
No description provided by the author
No description provided by the author
"socks5://127.0.0.1:1080".
Get a http request body is a json string and a byte array.
the pre hash string eg: timestamp = 2018-03-08T10:59:25.789Z method = POST request_path = /orders?before=2&limit=30 body = {"product_id":"BTC-USD-0309","order_id":"377454671037440"} return pre hash string = 2018-03-08T10:59:25.789ZPOST/orders?before=2&limit=30{"product_id":"BTC-USD-0309","order_id":"377454671037440"} */.
No description provided by the author
No description provided by the author
struct convert json string */.
ternary operator replace language: a == b ? c : d */.
ternary operator biz extension */.

# Constants

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
currencies */.
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
candles bin size */.
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
margin mode */.
No description provided by the author
i18n: internationalization */.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FUTURES_ACCOUNT_CURRENCY_INFO = "/api/futures/v3/accounts/{currency}".
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
http methods */.
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
http headers */.
No description provided by the author
No description provided by the author
No description provided by the author
* paging params */.
No description provided by the author
No description provided by the author
No description provided by the author
transaction type */.
No description provided by the author
POST
No description provided by the author
others */.
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
用户账户频道.
公共-400档增量数据频道.
用户交易频道.
用户持仓频道.
公共-Ticker频道.
公共-交易频道.
用户账户频道.
公共-400档增量数据频道.
用户交易频道.
用户持仓频道.
公共-Ticker频道.
公共-交易频道.
zh_TW || zh_HK.
No description provided by the author

# Variables

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
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
OKEX uses cursor pagination for all REST requests which return arrays */.
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
OrdersData: Batch create new orders json string.(Max of 5 orders are allowed per request)) */.
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
Create a new order ClientOid: You setting order id.(optional) Type: The execution type @see file: futures_constants.go InstrumentId: The id of the futures, eg: BTC_USD_0331 Price: The order price: Maximum 1 million Amount: The order amount: Maximum 1 million MatchPrice: Match best counter party price (BBO)? 0: No 1: Yes If yes, the 'price' field is ignored LeverRate: lever, default 10.
No description provided by the author
Order status: 0: waiting for transaction 1: 1: part of the deal 2: all transactions 3: cancelling 4: canceled.
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
If OrderId = -1, ErrorCode > 0, error order */.
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
price String 价格 size String 数量 num_orders String 组成此条深度的订单数量.
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

# 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
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