okex

package
v0.0.0-...-2fde92b Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: MIT Imports: 14 Imported by: 0

README

#使用特定交易所的API可以获取更多的接口实现

var okex = NewOKEx(&goex.APIConfig{
                    	Endpoint: "https://www.okex.com",
                    	//HttpClient: &http.Client{
                    	//	Transport: &http.Transport{
                    	//		Proxy: func(req *http.Request) (*url.URL, error) {
                    	//			return &url.URL{
                    	//				Scheme: "socks5",
                    	//				Host:   "127.0.0.1:1080"}, nil
                    	//		},
                    	//	},
                    	//},
                    	ApiKey:        "",
                    	ApiSecretKey:  "",
                    	ApiPassphrase: "",
                    })
 var (
   okexSpot = okex.OKExSpot
   okexSwap = okex.OKExSwap   //永续合约实现
   okexFuture=okex.OKExFuture //交割合约实现
   okexWallet =okex.OKExWallet //资金账户(钱包)操作
   )
 
  //接口调用,更多接口调用请看代码
  log.Println(okexSpot.GetAccount()) //获取账户资产信息
  //okexSpot.BatchPlaceOrders([]goex.Order{...}) //批量下单,单个交易对同时最大只能下10笔
  log.Println(okexSwap.GetFutureUserinfo()) //获取账户权益信息
  log.Println(okexFuture.GetFutureUserinfo())//获取账户权益信息
  

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"
	PLACE_ALGO_ORDER      = "/api/swap/v3/order_algo"
	CANCEL_ALGO_ORDER     = "/api/swap/v3/cancel_algos"
	GET_ALGO_ORDER        = "/api/swap/v3/order_algo/%s?order_type=%d&"
)
View Source
const (
	WITHDRAWAL_OKCOIN int = 2 //提币到okcoin国际站
	WITHDRAWAL_OKEx       = 3 //提币到okex,站内提币
	WITHDRAWAL_COIN       = 4 //提币到数字货币地址,跨平台提币或者提到自己钱包
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllFutureContractInfo

type AllFutureContractInfo struct {
	// contains filtered or unexported fields
}

type BaesDepthInfo

type BaesDepthInfo []interface{}

type BaseCandleInfo

type BaseCandleInfo []interface{}

type BaseFillInfo

type BaseFillInfo struct {
	InstrumentId string `json:"instrument_id"`
	OrderQty     string `json:"order_qty"`
	TradeId      string `json:"trade_id"`
	Fee          string `json:"fee"`
	OrderId      string `json:"order_id"`
	Timestamp    string `json:"timestamp"`
	Price        string `json:"price"`
	Side         string `json:"side"`
	ExecType     string `json:"exec_type"`
}

type BaseHistoricalFundingRate

type BaseHistoricalFundingRate struct {
	InstrumentId string `json:"instrument_id"`
	InterestRate string `json:"interest_rate"`
	FundingRate  string `json:"funding_rate"`
	FundingTime  string `json:"funding_time"`
	RealizedRate string `json:"realized_rate"`
}

type BaseInstrumentAmount

type BaseInstrumentAmount struct {
	BizWarmTips
	InstrumentId string `json:"instrument_id"`
	Timestamp    string `json:"timestamp"`
	Amount       string `json:"amount"`
}

type BaseInstrumentInfo

type BaseInstrumentInfo struct {
	InstrumentId    string `json:"instrument_id"`
	QuoteCurrency   string `json:"quote_currency"`
	TickSize        string `json:"tick_size"`
	ContractVal     string `json:"contract_val"`
	Listing         string `json:"listing"`
	UnderlyingIndex string `json:"underlying_index"`
	Delivery        string `json:"delivery"`
	Coin            string `json:"coin"`
	SizeIncrement   string `json:"size_increment"`
}

type BaseLedgerInfo

type BaseLedgerInfo struct {
	InstrumentId string `json:"instrument_id"`
	Fee          string `json:"fee"`
	Timestamp    string `json:"timestamp"`
	Amount       string `json:"amount"`
	LedgerId     string `json:"ledger_id"`
	Type         string `json:"type"`
}

type BaseLiquidationInfo

type BaseLiquidationInfo struct {
	InstrumentId string `json:"instrument_id"`
	Loss         string `json:"loss"`
	CreatedAt    string `json:"created_at"`
	Type         string `json:"type"`
	Price        string `json:"price"`
	Size         string `json:"size"`
}

type BaseOrderInfo

type BaseOrderInfo struct {
	InstrumentId string  `json:"instrument_id"`
	Status       int     `json:"status,string"`
	OrderId      string  `json:"order_id"`
	ClientOid    string  `json:"client_oid"`
	Timestamp    string  `json:"timestamp"`
	Price        float64 `json:"price,string"`
	PriceAvg     float64 `json:"price_avg,string"`
	Size         float64 `json:"size,string"`
	Fee          float64 `json:"fee,string"`
	FilledQty    float64 `json:"filled_qty,string"`
	ContractVal  string  `json:"contract_val"`
	Type         int     `json:"type,string"`
}

type BasePlaceOrderInfo

type BasePlaceOrderInfo struct {
	ClientOid  string `json:"client_oid"`
	Price      string `json:"price"`
	MatchPrice string `json:"match_price"`
	Type       string `json:"type"`
	Size       string `json:"size"`
	OrderType  string `json:"order_type"`
}

type BaseResponse

type BaseResponse struct {
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
	Result       bool   `json:"result,string"`
}

type BaseSwapOrderResult

type BaseSwapOrderResult struct {
	OrderId      string `json:"order_id"`
	ClientOid    string `json:"client_oid"`
	ErrorMessage string `json:"error_message"`
	ErrorCode    string `json:"error_code"`
	Result       string `json:"result"`
}

type BaseTickerInfo

type BaseTickerInfo struct {
	InstrumentId string  `json:"instrument_id"`
	Last         float64 `json:"last,string"`
	Timestamp    string  `json:"timestamp"`
	High24h      float64 `json:"high_24h,string"`
	Volume24h    float64 `json:"volume_24h,string"`
	Low24h       float64 `json:"low_24h,string"`
	BestBid      float64 `json:"best_bid,string"`
	BestAsk      float64 `json:"best_ask,string"`
}

type BaseTradeInfo

type BaseTradeInfo struct {
	Timestamp string `json:"timestamp"`
	TradeId   string `json:"trade_id"`
	Side      string `json:"side"`
	Price     string `json:"price"`
	Size      string `json:"size"`
}

type BizWarmTips

type BizWarmTips struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type CrossedAccountInfo

type CrossedAccountInfo struct {
	MarginMode       string  `json:"margin_mode"`
	Equity           float64 `json:"equity,string"`
	RealizedPnl      float64 `json:"realized_pnl,string"`
	UnrealizedPnl    float64 `json:"unrealized_pnl,string"`
	MarginFrozen     float64 `json:"margin_frozen,string"`
	MarginRatio      float64 `json:"margin_ratio,string"`
	MaintMarginRatio float64 `json:"maint_margin_ratio,string"`
}

type DepositAddress

type DepositAddress struct {
	Address     string `json:"address"`
	Tag         string `json:"tag"`
	PaymentId   string `json:"payment_id"`
	Currency    string `json:"currency"`
	CanDeposit  int    `json:"can_deposit"`
	CanWithdraw int    `json:"can_withdraw"`
	Memo        string `json:"memo"` //eos need
}

type FutureContractInfo

type FutureContractInfo struct {
	InstrumentID    string  `json:"instrument_id"` //合约ID:如BTC-USD-180213
	UnderlyingIndex string  `json:"underlying_index"`
	QuoteCurrency   string  `json:"quote_currency"`
	TickSize        float64 `json:"tick_size,string"` //下单价格精度
	TradeIncrement  string  `json:"trade_increment"`  //数量精度
	ContractVal     string  `json:"contract_val"`     //合约面值(美元)
	Listing         string  `json:"listing"`
	Delivery        string  `json:"delivery"` //交割日期
	Alias           string  `json:"alias"`    //	本周 this_week 次周 next_week 季度 quarter
}

合约信息

type Instrument

type Instrument struct {
	InstrumentID        string    `json:"instrument_id"`
	UnderlyingIndex     string    `json:"underlying_index"`
	QuoteCurrency       string    `json:"quote_currency"`
	Coin                string    `json:"coin"`
	ContractVal         float64   `json:"contract_val,string"`
	Listing             time.Time `json:"listing"`
	Delivery            time.Time `json:"delivery"`
	SizeIncrement       int       `json:"size_increment,string"`
	TickSize            float64   `json:"tick_size,string"`
	BaseCurrency        string    `json:"base_currency"`
	Underlying          string    `json:"underlying"`
	SettlementCurrency  string    `json:"settlement_currency"`
	IsInverse           bool      `json:"is_inverse,string"`
	ContractValCurrency string    `json:"contract_val_currency"`
}

type MarginLeverage

type MarginLeverage struct {
	LongLeverage  float64 `json:"long_leverage,string"`
	MarginMode    string  `json:"margin_mode"`
	ShortLeverage float64 `json:"short_leverage,string"`
	InstrumentId  string  `json:"instrument_id"`
}

type OKEx

type OKEx struct {
	OKExSpot        *OKExSpot
	OKExFuture      *OKExFuture
	OKExSwap        *OKExSwap
	OKExWallet      *OKExWallet
	OKExMargin      *OKExMargin
	OKExV3FuturesWs *OKExV3FuturesWs
	OKExV3SpotWs    *OKExV3SpotWs
	OKExV3SwapWs    *OKExV3SwapWs
	// contains filtered or unexported fields
}

func NewOKEx

func NewOKEx(config *APIConfig) *OKEx

func (*OKEx) BuildRequestBody

func (ok *OKEx) BuildRequestBody(params interface{}) (string, *bytes.Reader, error)

Get a http request body is a json string and a byte array.

func (*OKEx) CancelOrder

func (ok *OKEx) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

func (*OKEx) DoRequest

func (ok *OKEx) DoRequest(httpMethod, uri, reqBody string, response interface{}) error

func (*OKEx) GetAccount

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

func (*OKEx) GetDepth

func (ok *OKEx) GetDepth(size int, currency CurrencyPair) (*Depth, error)

func (*OKEx) GetExchangeName

func (ok *OKEx) GetExchangeName() string

func (*OKEx) GetKlineRecords

func (ok *OKEx) GetKlineRecords(currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error)

func (*OKEx) GetOneOrder

func (ok *OKEx) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

func (*OKEx) GetOrderHistorys

func (ok *OKEx) GetOrderHistorys(currency CurrencyPair, opt ...OptionalParameter) ([]Order, error)

func (*OKEx) GetTicker

func (ok *OKEx) GetTicker(currency CurrencyPair) (*Ticker, error)

func (*OKEx) GetTrades

func (ok *OKEx) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*OKEx) GetUnfinishOrders

