ws

package
v0.0.0-...-eb36ede Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostPublicWebSocket     = "wss://ws.okx.com:8443/ws/v5/public"
	HostPrivateWebSocket    = "wss://ws.okx.com:8443/ws/v5/private"
	HostPublicWebSocketAWS  = "wss://wsaws.okx.com:8443/ws/v5/public"
	HostPrivateWebSocketAWS = "wss://wsaws.okx.com:8443/ws/v5/private"
)
View Source
const (
	ChannelBalanceAndPosition = "balance_and_position"
	ChannelRfqs               = "rfqs"
	ChannelQuotes             = "quotes"
	ChannelTicker             = "tickers"
	ChannelOptSummary         = "opt-summary"
	ChannelAccount            = "account"
	ChannelAccountGreeks      = "account-greeks"
	ChannelGridPositions      = "grid-positions"
	ChannelGridSubOrders      = "grid-sub-orders"
	ChannelLiquidationWarning = "liquidation-warning"
	ChannelGridOrdersSpot     = "grid-orders-spot"
	ChannelGridOrdersContract = "grid-orders-contract"
	ChannelGridOrdersMoon     = "grid-orders-moon"
	ChannelAlgoAdvance        = "algo-advance"
	ChannelEstimatedPrice     = "estimated-price"
	ChannelPositions          = "positions"
	ChannelOrders             = "orders"
	ChannelOrdersAlgo         = "orders-algo"
)
View Source
const (
	InstTypeSpot    = "SPOT"
	InstTypeMargin  = "MARGIN"
	InstTypeSwap    = "SWAP"
	InstTypeFutures = "FUTURES"
	InstTypeOption  = "OPTION"
	InstTypeAny     = "ANY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgsAuth

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

type ArgsCmd

type ArgsCmd struct {
	Channel  string `json:"channel"`
	InstType string `json:"instType"`
	Uly      string `json:"uly"`
	InstID   string `json:"instId"`
	Ccy      string `json:"ccy"`
	AlgoId   string `json:"algoId"`
}

type Auth

type Auth struct {
	Op   string     `json:"op"`
	Args []ArgsAuth `json:"args"`
}

https://www.okx.com/docs-v5/en/#websocket-api-login

type Cmd

type Cmd struct {
	Op   string    `json:"op"`
	Args []ArgsCmd `json:"args"`
}

Необходим для удобного создания подписо

type Configuration

type Configuration struct {
	Addr           string `json:"addr"`
	ApiKey         string `json:"api_key"`
	SecretKey      string `json:"secret_key"`
	APIKeyPassword string `json:"passphrase"`
	DebugMode      bool   `json:"debug_mode"`
}

type OKXWS

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

func New

func New(config *Configuration) *OKXWS

func (*OKXWS) Auth

func (b *OKXWS) Auth()

Необходим для приватных каналов

func (*OKXWS) Emit

func (b *OKXWS) Emit(event interface{}, arguments ...interface{}) *emission.Emitter

Emit emits an event

func (*OKXWS) GetPair

func (b *OKXWS) GetPair(args ...string) string

func (*OKXWS) Off

func (b *OKXWS) Off(event interface{}, listener interface{}) *emission.Emitter

Off removes a listener for an event

func (*OKXWS) On

func (b *OKXWS) On(event interface{}, listener interface{}) *emission.Emitter

On adds a listener to a specific event

func (*OKXWS) Send

func (b *OKXWS) Send(msg string) (err error)

func (*OKXWS) SendCmd

func (b *OKXWS) SendCmd(cmd Cmd)

отправка команды на сервер в отдельной функции для того, чтобы при переподключении быстро подписаться на все предыдущие каналы

func (*OKXWS) Start

func (b *OKXWS) Start() error

подключение к серверу и постоянное чтение приходящих ответов

func (*OKXWS) Subscribe

func (b *OKXWS) Subscribe(channel string, args []string)

func (*OKXWS) Subscribe1

func (b *OKXWS) Subscribe1(channel string)

подписка только с channel

func (*OKXWS) Subscribe2

func (b *OKXWS) Subscribe2(channel string, secondArg string)

подписка c 2 аргументами

func (*OKXWS) Subscribe3

func (b *OKXWS) Subscribe3(channel string, InstType string, arg2 string)

подписка с тремя аргументами

func (*OKXWS) Subscribe4

func (b *OKXWS) Subscribe4(channel string, arg1 string, arg2 string, arg3 string)

подписка с четырьмя аргументами

type Tickers

type Tickers struct {
	Arg  argTickers    `json:"arg"`
	Data []dataTickers `json:"data"`
}

https://www.okx.com/docs-v5/en/#websocket-api-public-channel-instruments-channel

type WalletBalance

type WalletBalance struct {
	Arg  argWalletBalance    `json:"arg"`
	Data []dataWalletBalance `json:"data"`
}

https://www.okx.com/docs-v5/en/#websocket-api-private-channel-balance-and-position-channel

Jump to

Keyboard shortcuts

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