okex

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTENT_TYPE          = "Content-Type"
	ACCEPT                = "Accept"
	APPLICATION_JSON_UTF8 = "application/json; charset=UTF-8"
	APPLICATION_JSON      = "application/json"
	OK_ACCESS_KEY         = "OK-ACCESS-KEY"
	OK_ACCESS_SIGN        = "OK-ACCESS-SIGN"
	OK_ACCESS_TIMESTAMP   = "OK-ACCESS-TIMESTAMP"
	OK_ACCESS_PASSPHRASE  = "OK-ACCESS-PASSPHRASE"
)

Variables

This section is empty.

Functions

func IsoTime

func IsoTime() string

Get a iso time

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

Types

type AssetSummary

type AssetSummary struct {
	Currency  string  `json:"ccy"`
	Total     float64 `json:"bal"`
	Available float64 `json:"availBal,string"`
	Frozen    float64 `json:"frozenBal,string"`
}

type BalanceDetail

type BalanceDetail struct {
	Available string `json:"availBal"`
	AvailEq   string `json:"availEq"`
	CashBal   string `json:"cashBal"`
	Currency  string `json:"ccy"`
	DisEq     string `json:"disEq"`
	Eq        string `json:"eq"`
	Frozen    string `json:"frozenBal"`
	Interest  string `json:"interest"`
	IsoEq     string `json:"isoEq"`
	Liab      string `json:"liab"`
	MgnRatio  string `json:"mgnRatio"`
	OrdFrozen string `json:"ordFrozen"`
	UTime     string `json:"uTime"`
	Upl       string `json:"upl"`
	UplLiab   string `json:"uplLiab"`
}

type BalanceV5

type BalanceV5 struct {
	AdjEq    string          `json:"adjEq"`
	Details  []BalanceDetail `json:"details"`
	Imr      string          `json:"imr"`
	IsoEq    string          `json:"isoEq"`
	MgnRatio string          `json:"mgnRatio"`
	Mmr      string          `json:"mmr"`
	OrdFroz  string          `json:"ordFroz"`
	TotalEq  string          `json:"totalEq"`
	UTime    string          `json:"uTime"`
}

type CreateOrderParam

type CreateOrderParam struct {
	Symbol    string //产品ID
	TradeMode string //交易模式,	保证金模式:isolated:逐仓 ;cross:全仓,	非保证金模式:cash:非保证金
	Side      string // 订单方向 buy:买 sell:卖
	OrderType string //订单类型

	Size        string //	委托数量
	PosSide     string //持仓方向 在双向持仓模式下必填,且仅可选择 long 或 short
	Price       string //委托价格,仅适用于限价单
	CCY         string // 保证金币种,仅适用于单币种保证金模式下的全仓杠杆订单
	ClientOrdId string //客户自定义订单ID	字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。
	Tag         string //订单标签	字母(区分大小写)与数字的组合,可以是纯字母、纯数字,且长度在1-8位之间。
	ReduceOnly  bool   //是否只减仓,true 或 false,默认false	仅适用于币币杠杆订单
}

type DepthV5

type DepthV5 struct {
	Asks      [][]string `json:"asks,string"`
	Bids      [][]string `json:"bids,string"`
	Timestamp uint64     `json:"ts,string"` // 单位:ms
}

type OKExV5

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

base interface for okex v5

func NewOKExV5

func NewOKExV5(config *APIConfig) *OKExV5

func (*OKExV5) BuildRequestBody

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

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

func (*OKExV5) CancelOrderV5

func (ok *OKExV5) CancelOrderV5(instId, ordId, clOrdId string) (*OrderSummaryV5, error)

func (*OKExV5) CreateOrder

func (ok *OKExV5) CreateOrder(param *CreateOrderParam) (*OrderSummaryV5, error)

func (*OKExV5) DoAuthorRequest

func (ok *OKExV5) DoAuthorRequest(httpMethod, uri, reqBody string, response interface{}) error

func (*OKExV5) ExchangeName

func (ok *OKExV5) ExchangeName() string

func (*OKExV5) GetAccountBalances

func (ok *OKExV5) GetAccountBalances(currency string) (*BalanceV5, error)