func (ok *OKEx) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*OKEx) IsoTime

func (ok *OKEx) IsoTime() string

Get a iso time

eg: 2018-03-16T18:02:48.284Z

func (*OKEx) LimitBuy

func (ok *OKEx) LimitBuy(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*OKEx) LimitSell

func (ok *OKEx) LimitSell(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*OKEx) MarketBuy

func (ok *OKEx) MarketBuy(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKEx) MarketSell

func (ok *OKEx) MarketSell(amount, price string, currency CurrencyPair) (*Order, error)

func (*OKEx) UUID

func (ok *OKEx) UUID() string

type OKExFuture

type OKExFuture struct {
	*OKEx
	sync.Locker
	// contains filtered or unexported fields
}

func (*OKExFuture) FutureCancelOrder

func (ok *OKExFuture) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*OKExFuture) GetAccounts

func (ok *OKExFuture) GetAccounts(currencyPair CurrencyPair) (*FutureAccount, error)

func (*OKExFuture) GetAllFutureContractInfo

func (ok *OKExFuture) GetAllFutureContractInfo() ([]FutureContractInfo, error)

func (*OKExFuture) GetContractInfo

func (ok *OKExFuture) GetContractInfo(contractId string) (*FutureContractInfo, error)

func (*OKExFuture) GetContractValue

