okex

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*
	  http headers
	*/
	OK_ACCESS_KEY        = "OK-ACCESS-KEY"
	OK_ACCESS_SIGN       = "OK-ACCESS-SIGN"
	OK_ACCESS_TIMESTAMP  = "OK-ACCESS-TIMESTAMP"
	OK_ACCESS_PASSPHRASE = "OK-ACCESS-PASSPHRASE"

	/**
	  paging params
	*/
	OK_FROM  = "OK-FROM"
	OK_TO    = "OK-TO"
	OK_LIMIT = "OK-LIMIT"

	CONTENT_TYPE = "Content-Type"
	ACCEPT       = "Accept"
	COOKIE       = "Cookie"
	LOCALE       = "locale="

	APPLICATION_JSON      = "application/json"
	APPLICATION_JSON_UTF8 = "application/json; charset=UTF-8"

	/*
	  i18n: internationalization
	*/
	ENGLISH            = "en_US"
	SIMPLIFIED_CHINESE = "zh_CN"
	//zh_TW || zh_HK
	TRADITIONAL_CHINESE = "zh_HK"

	/*
	  http methods
	*/
	GET    = "GET"
	POST   = "POST"
	DELETE = "DELETE"

	/*
	 others
	*/
	ResultDataJsonString = "resultDataJsonString"
	ResultPageJsonString = "resultPageJsonString"

	BTC_USD_SWAP = "BTC-USD-SWAP"
	LTC_USD_SWAP = "LTC-USD-SWAP"
	ETH_USD_SWAP = "ETH-USD-SWAP"
	ETC_USD_SWAP = "ETC-USD-SWAP"
	BCH_USD_SWAP = "BCH-USD-SWAP"
	BSV_USD_SWAP = "BSV-USD-SWAP"
	EOS_USD_SWAP = "EOS-USD-SWAP"
	XRP_USD_SWAP = "XRP-USD-SWAP"

	/*Rest Endpoint*/
	Endpoint              = "https://www.okex.com"
	GET_ACCOUNTS          = "/api/swap/v3/accounts"
	PLACE_ORDER           = "/api/swap/v3/order"
	CANCEL_ORDER          = "/api/swap/v3/cancel_order/%s/%s"
	GET_ORDER             = "/api/swap/v3/orders/%s/%s"
	GET_POSITION          = "/api/swap/v3/%s/position"
	GET_DEPTH             = "/api/swap/v3/instruments/%s/depth?size=%d"
	GET_TICKER            = "/api/swap/v3/instruments/%s/ticker"
	GET_ALL_TICKER        = "/api/swap/v3/instruments/ticker"
	GET_UNFINISHED_ORDERS = "/api/swap/v3/orders/%s?status=%d&limit=%d"
)

Variables

This section is empty.

Functions

func NewSpotAPI

func NewSpotAPI(client *http.Client, apiKey, secretKey, apiPass string) SpotAPI

func NewSpotWebsocket

func NewSpotWebsocket(wsURL, proxyURL string) (sw SpotWebsocket, err error)

Types

type OKExSpot

type OKExSpot struct {
	HttpClient    *http.Client
	Endpoint      string
	ApiKey        string
	ApiSecretKey  string
	ApiPassphrase string //for okex.com v3 api
}

func (*OKExSpot) BatchPlaceOrders

func (ok *OKExSpot) BatchPlaceOrders(orders []Order) ([]placeOrderResponse, error)

* Must Set Client Oid

func (*OKExSpot) Cancel

func (ok *OKExSpot) Cancel(orderId string, pair CurrencyPair) (bool, error)

func (*OKExSpot) GetAccount

func (ok *OKExSpot) GetAccount() (*Account, error)

func (*OKExSpot) GetAllCurrencyPair

func (ok *OKExSpot) GetAllCurrencyPair() (map[string]SymbolSetting, error)

func (*OKExSpot) GetAllCurrencyStatus

