kucoin

package
v1.39.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: AGPL-3.0 Imports: 19 Imported by: 2

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

View Source
const KCS = "KCS"

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

Variables

View Source
var ErrMissingSequence = errors.New("sequence is missing")

Functions

This section is empty.

Types

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) (errs error)

func (*Exchange) IsSupportedInterval

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

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

func (*Exchange) QueryDepth

func (e *Exchange) QueryDepth(ctx context.Context, symbol string) (types.SliceOrderBook, int64, error)

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)

QueryOpenOrders

Documentation from the Kucoin API page

Any order on the exchange order book is in active status. Orders removed from the order book will be marked with done status. After an order becomes done, there may be a few milliseconds latency before it’s fully settled.

You can check the orders in any status. If the status parameter is not specified, orders of done status will be returned by default.

When you query orders in active status, there is no time limit. However, when you query orders in done status, the start and end time range cannot exceed 7* 24 hours. An error will occur if the specified time window exceeds the range.

If you specify the end time only, the system will automatically calculate the start time as end time minus 7*24 hours, and vice versa.

The history for cancelled orders is only kept for one month. You will not be able to query for cancelled orders that have happened more than a month ago.

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

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

func (*Exchange) SubmitOrders

func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error)

func (*Exchange) SupportedInterval

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 *kucoinapi.RestClient, ex *Exchange) *Stream

func (*Stream) EmitAccountBalanceEvent

func (s *Stream) EmitAccountBalanceEvent(e *WebSocketAccountBalanceEvent)

func (*Stream) EmitCandleEvent

func (s *Stream) EmitCandleEvent(candle *WebSocketCandleEvent, e *WebSocketEvent)

func (*Stream) EmitOrderBookL2Event

func (s *Stream) EmitOrderBookL2Event(e *WebSocketOrderBookL2Event)

func (*Stream) EmitPrivateOrderEvent

func (s *Stream) EmitPrivateOrderEvent(e *WebSocketPrivateOrderEvent)

func (*Stream) EmitTickerEvent

func (s *Stream) EmitTickerEvent(e *WebSocketTickerEvent)

func (*Stream) OnAccountBalanceEvent

func (s *Stream) OnAccountBalanceEvent(cb func(e *WebSocketAccountBalanceEvent))

func (*Stream) OnCandleEvent

func (s *Stream) OnCandleEvent(cb func(candle *WebSocketCandleEvent, e *WebSocketEvent))

func (*Stream) OnOrderBookL2Event

func (s *Stream) OnOrderBookL2Event(cb func(e *WebSocketOrderBookL2Event))

func (*Stream) OnPrivateOrderEvent

func (s *Stream) OnPrivateOrderEvent(cb func(e *WebSocketPrivateOrderEvent))

func (*Stream) OnTickerEvent

func (s *Stream) OnTickerEvent(cb func(e *WebSocketTickerEvent))

type StreamEventHub

type StreamEventHub interface {
	OnCandleEvent(cb func(candle *WebSocketCandleEvent, e *WebSocketEvent))

	OnOrderBookL2Event(cb func(e *WebSocketOrderBookL2Event))

	OnTickerEvent(cb func(e *WebSocketTickerEvent))

	OnAccountBalanceEvent(cb func(e *WebSocketAccountBalanceEvent))

	OnPrivateOrderEvent(cb func(e *WebSocketPrivateOrderEvent))
}

type WebSocketAccountBalanceEvent

type WebSocketAccountBalanceEvent struct {
	Total           fixedpoint.Value `json:"total"`
	Available       fixedpoint.Value `json:"available"`
	AvailableChange fixedpoint.Value `json:"availableChange"`
	Currency        string           `json:"currency"`
	Hold            fixedpoint.Value `json:"hold"`
	HoldChange      fixedpoint.Value `json:"holdChange"`
	RelationEvent   string           `json:"relationEvent"`
	RelationEventId string           `json:"relationEventId"`
	RelationContext struct {
		Symbol  string `json:"symbol"`
		TradeId string `json:"tradeId"`
		OrderId string `json:"orderId"`
	} `json:"relationContext"`
	Time string `json:"time"`
}

type WebSocketCandleEvent

type WebSocketCandleEvent struct {
	Symbol  string                     `json:"symbol"`
	Candles []string                   `json:"candles"`
	Time    types.MillisecondTimestamp `json:"time"`

	// Interval is an injected field (not from the payload)
	Interval types.Interval

	// Is a new candle or not
	Add bool
}

func (*WebSocketCandleEvent) KLine