func (ok *OKExFuture) GetContractValue(currencyPair CurrencyPair) (float64, error)

func (*OKExFuture) GetDeliveryTime

func (ok *OKExFuture) GetDeliveryTime() (int, int, int, int)

func (*OKExFuture) GetExchangeName

func (ok *OKExFuture) GetExchangeName() string

func (*OKExFuture) GetFee

func (ok *OKExFuture) GetFee() (float64, error)

func (*OKExFuture) GetFutureAllTicker

func (ok *OKExFuture) GetFutureAllTicker() (*[]FutureTicker, error)

func (*OKExFuture) GetFutureContractId

func (ok *OKExFuture) GetFutureContractId(pair CurrencyPair, contractAlias string) string

func (*OKExFuture) GetFutureDepth

func (ok *OKExFuture) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*OKExFuture) GetFutureEstimatedPrice

func (ok *OKExFuture) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*OKExFuture) GetFutureIndex

func (ok *OKExFuture) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*OKExFuture) GetFutureOrder

func (ok *OKExFuture) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

func (*OKExFuture) GetFutureOrderHistory

func (ok *OKExFuture) GetFutureOrderHistory(pair CurrencyPair, contractType string, optional ...OptionalParameter) ([]FutureOrder, error)

func (*OKExFuture) GetFutureOrders

func (ok *OKExFuture) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExFuture) GetFuturePosition

func (ok *OKExFuture) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*OKExFuture) GetFutureTicker

func (ok *OKExFuture) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*OKExFuture) GetFutureUserinfo

func (ok *OKExFuture) GetFutureUserinfo(currencyPair ...CurrencyPair) (*FutureAccount, error)

基本上已经报废,OK限制10s一次,但是基本上都会返回error:{"code":30014,"message":"Too Many Requests"} 加入currency pair救活了这个接口

func (*OKExFuture) GetKlineRecords

func (ok *OKExFuture) GetKlineRecords(contractType string, currency CurrencyPair, period KlinePeriod, size int, opt ...OptionalParameter) ([]FutureKline, error)

func (*OKExFuture) GetKlineRecordsByRange

func (ok *OKExFuture) GetKlineRecordsByRange(contractType string, currency CurrencyPair, period, since, to int) ([]FutureKline, error)

*

since : 单位秒,开始时间
to : 单位秒,结束时间

func (*OKExFuture) GetRate

func (ok *OKExFuture) GetRate() (float64, error)

获取法币汇率

func (*OKExFuture) GetTrades

func (ok *OKExFuture) GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*OKExFuture) GetUnfinishFutureOrders

func (ok *OKExFuture) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExFuture) LimitFuturesOrder

