okex

package
v1.55.4 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: AGPL-3.0 Imports: 16 Imported by: 2

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

View Source
const ID = "okex"
View Source
const PlatformToken = "OKB"

PlatformToken is the platform currency of OKEx, pre-allocate static string here

Variables

View Source
var (
	// below are supported UTC timezone interval for okex
	SupportedIntervals = map[types.Interval]int{
		types.Interval1m:  1 * 60,
		types.Interval3m:  3 * 60,
		types.Interval5m:  5 * 60,
		types.Interval15m: 15 * 60,
		types.Interval30m: 30 * 60,
		types.Interval1h:  60 * 60,
		types.Interval2h:  60 * 60 * 2,
		types.Interval4h:  60 * 60 * 4,
		types.Interval6h:  60 * 60 * 6,
		types.Interval12h: 60 * 60 * 12,
		types.Interval1d:  60 * 60 * 24,
		types.Interval3d:  60 * 60 * 24 * 3,
		types.Interval1w:  60 * 60 * 24 * 7,
		types.Interval1mo: 60 * 60 * 24 * 30,
	}

	ToLocalInterval = map[types.Interval]string{
		types.Interval1m:  "1m",
		types.Interval3m:  "3m",
		types.Interval5m:  "5m",
		types.Interval15m: "15m",
		types.Interval30m: "30m",
		types.Interval1h:  "1H",
		types.Interval2h:  "2H",
		types.Interval4h:  "4H",
		types.Interval6h:  "6Hutc",
		types.Interval12h: "12Hutc",
		types.Interval1d:  "1Dutc",
		types.Interval3d:  "3Dutc",
		types.Interval1w:  "1Wutc",
		types.Interval1mo: "1Mutc",
	}
)
View Source
var CandleChannels = []string{
	"candle1Y",
	"candle6M", "candle3M", "candle1M",
	"candle1W",
	"candle1D", "candle2D", "candle3D", "candle5D",
	"candle12H", "candle6H", "candle4H", "candle2H", "candle1H",
	"candle30m", "candle15m", "candle5m", "candle3m", "candle1m",
}
View Source
var ErrSymbolRequired = errors.New("symbol is a required parameter")

Functions

This section is empty.

Types

type BookEntry

type BookEntry struct {
	Price         fixedpoint.Value
	Volume        fixedpoint.Value
	NumLiquidated int
	NumOrders     int
}

type BookEvent added in v1.23.0

type BookEvent struct {
	InstrumentID         string
	Symbol               string
	Action               string
	Bids                 []BookEntry
	Asks                 []BookEntry
	MillisecondTimestamp int64
	Checksum             int
	// contains filtered or unexported fields
}

func (*BookEvent) Book added in v1.23.0

func (data *BookEvent) Book() types.SliceOrderBook

func (*BookEvent) BookTicker added in v1.23.0

func (data *BookEvent) BookTicker() types.BookTicker

type Candle

type Candle struct {
	Channel      string
	InstrumentID string
	Symbol       string
	Interval     string
	Open         fixedpoint.Value
	High         fixedpoint.Value
	Low          fixedpoint.Value
	Close        fixedpoint.Value

	// Trading volume, with a unit of contact.
	// If it is a derivatives contract, the value is the number of contracts.
	// If it is SPOT/MARGIN, the value is the amount of trading currency.
	Volume fixedpoint.Value

	// Trading volume, with a unit of currency.
	// If it is a derivatives contract, the value is the number of settlement currency.
	// If it is SPOT/MARGIN, the value is the number of quote currency.
	VolumeInCurrency fixedpoint.Value

	MillisecondTimestamp int64

	StartTime time.Time
}

func (*Candle) KLine

func (c *Candle) KLine() types.KLine

type CandleKey

type CandleKey struct {
	InstrumentID string
	Channel      string
}

type Exchange

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

func New

func New(key, secret, passphrase string) *Exchange

func (*Exchange) CancelOrders

func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) error

func (*Exchange) IsSupportedInterval added in v1.53.0

func (e *Exchange) IsSupportedInterval(interval types.Interval) bool

func (*Exchange) Name

func (e *Exchange) Name() types.ExchangeName

func (*Exchange) NewStream

func (e *Exchange) NewStream() types.Stream

func (*Exchange) PlatformFeeCurrency

func (e *Exchange) PlatformFeeCurrency() string

func (*Exchange) QueryAccount

func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error)

func (*Exchange) QueryAccountBalances

func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error)

func (*Exchange) QueryClosedOrders added in v1.53.0

func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) ([]types.Order, error)

QueryClosedOrders can query closed orders in last 3 months, there are no time interval limitations, as long as until >= since. Please Use lastOrderID as cursor, only return orders later than that order, that order is not included. If you want to query orders by time range, please just pass since and until. If you want to query by cursor, please pass lastOrderID. Because it gets the correct response even when you pass all parameters with the right time interval and invalid lastOrderID, like 0. Time interval boundary unit is second. since is inclusive, ex. order created in 1694155903, get response if query since 1694155903, get empty if query since 1694155904 until is not inclusive, ex. order created in 1694155903, get response if query until 1694155904, get empty if query until 1694155903

func (*Exchange) QueryKLines

func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions) ([]types.KLine, error)

func (*Exchange) QueryMarkets

func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error)

func (*Exchange) QueryOpenOrders

func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error)

func (*Exchange) QueryOrder added in v1.52.0

func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error)

func (*Exchange) QueryOrderTrades added in v1.52.0

func (e *Exchange) QueryOrderTrades(ctx context.Context, q types.OrderQuery) ([]types.Trade, error)

Query order trades can query trades in last 3 months.

func (*Exchange) QueryTicker

func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error)

func (*Exchange) QueryTickers

func (e *Exchange) QueryTickers(ctx context.Context, symbols ...string) (map[string]types.Ticker, error)

func (*Exchange) QueryTrades added in v1.53.0

func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) ([]types.Trade, error)

QueryTrades can query trades in last 3 months, there are no time interval limitations, as long as end_time >= start_time. OKEX do not provide api to query by tradeID, So use /api/v5/trade/orders-history-archive as its official site do. If you want to query trades by time range, please just pass start_time and end_time. Because it gets the correct response even when you pass all parameters with the right time interval and invalid LastTradeID, like 0. No matter how you pass parameter, QueryTrades return descending order. If you query time period 3 months earlier with start time and end time, will return [] empty slice But If you query time period 3 months earlier JUST with start time, will return like start with 3 months ago.

func (*Exchange) SubmitOrder added in v1.40.3

func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (*types.Order, error)

func (*Exchange) SupportedInterval added in v1.53.0

func (e *Exchange) SupportedInterval() map[types.Interval]int

type Stream

type Stream struct {
	types.StandardStream
	// contains filtered or unexported fields
}

func NewStream

func NewStream(client *okexapi.RestClient) *Stream

func (*Stream) EmitAccountEvent added in v1.23.0

func (s *Stream) EmitAccountEvent(account okexapi.Account)

func (*Stream) EmitBookEvent added in v1.23.0

func (s *Stream) EmitBookEvent(book BookEvent)

func (*Stream) EmitCandleEvent added in v1.23.0

func (s *Stream) EmitCandleEvent(candle Candle)

func (*Stream) EmitEvent

func (s *Stream) EmitEvent(event WebSocketEvent)

func (*Stream) EmitOrderDetailsEvent added in v1.23.0

func (s *Stream) EmitOrderDetailsEvent(orderDetails []okexapi.OrderDetails)

func (*Stream) OnAccountEvent added in v1.23.0

func (s *Stream) OnAccountEvent(cb func(account okexapi.Account))

func (*Stream) OnBookEvent added in v1.23.0

func (s *Stream) OnBookEvent(cb func(book BookEvent))

func (*Stream) OnCandleEvent added in v1.23.0

func (s *Stream) OnCandleEvent(cb func(candle Candle))

func (*Stream) OnEvent

func (s *Stream) OnEvent(cb func(event WebSocketEvent))

func (*Stream) OnOrderDetailsEvent added in v1.23.0

func (s *Stream) OnOrderDetailsEvent(cb func(orderDetails []okexapi.OrderDetails))

type StreamEventHub

type StreamEventHub interface {
	OnCandleEvent(cb func(candle Candle))

	OnBookEvent(cb func(book BookEvent))

	OnEvent(cb func(event WebSocketEvent))

	OnAccountEvent(cb func(account okexapi.Account))

	OnOrderDetailsEvent(cb func(orderDetails []okexapi.OrderDetails))
}

type WebSocketEvent

type WebSocketEvent struct {
	Event   string      `json:"event"`
	Code    string      `json:"code,omitempty"`
	Message string      `json:"msg,omitempty"`
	Arg     interface{} `json:"arg,omitempty"`
}

type WebsocketLogin

type WebsocketLogin struct {
	Key        string `json:"apiKey"`
	Passphrase string `json:"passphrase"`
	Timestamp  string `json:"timestamp"`
	Sign       string `json:"sign"`
}

type WebsocketOp

type WebsocketOp struct {
	Op   string      `json:"op"`
	Args interface{} `json:"args"`
}

type WebsocketSubscription

type WebsocketSubscription struct {
	Channel        string `json:"channel"`
	InstrumentID   string `json:"instId,omitempty"`
	InstrumentType string `json:"instType,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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