ws

package
v0.0.0-...-1820ca8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PingPeriod = (pongWait * 8) / 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientWs

type ClientWs struct {
	Cancel              context.CancelFunc
	DoneChan            chan interface{}
	StructuredEventChan chan interface{}
	RawEventChan        chan *events.Basic
	ErrChan             chan *events.Error
	SubscribeChan       chan *events.Subscribe
	UnsubscribeCh       chan *events.Unsubscribe
	LoginChan           chan *events.Login
	SuccessChan         chan *events.Success

	AuthRequested *time.Time
	Authorized    bool
	Private       *Private
	Public        *Public
	Trade         *Trade
	// contains filtered or unexported fields
}

ClientWs is the websocket api client

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

func NewClient

func NewClient(ctx context.Context, apiKey, secretKey, passphrase string, url map[bool]okex.BaseURL) *ClientWs

NewClient returns a pointer to a fresh ClientWs

func (*ClientWs) Connect

func (c *ClientWs) Connect(p bool) error

Connect into the server

https://www.okex.com/docs-v5/en/#websocket-api-connect

func (*ClientWs) Send

func (c *ClientWs) Send(p bool, op okex.Operation, args []map[string]string, extras ...map[string]string) error

Send message through either connections

func (*ClientWs) SetChannels

func (c *ClientWs) SetChannels(errCh chan *events.Error, subCh chan *events.Subscribe, unSub chan *events.Unsubscribe, lCh chan *events.Login, sCh chan *events.Success)

SetChannels to receive certain events on separate channel

func (*ClientWs) Subscribe

func (c *ClientWs) Subscribe(p bool, ch []okex.ChannelName, args map[string]string) error

Subscribe Users can choose to subscribe to one or more channels, and the total length of multiple channels cannot exceed 4096 bytes.

https://www.okex.com/docs-v5/en/#websocket-api-subscribe

func (*ClientWs) Unsubscribe

func (c *ClientWs) Unsubscribe(p bool, ch []okex.ChannelName, args map[string]string) error

Unsubscribe into channel(s)

https://www.okex.com/docs-v5/en/#websocket-api-unsubscribe

func (*ClientWs) WaitForAuthorization

func (c *ClientWs) WaitForAuthorization() error

WaitForAuthorization waits for the auth response and try to log in if it was needed

type Private

type Private struct {
	*ClientWs
	// contains filtered or unexported fields
}

Private

https://www.okex.com/docs-v5/en/#websocket-api-private-channel

func NewPrivate

func NewPrivate(c *ClientWs) *Private

NewPrivate returns a pointer to a fresh Private

func (*Private) Account

func (c *Private) Account(req requests.Account, ch ...chan *private.Account) error

Account Retrieve account information. Data will be pushed when triggered by events such as placing/canceling order, and will also be pushed in regular interval according to subscription granularity.

https://www.okex.com/docs-v5/en/#websocket-api-private-channel-account-channel

func (*Private) BalanceAndPosition

func (c *Private) BalanceAndPosition(ch ...chan *private.BalanceAndPosition) error

BalanceAndPosition Retrieve account balance and position information. Data will be pushed when triggered by events such as filled order, funding transfer.

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

func (*Private) Order

func (c *Private) Order(req requests.Order, ch ...chan *private.Order) error

Order Retrieve position information. Initial snapshot will be pushed according to subscription granularity. Data will be pushed when triggered by events such as placing/canceling order, and will also be pushed in regular interval according to subscription granularity.

https://www.okex.com/docs-v5/en/#websocket-api-private-channel-order-channel

func (*Private) Position

func (c *Private) Position(req requests.Position, ch ...chan *private.Position) error

Position Retrieve position information. Initial snapshot will be pushed according to subscription granularity. Data will be pushed when triggered by events such as placing/canceling order, and will also be pushed in regular interval according to subscription granularity.

https://www.okex.com/docs-v5/en/#websocket-api-private-channel-positions-channel

func (*Private) Process

func (c *Private) Process(data []byte, e *events.Basic) bool

func (*Private) UBalanceAndPosition

func (c *Private) UBalanceAndPosition(rCh ...bool) error

UBalanceAndPosition unsubscribes a position channel

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

type Public

type Public struct {
	*ClientWs
	// contains filtered or unexported fields
}

Public

https://www.okex.com/docs-v5/en/#websocket-api-public-channels

func NewPublic

func NewPublic(c *ClientWs) *Public

NewPublic returns a pointer to a fresh Public

func (*Public) Candlesticks

func (c *Public) Candlesticks(req requests.Candlesticks, ch ...chan *public.Candlesticks) error

Candlesticks Retrieve the open interest. Data will by pushed every 3 seconds.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-candlesticks-channel

func (*Public) EstimatedDeliveryExercisePrice

func (c *Public) EstimatedDeliveryExercisePrice(req requests.EstimatedDeliveryExercisePrice, ch ...chan *public.EstimatedDeliveryExercisePrice) error

EstimatedDeliveryExercisePrice Retrieve the estimated delivery/exercise price of FUTURES contracts and OPTION.

Only the estimated delivery/exercise price will be pushed an hour before delivery/exercise, and will be pushed if there is any price change.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-estimated-delivery-exercise-price-channel