func (ok *OKExFuture) LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)

func (*OKExFuture) MarketCloseAllPosition

func (ok *OKExFuture) MarketCloseAllPosition(currency CurrencyPair, contract string, oType int) (bool, error)

特殊接口

市价全平仓
contract:合约ID
oType:平仓方向:CLOSE_SELL平空,CLOSE_BUY平多

func (*OKExFuture) MarketFuturesOrder

func (ok *OKExFuture) MarketFuturesOrder(currencyPair CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error)

func (*OKExFuture) PlaceFutureOrder

func (ok *OKExFuture) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error)

func (*OKExFuture) PlaceFutureOrder2

func (ok *OKExFuture) PlaceFutureOrder2(matchPrice int, ord *FutureOrder) (*FutureOrder, error)

matchPrice:是否以对手价下单(0:不是 1:是),默认为0;当取值为1时,price字段无效,当以对手价下单,order_type只能选择0:普通委托

type OKExMargin

type OKExMargin struct {
	*OKEx
}

func (*OKExMargin) Borrow

func (ok *OKExMargin) Borrow(parameter BorrowParameter) (borrowId string, err error)

*

杠杆交易区借币,
pair : 操作的交易对
currency: 需要借的币种
amount : 借的金额

func (*OKExMargin) CancelOrder

func (ok *OKExMargin) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

func (*OKExMargin) GetMarginAccount

func (ok *OKExMargin) GetMarginAccount(pair CurrencyPair) (*MarginAccount, error)

func (*OKExMargin) GetOneOrder

func (ok *OKExMargin) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

orderId can set client oid or orderId

func (*OKExMargin) GetUnfinishOrders

func (ok *OKExMargin) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*OKExMargin) PlaceOrder

func (ok *OKExMargin) PlaceOrder(ord *Order) (*Order, error)

func (*OKExMargin) Repayment

func (ok *OKExMargin) Repayment(parameter RepaymentParameter) (repaymentId string, err error)

type OKExSpot

type OKExSpot struct {
	*OKEx
}

func (*OKExSpot) BatchPlaceOrders

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

* Must Set Client Oid

func (*OKExSpot) CancelOrder

func (ok *OKExSpot) CancelOrder(orderId string, currency CurrencyPair) (bool, error)

orderId can set client oid or orderId

func (*OKExSpot) GetAccount

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

func (*OKExSpot) GetCurrenciesPrecision

func (ok *OKExSpot) GetCurrenciesPrecision() ([]OKExSpotSymbol, error)

func (*OKExSpot) GetDepth

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

func (*OKExSpot) GetExchangeName

func (ok *OKExSpot) GetExchangeName() string

func (*OKExSpot) GetKlineRecords

func (ok *OKExSpot) GetKlineRecords(currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error)

func (*OKExSpot) GetOneOrder

func (ok *OKExSpot) GetOneOrder(orderId string, currency CurrencyPair) (*Order, error)

orderId can set client oid or orderId

func (*OKExSpot) GetOrderHistorys

func (ok *OKExSpot) GetOrderHistorys(currency CurrencyPair, optional ...OptionalParameter) ([]Order, error)

func (*OKExSpot) GetTicker

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

func (*OKExSpot) GetTrades

func (ok *OKExSpot) GetTrades(currencyPair CurrencyPair, since int64) ([]Trade, error)

非个人,整个交易所的交易记录

func (*OKExSpot) GetUnfinishOrders

func (ok *OKExSpot) GetUnfinishOrders(currency CurrencyPair) ([]Order, error)

func (*OKExSpot) LimitBuy

func (ok *OKExSpot) LimitBuy(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*OKExSpot) LimitSell

func (ok *OKExSpot) LimitSell(amount, price string, currency CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*OKExSpot) MarketBuy

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

func (*OKExSpot) MarketSell

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

func (*OKExSpot) PlaceOrder

func (ok *OKExSpot) PlaceOrder(ty string, ord *Order) (*Order, error)

type OKExSpotSymbol

type OKExSpotSymbol struct {
	BaseCurrency    string
	QuoteCurrency   string
	PricePrecision  float64
	AmountPrecision float64
	MinAmount       float64
	MinValue        float64
	SymbolPartition string
	Symbol          string
}

type OKExSwap

type OKExSwap struct {
	*OKEx
	// contains filtered or unexported fields
}

func NewOKExSwap

func NewOKExSwap(config *APIConfig) *OKExSwap

func (*OKExSwap) AdaptTradeStatus

func (ok *OKExSwap) AdaptTradeStatus(status int) TradeStatus

func (*OKExSwap) FutureCancelAlgoOrder

func (ok *OKExSwap) FutureCancelAlgoOrder(currencyPair CurrencyPair, orderId []string) (bool, error)

委托策略撤单

func (*OKExSwap) FutureCancelOrder

func (ok *OKExSwap) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*OKExSwap) GetContractValue

func (ok *OKExSwap) GetContractValue(currencyPair CurrencyPair) (float64, error)