func (*OKExV5) GetAssetBalances

func (ok *OKExV5) GetAssetBalances(currency string) ([]AssetSummary, error)

func (*OKExV5) GetDepthV5

func (ok *OKExV5) GetDepthV5(instId string, size int) (*DepthV5, error)

func (*OKExV5) GetKlineRecordsV5

func (ok *OKExV5) GetKlineRecordsV5(instId string, period KlinePeriod, params *url.Values) ([][]string, error)

func (*OKExV5) GetOrderHistory

func (ok *OKExV5) GetOrderHistory(instType, instId, ordType, state, afterID, beforeID string) ([]OrderV5, error)

func (*OKExV5) GetOrderV5

func (ok *OKExV5) GetOrderV5(instId, ordId, clOrdId string) (*OrderV5, error)

func (*OKExV5) GetPendingOrders

func (ok *OKExV5) GetPendingOrders(param *PendingOrderParam) ([]OrderV5, error)

func (*OKExV5) GetTickerV5

func (ok *OKExV5) GetTickerV5(instId string) (*TickerV5, error)

func (*OKExV5) SetCustomCID

func (ok *OKExV5) SetCustomCID(f func() string)

type OKExV5Spot

type OKExV5Spot struct {
	*OKExV5
}

func NewOKExV5Spot

func NewOKExV5Spot(config *APIConfig) *OKExV5Spot

func (*OKExV5Spot) CancelOrder

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

func (*OKExV5Spot) GetAccount

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

func (*OKExV5Spot) GetDepth

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

func (*OKExV5Spot) GetExchangeName

func (ok *OKExV5Spot) GetExchangeName() string

func (*OKExV5Spot) GetKlineRecords

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

func (*OKExV5Spot) GetOneOrder

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

func (*OKExV5Spot) GetOrderHistorys

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

func (*OKExV5Spot) GetTicker

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

func (*OKExV5Spot) GetTrades

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

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

func (*OKExV5Spot) GetUnfinishOrders

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

func (*OKExV5Spot) LimitBuy

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

private API

func (*OKExV5Spot) LimitSell

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

func (*OKExV5Spot) MarketBuy

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

func (*OKExV5Spot) MarketSell

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

type OKExV5Swap

type OKExV5Swap struct {
	*OKExV5
}

func NewOKExV5Swap

func NewOKExV5Swap(config *APIConfig) *OKExV5Swap

func (*OKExV5Swap) FutureCancelOrder

func (O *OKExV5Swap) FutureCancelOrder(currencyPair CurrencyPair, contractType, orderId string) (bool, error)

func (*OKExV5Swap) GetContractValue

func (O *OKExV5Swap) GetContractValue(currencyPair CurrencyPair) (float64, error)

func (OKExV5Swap) GetDeliveryTime

func (O OKExV5Swap) GetDeliveryTime() (int, int, int, int)

func (*OKExV5Swap) GetExchangeName

func (O *OKExV5Swap) GetExchangeName() string

func (*OKExV5Swap) GetFee

func (O *OKExV5Swap) GetFee() (float64, error)

func (*OKExV5Swap) GetFutureDepth

func (O *OKExV5Swap) GetFutureDepth(currencyPair CurrencyPair, contractType string, size int) (*Depth, error)

func (*OKExV5Swap) GetFutureEstimatedPrice

func (O *OKExV5Swap) GetFutureEstimatedPrice(currencyPair CurrencyPair) (float64, error)

func (*OKExV5Swap) GetFutureIndex

func (O *OKExV5Swap) GetFutureIndex(currencyPair CurrencyPair) (float64, error)

func (*OKExV5Swap) GetFutureOrder

func (O *OKExV5Swap) GetFutureOrder(orderId string, currencyPair CurrencyPair, contractType string) (*FutureOrder, error)

func (*OKExV5Swap) GetFutureOrderHistory

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

func (*OKExV5Swap) GetFutureOrders

func (O *OKExV5Swap) GetFutureOrders(orderIds []string, currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExV5Swap) GetFuturePosition

