okx

package
v0.0.0-...-41d977e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 15 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"
)
View Source
const (
	Subscribe   = "subscribe"
	UnSubscribe = "unsubscribe"
)

Variables

This section is empty.

Functions

func IsoTime

func IsoTime() string

Types

type AccountV5

type AccountV5 struct {
	TotalEq     string         `json:"totalEq"`
	IsoEq       string         `json:"isoEq"`
	AdjEq       string         `json:"adjEq"`
	OrdFroz     string         `json:"ordFroz"`
	Imr         string         `json:"imr,omitempty"`
	Mmr         string         `json:"mmr"`
	BorrowFroz  string         `json:"borrowFroz"`
	NotionalUsd string         `json:"notionalUsd"`
	Upl         string         `json:"upl"`
	Details     []SubAccountV5 `json:"details"`
}

type AccountV5Response

type AccountV5Response struct {
	Code int         `json:"code,string"`
	Msg  string      `json:"msg"`
	Data []AccountV5 `json:"data"`
}

type DepthV5

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

type InstrumentsV5

type InstrumentsV5 struct {
	InstId   string `json:"instId"`
	BaseCcy  string `json:"baseCcy"`
	QuoteCcy string `json:"quoteCcy"`
	TickSz   string `json:"tickSz"`
	LotSz    string `json:"lotSz"`
	State    string `json:"state"`
}

type InstrumentsV5Response

type InstrumentsV5Response struct {
	Code int             `json:"code,string"`
	Msg  string          `json:"msg"`
	Data []InstrumentsV5 `json:"data"`
}

type Okx

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

func New

func New(client *http.Client, accesskey, secretkey, passphrase string) *Okx

func (*Okx) BuildRequestBody

func (g *Okx) BuildRequestBody(params interface{}) (string, *bytes.Reader, error)

func (*Okx) CancelOrder

func (g *Okx) CancelOrder(orderId string, currencyPair CurrencyPair) (bool, error)

func (*Okx) DoPost

func (p *Okx) DoPost(uri string, body io.Reader, header map[string]string) ([]byte, error)

func (*Okx) GetAccount

func (g *Okx) GetAccount() (*Account, error)

func (*Okx) GetBestTicker

func (g *Okx) GetBestTicker(currencyPair CurrencyPair) (*BestTicker, error)

func (*Okx) GetCurrencyPairs

func (g *Okx) GetCurrencyPairs() ([]CurrencyPair, error)

获取所有交易对

func (*Okx) GetDepth

func (g *Okx) GetDepth(size int, currencyPair CurrencyPair) (*Depth, error)

func (*Okx) GetExchangeName

func (g *Okx) GetExchangeName() string

func (*Okx) GetKlineRecords

func (g *Okx) GetKlineRecords(currencyPair CurrencyPair, period KlinePeriod, size int, optional ...OptionalParameter) ([]Kline, error)

func (*Okx) GetOneOrder

func (g *Okx) GetOneOrder(orderId string, currencyPair CurrencyPair) (*Order, error)

func (*Okx) GetOrderHistorys

func (g *Okx) GetOrderHistorys(currencyPair CurrencyPair, optional ...OptionalParameter) ([]Order, error)

func (*Okx) GetSubAccount

func (g *Okx) GetSubAccount(coin Currency) (*SubAccount, error)

func (*Okx) GetTicker

func (g *Okx) GetTicker(currencyPair CurrencyPair) (*Ticker, error)

func (*Okx) GetTradeFee

func (g *Okx) GetTradeFee(currencyPair CurrencyPair) (*TradeFee, error)

私有权限

func (*Okx) GetTrades

func (g *Okx) GetTrades(currencyPair CurrencyPair, size int64) ([]Trade, error)

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

func (*Okx) GetUnfinishOrders

func (g *Okx) GetUnfinishOrders(currencyPair CurrencyPair) ([]Order, error)

查询指定交易对所有挂单

func (*Okx) LimitBuy

func (g *Okx) LimitBuy(amount, price string, currencyPair CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

限价买单

func (*Okx) LimitSell

func (g *Okx) LimitSell(amount, price string, currencyPair CurrencyPair, opt ...LimitOrderOptionalParameter) (*Order, error)

func (*Okx) MarketBuy

func (g *Okx) MarketBuy(amount, price string, currencyPair CurrencyPair) (*Order, error)

func (*Okx) MarketSell

func (g *Okx) MarketSell(amount, price string, currencyPair CurrencyPair) (*Order, error)

func (*Okx) PlaceOrder

func (g *Okx) PlaceOrder(ty string, ord *Order) (*Order, error)

type OrderV5

type OrderV5 struct {
	InstId     string  `json:"instId"`
	ClOrdId    string  `json:"clOrdId"`
	OrdId      string  `json:"ordId"`
	OrdType    string  `json:"ordType"`
	Price      string  `json:"px,omitempty"`
	Size       float64 `json:"sz,string"`
	DealAmount string  `json:"accFillSz"`
	AvgPrice   string  `json:"avgPx"`
	Side       string  `json:"side"`
	State      string  `json:"state"`
	Timestamp  string  `json:"cTime"`
	UpdateTime string  `json:"uTime"`
	Fee        string  `json:"fee"`
}

type OrderV5Response

type OrderV5Response struct {
	Code int       `json:"code,string"`
	Msg  string    `json:"msg"`
	Data []OrderV5 `json:"data"`
}

type PlaceOrderReqParam

type PlaceOrderReqParam struct {
	ClOrdId string  `json:"clOrdId"`
	TdMode  string  `json:"tdMode"`
	OrdType string  `json:"ordType"`
	Side    string  `json:"side"`
	InstId  string  `json:"instId"`
	Price   float64 `json:"px"`
	Size    float64 `json:"sz"`
}

type PlaceOrderV5

type PlaceOrderV5 struct {
	ClOrdId string `json:"clOrdId"`
	OrdId   string `json:"ordId"`
	SCode   string `json:"sCode"`
	SMsg    string `json:"sMsg"`
}

type PlaceOrderV5Response

type PlaceOrderV5Response struct {
	Code int            `json:"code,string"`
	Msg  string         `json:"msg"`
	Data []PlaceOrderV5 `json:"data"`
}

type ServerResponse

type ServerResponse struct {
	Code int             `json:"code,string"`
	Msg  string          `json:"msg"`
	Data json.RawMessage `json:"data"`
}

api server response

type SpotWs

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

func NewSpotWs

func NewSpotWs(accesskey, secretkey, passphrase, proxy string) *SpotWs

func (*SpotWs) BestTickerCallback

func (s *SpotWs) BestTickerCallback(f func(ticker *gocoinex.BestTicker, exchange string))

func (*SpotWs) DepthCallback

func (s *SpotWs) DepthCallback(f func(depth *gocoinex.Depth, exchange string))

func (*SpotWs) SubscribeBestTicker

func (s *SpotWs) SubscribeBestTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeDepth

func (s *SpotWs) SubscribeDepth(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeTicker

func (s *SpotWs) SubscribeTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeTrade

func (s *SpotWs) SubscribeTrade(pair gocoinex.CurrencyPair) error

func (*SpotWs) SubscribeUserBalance

func (s *SpotWs) SubscribeUserBalance() error

func (*SpotWs) SubscribeUserOrder

func (s *SpotWs) SubscribeUserOrder() error

func (*SpotWs) TickerCallback

func (s *SpotWs) TickerCallback(f func(ticker *gocoinex.Ticker, exchange string))

func (*SpotWs) TradeCallback

func (s *SpotWs) TradeCallback(f func(trade *gocoinex.Trade, exchange string))

func (*SpotWs) UnSubscribeBestTicker

func (s *SpotWs) UnSubscribeBestTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeDepth

func (s *SpotWs) UnSubscribeDepth(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeTicker

func (s *SpotWs) UnSubscribeTicker(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeTrade

func (s *SpotWs) UnSubscribeTrade(pair gocoinex.CurrencyPair) error

func (*SpotWs) UnSubscribeUserBalance

func (s *SpotWs) UnSubscribeUserBalance() error

func (*SpotWs) UnSubscribeUserOrder

func (s *SpotWs) UnSubscribeUserOrder() error

func (*SpotWs) UserBalanceCallback

func (s *SpotWs) UserBalanceCallback(f func(trade *gocoinex.SubAccount, exchange string))

func (*SpotWs) UserOrderCallback

func (s *SpotWs) UserOrderCallback(f func(ticker *gocoinex.Order, exchange string))

type SubAccountV5

type SubAccountV5 struct {
	Ccy       string `json:"ccy"`
	Eq        string `json:"eq"`
	AvailBal  string `json:"availBal"`
	FrozenBal string `json:"frozenBal"`
}

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
}

type TickerV5Response

type TickerV5Response struct {
	Code int        `json:"code,string"`
	Msg  string     `json:"msg"`
	Data []TickerV5 `json:"data"`
}

type TradeFeeV5

type TradeFeeV5 struct {
	Timestamp int64   `json:"ts,string"`
	InstType  string  `json:"instType"`
	Level     string  `json:"level"`
	Maker     float64 `json:"maker,string"`
	Taker     float64 `json:"taker,string"`
}

type TradeFeeV5Response

type TradeFeeV5Response struct {
	Code int          `json:"code,string"`
	Msg  string       `json:"msg"`
	Data []TradeFeeV5 `json:"data"`
}

type TradeV5

type TradeV5 struct {
	Timestamp string  `json:"ts"`
	TradeId   string  `json:"tradeId"`
	Price     float64 `json:"px,string"`
	Size      float64 `json:"sz,string"`
	Side      string  `json:"side"`
	Symbol    string  `json:"instId"`
}

type TradeV5Response

type TradeV5Response struct {
	Code int       `json:"code,string"`
	Msg  string    `json:"msg"`
	Data []TradeV5 `json:"data"`
}

type WsDataResponse

type WsDataResponse struct {
	Arg  WssubscribeArgsReq `json:"arg"`
	Data json.RawMessage    `json:"data"`
	// contains filtered or unexported fields
}

websocket req struct

type WsDepthResponse

type WsDepthResponse struct {
	TimeInMilli int64       `json:"ts,string"`
	Checksum    int64       `json:"checksum"`
	PrevSeqId   int64       `json:"prevSeqId"`
	SeqId       int64       `json:"seqId"`
	Bid         [][4]string `json:"bids"`
	Ask         [][4]string `json:"asks"`
}

type WsTickerResponse

type WsTickerResponse struct {
	InstId    string  `json:"instId"`
	Last      float64 `json:"last,string"`
	LastSz    float64 `json:"lastSz,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
}

type WsTradeResponse

type WsTradeResponse struct {
	InstId  string  `json:"instId"`
	TradeId string  `json:"tradeId"`
	Date    string  `json:"ts"`
	Side    string  `json:"side"`
	Amount  float64 `json:"sz,string"`
	Price   float64 `json:"px,string"`
}

type WssubscribeArgsReq

type WssubscribeArgsReq struct {
	Channel    string `json:"channel"`
	InstType   string `json:"instType,omitempty"`
	InstFamily string `json:"instFamily,omitempty"` //适用于交割/永续/期权
	InstId     string `json:"instId"`
}

websocket req struct

type WssubscribeReq

type WssubscribeReq struct {
	Op   string               `json:"op"`
	Args []WssubscribeArgsReq `json:"args"`
}

websocket req struct

type WssubscribeResponse

type WssubscribeResponse struct {
	Event   string             `json:"event"`
	Code    string             `json:"code"`
	Message string             `json:"msg"`
	Arg     WssubscribeArgsReq `json:"arg"`
	ConnId  string             `json:"connId"`
}

Jump to

Keyboard shortcuts

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