*

  • BTC: 100美元一张合约
  • LTC/ETH/ETC/BCH: 10美元一张合约

func (*OKExSwap) GetDeliveryTime

func (ok *OKExSwap) GetDeliveryTime() (int, int, int, int)

func (*OKExSwap) GetExchangeName

func (ok *OKExSwap) GetExchangeName() string

func (*OKExSwap) GetExchangeRate

func (ok *OKExSwap) GetExchangeRate() (float64, error)

func (*OKExSwap) GetFee

func (ok *OKExSwap) GetFee() (float64, error)

func (*OKExSwap) GetFutureAccountInfo

func (ok *OKExSwap) GetFutureAccountInfo(currency CurrencyPair) (*SwapAccountInfo, error)

func (*OKExSwap) GetFutureAlgoOrders

func (ok *OKExSwap) GetFutureAlgoOrders(algo_id string, status string, currencyPair CurrencyPair) ([]FutureOrder, error)

获取委托单列表, status和algo_id必填且只能填其一

func (*OKExSwap) GetFutureAllTicker

func (ok *OKExSwap) GetFutureAllTicker() (*[]FutureTicker, error)

func (*OKExSwap) GetFutureDepth

func (ok *OKExSwap) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*OKExSwap) GetFutureEstimatedPrice

func (ok *OKExSwap) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*OKExSwap) GetFutureIndex

func (ok *OKExSwap) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*OKExSwap) GetFutureOrder

func (ok *OKExSwap) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

*

*获取单个订单信息

func (*OKExSwap) GetFutureOrderHistory

func (ok *OKExSwap) GetFutureOrderHistory(pair CurrencyPair, contractType string, optional ...OptionalParameter) ([]FutureOrder, error)

func (*OKExSwap) GetFutureOrders

func (ok *OKExSwap) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

*

*获取订单信息

func (*OKExSwap) GetFuturePosition

func (ok *OKExSwap) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*OKExSwap) GetFutureTicker

func (ok *OKExSwap) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*OKExSwap) GetFutureUserinfo

func (ok *OKExSwap) GetFutureUserinfo(currencyPair ...CurrencyPair) (*FutureAccount, error)

func (*OKExSwap) GetHistoricalFunding

func (ok *OKExSwap) GetHistoricalFunding(contractType string, currencyPair CurrencyPair, page int) ([]HistoricalFunding, error)

func (*OKExSwap) GetInstruments

func (ok *OKExSwap) GetInstruments() ([]Instrument, error)

func (*OKExSwap) GetKlineRecords

func (ok *OKExSwap) GetKlineRecords(contractType string, currency CurrencyPair, period KlinePeriod, size int, opt ...OptionalParameter) ([]FutureKline, error)

func (*OKExSwap) GetKlineRecords2

func (ok *OKExSwap) GetKlineRecords2(contractType string, currency CurrencyPair, start, end, period string) ([]FutureKline, error)

*

since : 单位秒,开始时间

func (*OKExSwap) GetKlineRecordsByRange

func (ok *OKExSwap) GetKlineRecordsByRange(currency CurrencyPair, period, since, to int) ([]FutureKline, error)

*

since : 单位秒,开始时间
to : 单位秒,结束时间

func (*OKExSwap) GetMarginLevel

func (ok *OKExSwap) GetMarginLevel(currencyPair CurrencyPair) (*MarginLeverage, error)

func (*OKExSwap) GetTrades

func (ok *OKExSwap) GetTrades(contractType string, currencyPair CurrencyPair, since int64) ([]Trade, error)

func (*OKExSwap) GetUnfinishFutureOrders

func (ok *OKExSwap) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExSwap) LimitFuturesOrder

func (ok *OKExSwap) LimitFuturesOrder(currencyPair CurrencyPair, contractType, price, amount string, openType int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)

func (*OKExSwap) MarketFuturesOrder

func (ok *OKExSwap) MarketFuturesOrder(currencyPair CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error)

func (*OKExSwap) PlaceFutureAlgoOrder

func (ok *OKExSwap) PlaceFutureAlgoOrder(ord *FutureOrder) (*FutureOrder, error)

委托策略下单 algo_type 1:限价 2:市场价;触发价格类型,默认是限价;为市场价时,委托价格不必填;

func (*OKExSwap) PlaceFutureOrder

func (ok *OKExSwap) PlaceFutureOrder(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, leverRate float64) (string, error)

func (*OKExSwap) PlaceFutureOrder2

func (ok *OKExSwap) PlaceFutureOrder2(currencyPair CurrencyPair, contractType, price, amount string, openType, matchPrice int, opt ...LimitOrderOptionalParameter) (*FutureOrder, error)

func (*OKExSwap) SetMarginLevel

func (ok *OKExSwap) SetMarginLevel(currencyPair CurrencyPair, level, marginMode int) (*MarginLeverage, error)

marginmode 1:逐仓-多仓 2:逐仓-空仓 3:全仓

type OKExV3FuturesWs

type OKExV3FuturesWs struct {
	// contains filtered or unexported fields
}

func NewOKExV3FuturesWs

func NewOKExV3FuturesWs(base *OKEx) *OKExV3FuturesWs

func (*OKExV3FuturesWs) DepthCallback

func (okV3Ws *OKExV3FuturesWs) DepthCallback(depthCallback func(*Depth))

func (*OKExV3FuturesWs) KlineCallback

func (okV3Ws *OKExV3FuturesWs) KlineCallback(klineCallback func(*FutureKline, int))

func (*OKExV3FuturesWs) SetCallbacks

func (okV3Ws *OKExV3FuturesWs) SetCallbacks(tickerCallback func(*FutureTicker),
	depthCallback func(*Depth),
	tradeCallback func(*Trade, string),
	klineCallback func(*FutureKline, int))

func (*OKExV3FuturesWs) SubscribeDepth

func (okV3Ws *OKExV3FuturesWs) SubscribeDepth(currencyPair CurrencyPair, contractType string) error

func (*OKExV3FuturesWs) SubscribeKline

func (okV3Ws *OKExV3FuturesWs) SubscribeKline(currencyPair CurrencyPair, contractType string, period int) error

func (*OKExV3FuturesWs) SubscribeTicker

func (okV3Ws *OKExV3FuturesWs) SubscribeTicker(currencyPair CurrencyPair, contractType string) error

func (*OKExV3FuturesWs) SubscribeTrade

func (okV3Ws *OKExV3FuturesWs) SubscribeTrade(currencyPair CurrencyPair, contractType string) error

func (*OKExV3FuturesWs) TickerCallback

func (okV3Ws *OKExV3FuturesWs) TickerCallback(tickerCallback func(*FutureTicker))

func (*OKExV3FuturesWs) TradeCallback

func (okV3Ws *OKExV3FuturesWs) TradeCallback(tradeCallback func(*Trade, string))

type OKExV3SpotWs

type OKExV3SpotWs struct {
	// contains filtered or unexported fields
}

func NewOKExSpotV3Ws

func NewOKExSpotV3Ws(base *OKEx) *OKExV3SpotWs

func (*OKExV3SpotWs) DepthCallback

func (okV3Ws *OKExV3SpotWs) DepthCallback(depthCallback func(*Depth))

func (*OKExV3SpotWs) KLineCallback

func (okV3Ws *OKExV3SpotWs) KLineCallback(klineCallback func(kline *Kline, period KlinePeriod))

func (*OKExV3SpotWs) SetCallbacks

func (okV3Ws *OKExV3SpotWs) SetCallbacks(tickerCallback func(*Ticker),
	depthCallback func(*Depth),
	tradeCallback func(*Trade),
	klineCallback func(*Kline, KlinePeriod))

func (*OKExV3SpotWs) SubscribeDepth

func (okV3Ws *OKExV3SpotWs) SubscribeDepth(currencyPair CurrencyPair) error

func (*OKExV3SpotWs) SubscribeKline

func (okV3Ws *OKExV3SpotWs) SubscribeKline(currencyPair CurrencyPair, period int) error

func (*OKExV3SpotWs) SubscribeTicker

func (okV3Ws *OKExV3SpotWs) SubscribeTicker(currencyPair CurrencyPair) error

func (*OKExV3SpotWs) SubscribeTrade

func (okV3Ws *OKExV3SpotWs) SubscribeTrade(currencyPair CurrencyPair) error

func (*OKExV3SpotWs) TickerCallback

func (okV3Ws *OKExV3SpotWs) TickerCallback(tickerCallback func(*Ticker))

func (*OKExV3SpotWs) TradeCallback

func (okV3Ws *OKExV3SpotWs) TradeCallback(tradeCallback func(*Trade))

type OKExV3SwapWs

type OKExV3SwapWs struct {
	// contains filtered or unexported fields
}

func NewOKExV3SwapWs

func NewOKExV3SwapWs(base *OKEx) *OKExV3SwapWs

func (*OKExV3SwapWs) DepthCallback

func (okV3Ws *OKExV3SwapWs) DepthCallback(depthCallback func(*Depth))

func (*OKExV3SwapWs) KlineCallback

func (okV3Ws *OKExV3SwapWs) KlineCallback(klineCallback func(*FutureKline, int))

func (*OKExV3SwapWs) SetCallbacks

func (okV3Ws *OKExV3SwapWs) SetCallbacks(tickerCallback func(*FutureTicker),
	depthCallback func(*Depth),
	tradeCallback func(*Trade, string),
	klineCallback func(*FutureKline, int))

func (*OKExV3SwapWs) SubscribeDepth

func (okV3Ws *OKExV3SwapWs) SubscribeDepth(currencyPair CurrencyPair, contractType string) error

func (*OKExV3SwapWs) SubscribeKline

func (okV3Ws *OKExV3SwapWs) SubscribeKline(currencyPair CurrencyPair, contractType string, period int) error

func (*OKExV3SwapWs) SubscribeTicker

func (okV3Ws *OKExV3SwapWs) SubscribeTicker(currencyPair CurrencyPair, contractType string) error

func (*OKExV3SwapWs) SubscribeTrade

func (okV3Ws *OKExV3SwapWs) SubscribeTrade(currencyPair CurrencyPair, contractType string) error

func (*OKExV3SwapWs) TickerCallback

func (okV3Ws *OKExV3SwapWs) TickerCallback(tickerCallback func(*FutureTicker))

func (*OKExV3SwapWs) TradeCallback

func (okV3Ws *OKExV3SwapWs) TradeCallback(tradeCallback func(*Trade, string))

type OKExV3Ws

type OKExV3Ws struct {
	*WsBuilder

	WsConn *WsConn
	// contains filtered or unexported fields
}

func NewOKExV3Ws

func NewOKExV3Ws(base *OKEx, handle func(channel string, data json.RawMessage) error) *OKExV3Ws

func (*OKExV3Ws) ConnectWs

func (okV3Ws *OKExV3Ws) ConnectWs()

func (*OKExV3Ws) Subscribe

func (okV3Ws *OKExV3Ws) Subscribe(sub map[string]interface{}) error

type OKExWallet

type OKExWallet struct {
	*OKEx
}

func (*OKExWallet) GetAccount

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

func (*OKExWallet) GetDepositAddress

func (ok *OKExWallet) GetDepositAddress(currency Currency) ([]DepositAddress, error)

func (*OKExWallet) GetDepositHistory

func (ok *OKExWallet) GetDepositHistory(currency *Currency) ([]DepositWithdrawHistory, error)

func (*OKExWallet) GetWithDrawHistory

func (ok *OKExWallet) GetWithDrawHistory(currency *Currency) ([]DepositWithdrawHistory, error)

func (*OKExWallet) GetWithDrawalFee

func (ok *OKExWallet) GetWithDrawalFee(currency *Currency) ([]WithdrawFee, error)

func (*OKExWallet) Transfer

func (ok *OKExWallet) Transfer(param TransferParameter) error
解释说明

from或to指定为0时,sub_account为必填项。

当from为0时,to只能填6,即子账户的资金账户只能转到母账户的资金账户。

当from指定为6,to指定为1-9,且sub_account填写子账户名时,可从母账户直接划转至子账户对应的币币、合约等账户。

from或to指定为5时,instrument_id为必填项。

func (*OKExWallet) Withdrawal

func (ok *OKExWallet) Withdrawal(param WithdrawParameter) (withdrawId string, err error)

认证过的数字货币地址、邮箱或手机号。某些数字货币地址格式为:地址+标签,例:"ARDOR-7JF3-8F2E-QUWZ-CAN7F:123456"

type OrderResponse

type OrderResponse struct {
	InstrumentId   string  `json:"instrument_id"`
	ClientOid      string  `json:"client_oid"`
	OrderId        string  `json:"order_id"`
	Price          string  `json:"price,omitempty"`
	Size           float64 `json:"size,string"`
	Notional       string  `json:"notional"`
	Side           string  `json:"side"`
	Type           string  `json:"type"`
	FilledSize     string  `json:"filled_size"`
	FilledNotional string  `json:"filled_notional"`
	PriceAvg       string  `json:"price_avg"`
	State          int     `json:"state,string"`
	Fee            string  `json:"fee"`
	OrderType      int     `json:"order_type,string"`
	Timestamp      string  `json:"timestamp"`
}

type PlaceOrderInfo

type PlaceOrderInfo struct {
	BasePlaceOrderInfo
	InstrumentId string `json:"instrument_id"`
}

type PlaceOrderParam

type PlaceOrderParam struct {
	ClientOid     string  `json:"client_oid"`
	Type          string  `json:"type"`
	Side          string  `json:"side"`
	InstrumentId  string  `json:"instrument_id"`
	OrderType     int     `json:"order_type"`
	Price         float64 `json:"price"`
	Size          float64 `json:"size"`
	Notional      float64 `json:"notional"`
	MarginTrading string  `json:"margin_trading,omitempty"`
}

type PlaceOrderResponse

type PlaceOrderResponse struct {
	OrderId      string `json:"order_id"`
	ClientOid    string `json:"client_oid"`
	Result       bool   `json:"result"`
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

type PlaceOrdersInfo

type PlaceOrdersInfo struct {
	InstrumentId string                `json:"instrument_id"`
	OrderData    []*BasePlaceOrderInfo `json:"order_data"`
}

type SwapAccountHolds

type SwapAccountHolds BaseInstrumentAmount

type SwapAccountInfo

type SwapAccountInfo struct {
	InstrumentId      string  `json:"instrument_id"`
	Timestamp         string  `json:"timestamp"`
	MarginFrozen      float64 `json:"margin_frozen,string"`
	TotalAvailBalance float64 `json:"total_avail_balance,string"`
	MarginRatio       float64 `json:"margin_ratio,string"`
	RealizedPnl       float64 `json:"realized_pnl,string"`
	UnrealizedPnl     float64 `json:"unrealized_pnl,string"`
	FixedBalance      float64 `json:"fixed_balance,string"`
	Equity            float64 `json:"equity,string"`
	Margin            float64 `json:"margin,string"`
	MarginMode        string  `json:"margin_mode"`
}

type SwapAccounts

type SwapAccounts struct {
	BizWarmTips
	Info []SwapAccountInfo `json:"info"`
}

type SwapAccountsLedgerList

type SwapAccountsLedgerList []BaseLedgerInfo

type SwapAccountsSetting

type SwapAccountsSetting struct {
	BizWarmTips
	InstrumentId  string `json:"instrument_id"`
	LongLeverage  string `json:"long_leverage"`
	ShortLeverage string `json:"short_leverage"`
	MarginMode    string `json:"margin_mode"`
}

type SwapBatchCancelOrderResult

type SwapBatchCancelOrderResult struct {
	BizWarmTips
	InstrumentId string   `json:"instrument_id"`
	Ids          []string `json:"ids"`
	Result       string   `json:"result"`
}

type SwapCancelOrderResult

type SwapCancelOrderResult struct {
	ErrorMessage string `json:"error_message"`
	ErrorCode    string `json:"error_code"`
	OrderId      string `json:"order_id"`
	Result       bool   `json:"result,string"`
}

type SwapCandleList

type SwapCandleList []BaseCandleInfo

type SwapFillsInfo

type SwapFillsInfo struct {
	BizWarmTips
	FillInfo []*BaseFillInfo `json:"fill_info"`
}

type SwapFundingTime

type SwapFundingTime struct {
	BizWarmTips
	InstrumentId string `json:"instrument_id"`
	FundingTime  string `json:"funding_time"`
}

type SwapHistoricalFundingRateList

type SwapHistoricalFundingRateList []BaseHistoricalFundingRate

type SwapIndexInfo

type SwapIndexInfo struct {
	BizWarmTips
	InstrumentId string `json:"instrument_id"`
	Index        string `json:"index"`
	Timestamp    string `json:"timestamp"`
}

type SwapInstrumentDepth

type SwapInstrumentDepth struct {
	BizWarmTips
	Timestamp string          `json:"time"`
	Bids      []BaesDepthInfo `json:"bids"`
	Asks      []BaesDepthInfo `json:"asks"`
}

type SwapInstrumentList

type SwapInstrumentList []BaseInstrumentInfo

type SwapLiquidationList

type SwapLiquidationList []BaseLiquidationInfo

type SwapMarkPrice

type SwapMarkPrice struct {
	BizWarmTips
	InstrumentId string `json:"instrument_id"`
	MarkPrice    string `json:"mark_price"`
	Timestamp    string `json:"timestamp"`
}

type SwapOpenInterest

type SwapOpenInterest BaseInstrumentAmount

type SwapOrderResult

type SwapOrderResult struct {
	BaseSwapOrderResult
	BizWarmTips
}

type SwapOrdersInfo

type SwapOrdersInfo struct {
	BizWarmTips
	OrderInfo []BaseOrderInfo `json:"order_info"`
}

type SwapOrdersResult

type SwapOrdersResult struct {
	BizWarmTips
	OrderInfo []BaseSwapOrderResult `json:"order_info"`
}

type SwapPosition

type SwapPosition struct {
	BizWarmTips
	MarginMode string                `json:"margin_mode"`
	Holding    []SwapPositionHolding `json:"holding"`
}

type SwapPositionHolding

type SwapPositionHolding struct {
	LiquidationPrice float64 `json:"liquidation_price , string"`
	Position         float64 `json:"position,string"`
	AvailPosition    float64 `json:"avail_position,string"`
	AvgCost          float64 `json:"avg_cost,string"`
	SettlementPrice  float64 `json:"settlement_price,string"`
	InstrumentId     string  `json:"instrument_id"`
	Leverage         string  `json:"leverage"`
	RealizedPnl      float64 `json:"realized_pnl,string"`
	Side             string  `json:"side"`
	Timestamp        string  `json:"timestamp"`
	Margin           string  `json:"margin";default:""`
}

type SwapPriceLimit

type SwapPriceLimit struct {
	BizWarmTips
	InstrumentId string `json:"instrument_id"`
	Lowest       string `json:"lowest"`
	Highest      string `json:"highest"`
	Timestamp    string `json:"timestamp"`
}

type SwapRate

type SwapRate struct {
	InstrumentId string `json:"instrument_id"`
	Timestamp    string `json:"timestamp"`
	Rate         string `json:"rate"`
}

type SwapTickerList

type SwapTickerList []BaseTickerInfo

type SwapTradeList

type SwapTradeList []BaseTradeInfo

type WithdrawFee

type WithdrawFee struct {
	Currency string `json:"currency"`
	MaxFee   string `json:"max_fee"`
	MinFee   string `json:"min_fee"`
}

Jump to

Keyboard shortcuts

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