func (ok *OKExSpot) GetAllCurrencyStatus() (all map[string]CurrencyStatus, err error)

func (*OKExSpot) GetAllTicker

func (ok *OKExSpot) GetAllTicker() ([]Ticker, error)

func (*OKExSpot) GetCurrencyStatus

func (ok *OKExSpot) GetCurrencyStatus(currency Currency) (CurrencyStatus, error)

func (*OKExSpot) GetDepth

func (ok *OKExSpot) GetDepth(pair CurrencyPair, size int, step int) (*Depth, error)

func (*OKExSpot) GetExchangeName

func (ok *OKExSpot) GetExchangeName() string

func (*OKExSpot) GetFinishedOrders

func (ok *OKExSpot) GetFinishedOrders(pair CurrencyPair) ([]Order, error)

func (*OKExSpot) GetKlineRecords

func (ok *OKExSpot) GetKlineRecords(pair CurrencyPair, period KlinePeriod, size, since int) ([]Kline, error)

func (*OKExSpot) GetOrder

func (ok *OKExSpot) GetOrder(orderId string, pair CurrencyPair) (*Order, error)

func (*OKExSpot) GetOrderDeal

func (ok *OKExSpot) GetOrderDeal(orderId string, pair CurrencyPair) ([]OrderDeal, error)

func (*OKExSpot) GetPendingOrders

func (ok *OKExSpot) GetPendingOrders(pair CurrencyPair) ([]Order, error)

func (*OKExSpot) GetTicker

func (ok *OKExSpot) GetTicker(pair CurrencyPair) (*Ticker, error)

func (*OKExSpot) GetTradeFee

func (ok *OKExSpot) GetTradeFee() (tf *TradeFee, err error)

func (*OKExSpot) GetTrades

func (ok *OKExSpot) GetTrades(pair CurrencyPair, size int) ([]Trade, error)

func (*OKExSpot) GetURL

func (ok *OKExSpot) GetURL() string

func (*OKExSpot) GetUserTrades

func (ok *OKExSpot) GetUserTrades(currencyPair CurrencyPair) ([]Trade, error)

func (*OKExSpot) LimitBuy

func (ok *OKExSpot) LimitBuy(pair CurrencyPair, price, amount string) (*Order, error)

func (*OKExSpot) LimitSell

func (ok *OKExSpot) LimitSell(pair CurrencyPair, price, amount string) (*Order, error)

func (*OKExSpot) MarketBuy

func (ok *OKExSpot) MarketBuy(pair CurrencyPair, amount string) (*Order, error)

func (*OKExSpot) MarketSell

func (ok *OKExSpot) MarketSell(pair CurrencyPair, amount string) (*Order, error)

func (*OKExSpot) SetURL

func (ok *OKExSpot) SetURL(exurl string)

type OkexSpotWs

type OkexSpotWs struct {
	SpotWsBase
}

func (*OkexSpotWs) FormatTopicName

func (ws *OkexSpotWs) FormatTopicName(topic string, pair CurrencyPair) string

格式化流名称

func (*OkexSpotWs) FormatTopicSubData

func (ws *OkexSpotWs) FormatTopicSubData(topic string, pair CurrencyPair) []byte

格式化流订阅消息

func (*OkexSpotWs) FormatTopicUnsubData

func (ws *OkexSpotWs) FormatTopicUnsubData(topic string, pair CurrencyPair) []byte

格式化流取消订阅消息

func (*OkexSpotWs) GetExchangeName

func (ws *OkexSpotWs) GetExchangeName() string

func (*OkexSpotWs) OnMessage

func (ws *OkexSpotWs) OnMessage(data []byte) (err error)

type TradeFee

type TradeFee struct {
	Maker float64 `json:"maker,string"` // 挂单手续费
	Taker float64 `json:"taker,string"` // 吃单手续费
}

"maker": "0.001", "taker": "0.0015", "timestamp": "2019-12-05T09:06:20.260Z"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL