Documentation ¶
Index ¶
- Constants
- type ClientWs
- func (c *ClientWs) Connect(p bool) error
- func (c *ClientWs) Login() error
- func (c *ClientWs) Send(p bool, op okex.Operation, args []map[string]string, ...) error
- func (c *ClientWs) SetChannels(errCh chan *events.Error, subCh chan *events.Subscribe, ...)
- func (c *ClientWs) Subscribe(p bool, ch []okex.ChannelName, args map[string]string) error
- func (c *ClientWs) Unsubscribe(p bool, ch []okex.ChannelName, args map[string]string) error
- func (c *ClientWs) WaitForAuthorization() error
- type Private
- func (c *Private) Account(req requests.Account, ch ...chan *private.Account) error
- func (c *Private) BalanceAndPosition(ch ...chan *private.BalanceAndPosition) error
- func (c *Private) Order(req requests.Order, ch ...chan *private.Order) error
- func (c *Private) Position(req requests.Position, ch ...chan *private.Position) error
- func (c *Private) Process(data []byte, e *events.Basic) bool
- func (c *Private) UAccount(req requests.Account, rCh ...bool) error
- func (c *Private) UBalanceAndPosition(rCh ...bool) error
- func (c *Private) UOrder(req requests.Order, rCh ...bool) error
- func (c *Private) UPosition(req requests.Position, rCh ...bool) error
- type Public
- func (c *Public) Candlesticks(req requests.Candlesticks, ch ...chan *public.Candlesticks) error
- func (c *Public) EstimatedDeliveryExercisePrice(req requests.EstimatedDeliveryExercisePrice, ...) error
- func (c *Public) FundingRate(req requests.FundingRate, ch ...chan *public.FundingRate) error
- func (c *Public) IndexCandlesticks(req requests.IndexCandlesticks, ch ...chan *public.IndexCandlesticks) error
- func (c *Public) IndexTickers(req requests.IndexTickers, ch ...chan *public.IndexTickers) error
- func (c *Public) Instruments(req requests.Instruments, ch ...chan *public.Instruments) error
- func (c *Public) MarkPrice(req requests.MarkPrice, ch ...chan *public.MarkPrice) error
- func (c *Public) MarkPriceCandlesticks(req requests.MarkPriceCandlesticks, ch ...chan *public.MarkPriceCandlesticks) error
- func (c *Public) OPTIONSummary(req requests.OPTIONSummary, ch ...chan *public.OPTIONSummary) error
- func (c *Public) OpenInterest(req requests.OpenInterest, ch ...chan *public.OpenInterest) error
- func (c *Public) OrderBook(req requests.OrderBook, ch ...chan *public.OrderBook) error
- func (c *Public) PriceLimit(req requests.PriceLimit, ch ...chan *public.PriceLimit) error
- func (c *Public) Process(data []byte, e *events.Basic) bool
- func (c *Public) Tickers(req requests.Tickers, ch ...chan *public.Tickers) error
- func (c *Public) Trades(req requests.Trades, ch ...chan *public.Trades) error
- func (c *Public) UCandlesticks(req requests.Candlesticks, rCh ...bool) error
- func (c *Public) UEstimatedDeliveryExercisePrice(req requests.EstimatedDeliveryExercisePrice, rCh ...bool) error
- func (c *Public) UFundingRate(req requests.FundingRate, rCh ...bool) error
- func (c *Public) UIndexCandlesticks(req requests.IndexCandlesticks, rCh ...bool) error
- func (c *Public) UIndexTickers(req requests.IndexTickers, rCh ...bool) error
- func (c *Public) UInstruments(req requests.Instruments, rCh ...bool) error
- func (c *Public) UMarkPrice(req requests.MarkPrice, rCh ...bool) error
- func (c *Public) UMarkPriceCandlesticks(req requests.MarkPriceCandlesticks, rCh ...bool) error
- func (c *Public) UOPTIONSummary(req requests.OPTIONSummary, rCh ...bool) error
- func (c *Public) UOpenInterest(req requests.OpenInterest, rCh ...bool) error
- func (c *Public) UOrderBook(req requests.OrderBook, rCh ...bool) error
- func (c *Public) UPriceLimit(req requests.PriceLimit, rCh ...bool) error
- func (c *Public) UTickers(req requests.Tickers, rCh ...bool) error
- func (c *Public) UTrades(req requests.Trades, rCh ...bool) error
- type Trade
Constants ¶
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) 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 ¶
Subscribe Users can choose to subscribe to one or more channels, and the total length of multiple channels cannot exceed 4096 bytes.
func (*ClientWs) Unsubscribe ¶
Unsubscribe into channel(s)
func (*ClientWs) WaitForAuthorization ¶
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 ¶
NewPrivate returns a pointer to a fresh Private
func (*Private) Account ¶
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 ¶
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 ¶
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) UAccount ¶
UAccount
https://www.okex.com/docs-v5/en/#websocket-api-private-channel-account-channel
func (*Private) UBalanceAndPosition ¶
UBalanceAndPosition unsubscribes a position channel
https://www.okex.com/docs-v5/en/#websocket-api-private-channel-balance-and-position-channel
func (*Private) UOrder ¶
UOrder
https://www.okex.com/docs-v5/en/#websocket-api-private-channel-order-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 (*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.
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 ¶
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 ¶
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) Tickers ¶
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 ¶
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
func (*Public) UCandlesticks ¶
func (c *Public) UCandlesticks(req requests.Candlesticks, rCh ...bool) error
UCandlesticks
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-candlesticks-channel
func (*Public) UEstimatedDeliveryExercisePrice ¶
func (c *Public) UEstimatedDeliveryExercisePrice(req requests.EstimatedDeliveryExercisePrice, rCh ...bool) error
UEstimatedDeliveryExercisePrice
func (*Public) UFundingRate ¶
func (c *Public) UFundingRate(req requests.FundingRate, rCh ...bool) error
UFundingRate
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-funding-rate-channel
func (*Public) UIndexCandlesticks ¶
func (c *Public) UIndexCandlesticks(req requests.IndexCandlesticks, rCh ...bool) error
UIndexCandlesticks
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-index-candlesticks-channel
func (*Public) UIndexTickers ¶
func (c *Public) UIndexTickers(req requests.IndexTickers, rCh ...bool) error
UIndexTickers
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-index-tickers-channel
func (*Public) UInstruments ¶
func (c *Public) UInstruments(req requests.Instruments, rCh ...bool) error
UInstruments
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-instruments-channel
func (*Public) UMarkPrice ¶
UMarkPrice
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-mark-price-channel
func (*Public) UMarkPriceCandlesticks ¶
func (c *Public) UMarkPriceCandlesticks(req requests.MarkPriceCandlesticks, rCh ...bool) error
UMarkPriceCandlesticks
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-mark-price-candlesticks-channel
func (*Public) UOPTIONSummary ¶
func (c *Public) UOPTIONSummary(req requests.OPTIONSummary, rCh ...bool) error
UOPTIONSummary
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-option-summary-channel
func (*Public) UOpenInterest ¶
func (c *Public) UOpenInterest(req requests.OpenInterest, rCh ...bool) error
UOpenInterest
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-open-interest-channel
func (*Public) UOrderBook ¶
UOrderBook
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-order-book-channel
func (*Public) UPriceLimit ¶
func (c *Public) UPriceLimit(req requests.PriceLimit, rCh ...bool) error
UPriceLimit
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-price-limit-channel
func (*Public) UTickers ¶
UTickers
https://www.okex.com/docs-v5/en/#websocket-api-public-channels-tickers-channel
type Trade ¶
type Trade struct {
*ClientWs
}
Trade
https://www.okex.com/docs-v5/en/#websocket-api-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