func (e *WebSocketCandleEvent) KLine() types.KLine

type WebSocketCommand

type WebSocketCommand struct {
	Id             int64                `json:"id"`
	Type           WebSocketMessageType `json:"type"`
	Topic          string               `json:"topic"`
	PrivateChannel bool                 `json:"privateChannel"`
	Response       bool                 `json:"response"`
}

func (*WebSocketCommand) JSON

func (c *WebSocketCommand) JSON() ([]byte, error)

type WebSocketConnector

type WebSocketConnector interface {
	Conn() *websocket.Conn
	Reconnect()
}

type WebSocketEvent

type WebSocketEvent struct {
	Type    WebSocketMessageType `json:"type"`
	Topic   string               `json:"topic"`
	Subject WebSocketSubject     `json:"subject"`
	Data    json.RawMessage      `json:"data"`
	Code    int                  `json:"code"` // used in type error

	// Object is used for storing the parsed Data
	Object interface{} `json:"-"`
}

type WebSocketMessageType

type WebSocketMessageType string
const (
	WebSocketMessageTypePing        WebSocketMessageType = "ping"
	WebSocketMessageTypeSubscribe   WebSocketMessageType = "subscribe"
	WebSocketMessageTypeUnsubscribe WebSocketMessageType = "unsubscribe"
	WebSocketMessageTypeAck         WebSocketMessageType = "ack"
	WebSocketMessageTypeError       WebSocketMessageType = "error"
	WebSocketMessageTypePong        WebSocketMessageType = "pong"
	WebSocketMessageTypeWelcome     WebSocketMessageType = "welcome"
	WebSocketMessageTypeMessage     WebSocketMessageType = "message"
)

type WebSocketOrderBookL2Event

type WebSocketOrderBookL2Event struct {
	SequenceStart int64  `json:"sequenceStart"`
	SequenceEnd   int64  `json:"sequenceEnd"`
	Symbol        string `json:"symbol"`
	Changes       struct {
		Asks types.PriceVolumeSlice `json:"asks"`
		Bids types.PriceVolumeSlice `json:"bids"`
	} `json:"changes"`
}

type WebSocketPrivateOrderEvent

type WebSocketPrivateOrderEvent struct {
	OrderId    string                    `json:"orderId"`
	TradeId    string                    `json:"tradeId"`
	Symbol     string                    `json:"symbol"`
	OrderType  string                    `json:"orderType"`
	Side       string                    `json:"side"`
	Type       string                    `json:"type"`
	OrderTime  types.NanosecondTimestamp `json:"orderTime"`
	Price      fixedpoint.Value          `json:"price"`
	Size       fixedpoint.Value          `json:"size"`
	FilledSize fixedpoint.Value          `json:"filledSize"`
	RemainSize fixedpoint.Value          `json:"remainSize"`

	Liquidity  string                     `json:"liquidity"`
	MatchPrice fixedpoint.Value           `json:"matchPrice"`
	MatchSize  fixedpoint.Value           `json:"matchSize"`
	ClientOid  string                     `json:"clientOid"`
	Status     string                     `json:"status"`
	Ts         types.MillisecondTimestamp `json:"ts"`
}

type WebSocketSubject

type WebSocketSubject string
const (
	WebSocketSubjectTradeTicker        WebSocketSubject = "trade.ticker"
	WebSocketSubjectTradeSnapshot      WebSocketSubject = "trade.snapshot" // ticker snapshot
	WebSocketSubjectTradeL2Update      WebSocketSubject = "trade.l2update" // order book L2
	WebSocketSubjectLevel2             WebSocketSubject = "level2"         // level2
	WebSocketSubjectTradeCandlesUpdate WebSocketSubject = "trade.candles.update"
	WebSocketSubjectTradeCandlesAdd    WebSocketSubject = "trade.candles.add"

	// private subjects
	WebSocketSubjectOrderChange    WebSocketSubject = "orderChange"
	WebSocketSubjectAccountBalance WebSocketSubject = "account.balance"
	WebSocketSubjectStopOrder      WebSocketSubject = "stopOrder"
)

type WebSocketTickerEvent

type WebSocketTickerEvent struct {
	Sequence    string           `json:"sequence"`
	Price       fixedpoint.Value `json:"price"`
	Size        fixedpoint.Value `json:"size"`
	BestAsk     fixedpoint.Value `json:"bestAsk"`
	BestAskSize fixedpoint.Value `json:"bestAskSize"`
	BestBid     fixedpoint.Value `json:"bestBid"`
	BestBidSize fixedpoint.Value `json:"bestBidSize"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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