Documentation
¶
Overview ¶
Code generated by go generate; DO NOT EDIT.
Index ¶
- Constants
- Variables
- type ActionType
- type BookEvent
- type Channel
- type Exchange
- func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) error
- func (e *Exchange) IsSupportedInterval(interval types.Interval) bool
- func (e *Exchange) Name() types.ExchangeName
- func (e *Exchange) NewStream() types.Stream
- func (e *Exchange) PlatformFeeCurrency() string
- func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error)
- func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error)
- func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) (orders []types.Order, err error)
- func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, ...) ([]types.KLine, error)
- func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error)
- func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error)
- func (e *Exchange) QueryOrder(ctx context.Context, q types.OrderQuery) (*types.Order, error)
- func (e *Exchange) QueryOrderTrades(ctx context.Context, q types.OrderQuery) (trades []types.Trade, err error)
- func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error)
- func (e *Exchange) QueryTickers(ctx context.Context, symbols ...string) (map[string]types.Ticker, error)
- func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error)
- func (e *Exchange) SubmitOrder(ctx context.Context, order types.SubmitOrder) (*types.Order, error)
- func (e *Exchange) SupportedInterval() map[types.Interval]int
- type KLine
- type KLineEvent
- type KLineSlice
- type MarketTradeEvent
- type OrderTradeEvent
- type PriceVolumeOrder
- type PriceVolumeOrderSlice
- type Stream
- func (s *Stream) EmitAccountEvent(account okexapi.Account)
- func (s *Stream) EmitBookEvent(book BookEvent)
- func (s *Stream) EmitKLineEvent(candle KLineEvent)
- func (s *Stream) EmitMarketTradeEvent(tradeDetail []MarketTradeEvent)
- func (s *Stream) EmitOrderTradesEvent(orderTrades []OrderTradeEvent)
- func (s *Stream) OnAccountEvent(cb func(account okexapi.Account))
- func (s *Stream) OnBookEvent(cb func(book BookEvent))
- func (s *Stream) OnKLineEvent(cb func(candle KLineEvent))
- func (s *Stream) OnMarketTradeEvent(cb func(tradeDetail []MarketTradeEvent))
- func (s *Stream) OnOrderTradesEvent(cb func(orderTrades []OrderTradeEvent))
- func (s *Stream) Unsubscribe()
- type StreamEventHub
- type WebSocketEvent
- type WebsocketLogin
- type WebsocketOp
- type WebsocketSubscription
- type WsEventType
Constants ¶
const ( ID = "okex" // PlatformToken is the platform currency of OKEx, pre-allocate static string here PlatformToken = "OKB" )
const ( WsEventTypeLogin = "login" WsEventTypeError = "error" WsEventTypeSubscribe = "subscribe" WsEventTypeUnsubscribe = "unsubscribe" )
Variables ¶
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", } )
var CandleChannels = []string{
"candle1Y",
"candle6M", "candle3M", "candle1M",
"candle1W",
"candle1D", "candle2D", "candle3D", "candle5D",
"candle12H", "candle6H", "candle4H", "candle2H", "candle1H",
"candle30m", "candle15m", "candle5m", "candle3m", "candle1m",
}
var ErrSymbolRequired = errors.New("symbol is a required parameter")
Functions ¶
This section is empty.
Types ¶
type ActionType ¶ added in v1.56.0
type ActionType string
const ( ActionTypeSnapshot ActionType = "snapshot" ActionTypeUpdate ActionType = "update" )
type BookEvent ¶ added in v1.23.0
type BookEvent struct {
InstrumentID string
Symbol string
Action ActionType
Data []struct {
Bids PriceVolumeOrderSlice `json:"bids"`
Asks PriceVolumeOrderSlice `json:"asks"`
MillisecondTimestamp types.MillisecondTimestamp `json:"ts"`
Checksum int `json:"checksum"`
}
// contains filtered or unexported fields
}
func (*BookEvent) Book ¶ added in v1.23.0
func (event *BookEvent) Book() types.SliceOrderBook
func (*BookEvent) BookTicker ¶ added in v1.23.0
func (event *BookEvent) BookTicker() types.BookTicker
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
func (*Exchange) CancelOrders ¶
func (*Exchange) IsSupportedInterval ¶ added in v1.53.0
func (*Exchange) Name ¶
func (e *Exchange) Name() types.ExchangeName
func (*Exchange) PlatformFeeCurrency ¶
func (*Exchange) QueryAccount ¶
func (*Exchange) QueryAccountBalances ¶
func (*Exchange) QueryClosedOrders ¶ added in v1.53.0
func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) (orders []types.Order, err 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 all orders within a large time range (e.g. total orders > 100), we recommend using batch.ClosedOrderBatchQuery.
** since and until are inclusive, you can include the lastTradeId as well. **
func (*Exchange) QueryKLines ¶
func (*Exchange) QueryMarkets ¶
func (*Exchange) QueryOpenOrders ¶
func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error)
QueryOpenOrders retrieves the pending orders. The data returned is ordered by createdTime, and we utilized the `After` parameter to acquire all orders.
func (*Exchange) QueryOrder ¶ added in v1.52.0
func (*Exchange) QueryOrderTrades ¶ added in v1.52.0
func (e *Exchange) QueryOrderTrades(ctx context.Context, q types.OrderQuery) (trades []types.Trade, err error)
QueryOrderTrades quires order trades can query trades in last 3 months.
func (*Exchange) QueryTicker ¶
func (*Exchange) QueryTickers ¶
func (*Exchange) QueryTrades ¶ added in v1.53.0
func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error)
QueryTrades can query trades in last 3 months, there are no time interval limitations, as long as end_time >= start_time. okx does not provide an API to query by trade ID, so we use the bill ID to do it. The trades result is ordered by timestamp.
REMARK: If your start time is 90 days earlier, we will update it to now - 90 days. ** StartTime and EndTime are inclusive. ** ** StartTime and EndTime cannot exceed 90 days. ** ** StartTime, EndTime, FromTradeId can be used together. **
If you want to query all trades within a large time range (e.g. total orders > 100), we recommend using batch.TradeBatchQuery.
func (*Exchange) SubmitOrder ¶ added in v1.40.3
type KLine ¶ added in v1.56.0
type KLine struct {
StartTime types.MillisecondTimestamp
OpenPrice fixedpoint.Value
HighestPrice fixedpoint.Value
LowestPrice fixedpoint.Value
ClosePrice fixedpoint.Value
// If it is a derivatives contract, the value is the number of contracts.
// If it is SPOT/MARGIN, the value is the quantity in base currency.
Volume fixedpoint.Value
// VolumeCcy trading volume, with a unit of currency.
// If it is a derivatives contract, the value is the number of base currency.
// If it is SPOT/MARGIN, the value is the quantity in quote currency.
VolumeCcy fixedpoint.Value
// VolumeCcyQuote Trading volume, the value is the quantity in quote currency
// e.g. The unit is USDT for BTC-USDT and BTC-USDT-SWAP;
// The unit is USD for BTC-USD-SWAP
VolumeCcyQuote fixedpoint.Value
// The state of candlesticks.
// 0 represents that it is uncompleted, 1 represents that it is completed.
Confirm fixedpoint.Value
}
type KLineEvent ¶ added in v1.56.0
type KLineEvent struct {
Events KLineSlice
InstrumentID string
Symbol string
Interval string
Channel Channel
}
type KLineSlice ¶ added in v1.56.0
type KLineSlice []KLine
func (*KLineSlice) UnmarshalJSON ¶ added in v1.56.0
func (m *KLineSlice) UnmarshalJSON(b []byte) error
type MarketTradeEvent ¶ added in v1.56.0
type MarketTradeEvent struct {
InstId string `json:"instId"`
TradeId types.StrInt64 `json:"tradeId"`
Px fixedpoint.Value `json:"px"`
Sz fixedpoint.Value `json:"sz"`
Side okexapi.SideType `json:"side"`
Timestamp types.MillisecondTimestamp `json:"ts"`
Count types.StrInt64 `json:"count"`
}
type OrderTradeEvent ¶ added in v1.56.0
type OrderTradeEvent struct {
okexapi.OrderDetail
Code types.StrInt64 `json:"code"`
Msg string `json:"msg"`
AmendResult string `json:"amendResult"`
ExecutionType okexapi.LiquidityType `json:"execType"`
// FillFee last filled fee amount or rebate amount:
// Negative number represents the user transaction fee charged by the platform;
// Positive number represents rebate
FillFee fixedpoint.Value `json:"fillFee"`
// FillFeeCurrency last filled fee currency or rebate currency.
// It is fee currency when fillFee is less than 0; It is rebate currency when fillFee>=0.
FillFeeCurrency string `json:"fillFeeCcy"`
// FillNotionalUsd Filled notional value in USD of order
FillNotionalUsd fixedpoint.Value `json:"fillNotionalUsd"`
FillPnl fixedpoint.Value `json:"fillPnl"`
// NotionalUsd Estimated national value in USD of order
NotionalUsd fixedpoint.Value `json:"notionalUsd"`
// ReqId Client Request ID as assigned by the client for order amendment. "" will be returned if there is no order amendment.
ReqId string `json:"reqId"`
LastPrice fixedpoint.Value `json:"lastPx"`
// QuickMgnType Quick Margin type, Only applicable to Quick Margin Mode of isolated margin
// manual, auto_borrow, auto_repay
QuickMgnType string `json:"quickMgnType"`
// AmendSource Source of the order amendation.
AmendSource string `json:"amendSource"`
// CancelSource Source of the order cancellation.
CancelSource string `json:"cancelSource"`
// Only applicable to options; return "" for other instrument types
FillPriceVolume string `json:"fillPxVol"`
FillPriceUsd string `json:"fillPxUsd"`
FillMarkVolume string `json:"fillMarkVol"`
FillFwdPrice string `json:"fillFwdPx"`
FillMarkPrice string `json:"fillMarkPx"`
}
type PriceVolumeOrder ¶ added in v1.56.0
type PriceVolumeOrder struct {
types.PriceVolume
// NumLiquidated is part of a deprecated feature and it is always "0"
NumLiquidated int
// NumOrders is the number of orders at the price.
NumOrders int
}
type PriceVolumeOrderSlice ¶ added in v1.56.0
type PriceVolumeOrderSlice []PriceVolumeOrder
func ParsePriceVolumeOrderSliceJSON ¶ added in v1.56.0
func ParsePriceVolumeOrderSliceJSON(b []byte) (slice PriceVolumeOrderSlice, err error)
ParsePriceVolumeOrderSliceJSON tries to parse a 2 dimensional string array into a PriceVolumeOrderSlice
[["8476.98", "415", "0", "13"], ["8477", "7", "0", "2"], ... ]
func (*PriceVolumeOrderSlice) UnmarshalJSON ¶ added in v1.56.0
func (slice *PriceVolumeOrderSlice) UnmarshalJSON(b []byte) error
type Stream ¶
type Stream struct {
types.StandardStream
// contains filtered or unexported fields
}
func NewStream ¶
func NewStream(client *okexapi.RestClient, balanceProvider types.ExchangeAccountService) *Stream
func (*Stream) EmitAccountEvent ¶ added in v1.23.0
func (*Stream) EmitBookEvent ¶ added in v1.23.0
func (*Stream) EmitKLineEvent ¶ added in v1.56.0
func (s *Stream) EmitKLineEvent(candle KLineEvent)
func (*Stream) EmitMarketTradeEvent ¶ added in v1.56.0
func (s *Stream) EmitMarketTradeEvent(tradeDetail []MarketTradeEvent)
func (*Stream) EmitOrderTradesEvent ¶ added in v1.56.0
func (s *Stream) EmitOrderTradesEvent(orderTrades []OrderTradeEvent)
func (*Stream) OnAccountEvent ¶ added in v1.23.0
func (*Stream) OnBookEvent ¶ added in v1.23.0
func (*Stream) OnKLineEvent ¶ added in v1.56.0
func (s *Stream) OnKLineEvent(cb func(candle KLineEvent))
func (*Stream) OnMarketTradeEvent ¶ added in v1.56.0
func (s *Stream) OnMarketTradeEvent(cb func(tradeDetail []MarketTradeEvent))
func (*Stream) OnOrderTradesEvent ¶ added in v1.56.0
func (s *Stream) OnOrderTradesEvent(cb func(orderTrades []OrderTradeEvent))
func (*Stream) Unsubscribe ¶ added in v1.56.0
func (s *Stream) Unsubscribe()
type StreamEventHub ¶
type StreamEventHub interface {
OnKLineEvent(cb func(candle KLineEvent))
OnBookEvent(cb func(book BookEvent))
OnAccountEvent(cb func(account okexapi.Account))
OnOrderTradesEvent(cb func(orderTrades []OrderTradeEvent))
OnMarketTradeEvent(cb func(tradeDetail []MarketTradeEvent))
}
type WebSocketEvent ¶
type WebSocketEvent struct {
Event WsEventType `json:"event"`
Code string `json:"code,omitempty"`
Message string `json:"msg,omitempty"`
Arg struct {
Channel Channel `json:"channel"`
InstId string `json:"instId"`
} `json:"arg,omitempty"`
Data json.RawMessage `json:"data"`
ActionType ActionType `json:"action"`
}
func (*WebSocketEvent) IsAuthenticated ¶ added in v1.56.0
func (w *WebSocketEvent) IsAuthenticated() bool
func (*WebSocketEvent) IsValid ¶ added in v1.56.0
func (w *WebSocketEvent) IsValid() error
type WebsocketLogin ¶
type WebsocketOp ¶
type WebsocketOp struct {
Op WsEventType `json:"op"`
Args interface{} `json:"args"`
}
type WebsocketSubscription ¶
type WsEventType ¶ added in v1.56.0
type WsEventType string