func (*Public) FundingRate

func (c *Public) FundingRate(req requests.FundingRate, ch ...chan *public.FundingRate) error

FundingRate Retrieve funding rate. Data will be pushed every minute.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-funding-rate-channel

func (*Public) IndexCandlesticks

func (c *Public) IndexCandlesticks(req requests.IndexCandlesticks, ch ...chan *public.IndexCandlesticks) error

IndexCandlesticks Retrieve the candlesticks data of the index. Data will be pushed every 500 ms.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-index-candlesticks-channel

func (*Public) IndexTickers

func (c *Public) IndexTickers(req requests.IndexTickers, ch ...chan *public.IndexTickers) error

IndexTickers Retrieve index tickers data

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-index-tickers-channel

func (*Public) Instruments

func (c *Public) Instruments(req requests.Instruments, ch ...chan *public.Instruments) error

Instruments The full instrument list will be pushed for the first time after subscription. Subsequently, the instruments will be pushed if there's any change to the instrument’s state (such as delivery of FUTURES, exercise of OPTION, listing of new contracts / trading pairs, trading suspension, etc.).

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

func (*Public) MarkPrice

func (c *Public) MarkPrice(req requests.MarkPrice, ch ...chan *public.MarkPrice) error

MarkPrice Retrieve the mark price. Data will be pushed every 200 ms when the mark price changes, and will be pushed every 10 seconds when the mark price does not change.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-mark-price-channel

func (*Public) MarkPriceCandlesticks

func (c *Public) MarkPriceCandlesticks(req requests.MarkPriceCandlesticks, ch ...chan *public.MarkPriceCandlesticks) error

MarkPriceCandlesticks Retrieve the candlesticks data of the mark price. Data will be pushed every 500 ms.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-mark-price-candlesticks-channel

func (*Public) OPTIONSummary

func (c *Public) OPTIONSummary(req requests.OPTIONSummary, ch ...chan *public.OPTIONSummary) error

OPTIONSummary Retrieve detailed pricing information of all OPTION contracts. Data will be pushed at once.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-option-summary-channel

func (*Public) OpenInterest

func (c *Public) OpenInterest(req requests.OpenInterest, ch ...chan *public.OpenInterest) error

OpenInterest Retrieve the open interest. Data will by pushed every 3 seconds.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-open-interest-channel

func (*Public) OrderBook

func (c *Public) OrderBook(req requests.OrderBook, ch ...chan *public.OrderBook) error

OrderBook Retrieve order book data.

Use books for 400 depth levels, book5 for 5 depth levels, books50-l2-tbt tick-by-tick 50 depth levels, and books-l2-tbt for tick-by-tick 400 depth levels.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-order-book-channel

func (*Public) PriceLimit

func (c *Public) PriceLimit(req requests.PriceLimit, ch ...chan *public.PriceLimit) error

PriceLimit Retrieve the maximum buy price and minimum sell price of the instrument. Data will be pushed every 5 seconds when there are changes in limits, and will not be pushed when there is no changes on limit.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-price-limit-channel

func (*Public) Process

func (c *Public) Process(data []byte, e *events.Basic) bool

func (*Public) Tickers

func (c *Public) Tickers(req requests.Tickers, ch ...chan *public.Tickers) error

Tickers Retrieve the last traded price, bid price, ask price and 24-hour trading volume of instruments. Data will be pushed every 100 ms.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-tickers-channel

func (*Public) Trades

func (c *Public) Trades(req requests.Trades, ch ...chan *public.Trades) error

Trades Retrieve the recent trades data. Data will be pushed whenever there is a trade.

https://www.okex.com/docs-v5/en/#websocket-api-public-channels-trades-channel

type Trade

type Trade struct {
	*ClientWs
}

Trade

https://www.okex.com/docs-v5/en/#websocket-api-trade

func NewTrade

func NewTrade(c *ClientWs) *Trade

NewTrade returns a pointer to a fresh Trade

func (*Trade) AmendOrder

func (c *Trade) AmendOrder(req ...requests.AmendOrder) error

AmendOrder Amend an incomplete order.

https://www.okex.com/docs-v5/en/#websocket-api-trade-place-order

Amend incomplete orders in batches. Maximum 20 orders can be amended at a time.

https://www.okex.com/docs-v5/en/#websocket-api-trade-amend-multiple-orders

func (*Trade) CancelOrder

func (c *Trade) CancelOrder(req ...requests.CancelOrder) error

CancelOrder Cancel an incomplete order

https://www.okex.com/docs-v5/en/#websocket-api-trade-place-order

Cancel incomplete orders in batches. Maximum 20 orders can be canceled at a time.

https://www.okex.com/docs-v5/en/#websocket-api-trade-cancel-multiple-orders

func (*Trade) PlaceOrder

func (c *Trade) PlaceOrder(req ...requests.PlaceOrder) error

PlaceOrder You can place an order only if you have sufficient funds.

https://www.okex.com/docs-v5/en/#websocket-api-trade-place-order

Place orders in a batch. Maximum 20 orders can be placed at a time

https://www.okex.com/docs-v5/en/#websocket-api-trade-place-multiple-orders

Jump to

Keyboard shortcuts

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