func (O *OKExV5Swap) GetFuturePosition(currencyPair CurrencyPair, contractType string) ([]FuturePosition, error)

func (*OKExV5Swap) GetFutureTicker

func (O *OKExV5Swap) GetFutureTicker(currencyPair CurrencyPair, contractType string) (*Ticker, error)

func (*OKExV5Swap) GetFutureUserinfo

func (O *OKExV5Swap) GetFutureUserinfo(currencyPair ...CurrencyPair) (*FutureAccount, error)

func (*OKExV5Swap) GetKlineRecords

func (O *OKExV5Swap) GetKlineRecords(contractType string, currency CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]FutureKline, error)

func (*OKExV5Swap) GetTrades

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

func (*OKExV5Swap) GetUnfinishFutureOrders

func (O *OKExV5Swap) GetUnfinishFutureOrders(currencyPair CurrencyPair, contractType string) ([]FutureOrder, error)

func (*OKExV5Swap) LimitFuturesOrder

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

func (*OKExV5Swap) MarketFuturesOrder

func (O *OKExV5Swap) MarketFuturesOrder(currencyPair CurrencyPair, contractType, amount string, openType int) (*FutureOrder, error)

func (*OKExV5Swap) PlaceFutureOrder

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

type OrderSummaryV5

type OrderSummaryV5 struct {
	OrdId       string `json:"ordId"`
	ClientOrdId string `json:"clOrdId"` //客户自定义订单ID	字母(区分大小写)与数字的组合,可以是纯字母、纯数字且长度要在1-32位之间。
	Tag         string `json:"tag"`
	SCode       string `json:"sCode"`
	SMsg        string `json:"sMsg"`
}

type OrderV5

type OrderV5 struct {
	AccFillSz   string  `json:"accFillSz"`
	AvgPx       string  `json:"avgPx"`
	CTime       int     `json:"cTime,string"`
	Category    string  `json:"category"`
	Ccy         string  `json:"ccy"`
	ClOrdID     string  `json:"clOrdId"`
	Fee         float64 `json:"fee,string"`
	FeeCcy      string  `json:"feeCcy"`
	FillPx      string  `json:"fillPx"`
	FillSz      string  `json:"fillSz"`
	FillTime    string  `json:"fillTime"`
	InstID      string  `json:"instId"`
	InstType    string  `json:"instType"`
	Lever       string  `json:"lever"`
	OrdID       string  `json:"ordId"`
	OrdType     string  `json:"ordType"`
	Pnl         string  `json:"pnl"`
	PosSide     string  `json:"posSide"`
	Px          float64 `json:"px,string"`
	Rebate      string  `json:"rebate"`
	RebateCcy   string  `json:"rebateCcy"`
	Side        string  `json:"side"`
	SlOrdPx     string  `json:"slOrdPx"`
	SlTriggerPx string  `json:"slTriggerPx"`
	State       string  `json:"state"`
	Sz          float64 `json:"sz,string"`
	Tag         string  `json:"tag"`
	TdMode      string  `json:"tdMode"`
	TpOrdPx     string  `json:"tpOrdPx"`
	TpTriggerPx string  `json:"tpTriggerPx"`
	TradeID     string  `json:"tradeId"`
	UTime       int64   `json:"uTime,string"`
}

type PendingOrderParam

type PendingOrderParam struct {
	InstType string
	Uly      string
	InstId   string //产品ID
	OrdType  string
	State    string
	After    string
	Before   string
	Limit    string
}

type TickerV5

type TickerV5 struct {
	InstId    string  `json:"instId"`
	Last      float64 `json:"last,string"`
	BuyPrice  float64 `json:"bidPx,string"`
	BuySize   float64 `json:"bidSz,string"`
	SellPrice float64 `json:"askPx,string"`
	SellSize  float64 `json:"askSz,string"`
	Open      float64 `json:"open24h,string"`
	High      float64 `json:"high24h,string"`
	Low       float64 `json:"low24h,string"`
	Vol       float64 `json:"volCcy24h,string"`
	VolQuote  float64 `json:"vol24h,string"`
	Timestamp uint64  `json:"ts,string"` // 单位:ms
}

Jump to

Keyboard shortcuts

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