Documentation ¶
Index ¶
- Constants
- Variables
- type Base
- type Config
- type ErrHandler
- type ErrJSONUnmarshal
- type ErrSubUnsub
- type ErrWsReadMessage
- type EventHandler
- type KlineEvent
- type KlineEventHandler
- type KlinePeriod
- type OrderbookData
- type OrderbookEvent
- type OrderbookEventHandler
- type PrivateEvent
- type PrivateEventHandler
- type PrivateOrder
- type PrivateTrade
- type SubUnsub
- type SubUnsubEvent
- type SubUnsubEventHandler
- type SubUnsubRequest
- func SubUnsubKlineTopics(subUnsub SubUnsub, symbol map[string]KlinePeriod) SubUnsubRequest
- func SubUnsubOrderbookTopics(subUnsub SubUnsub, symbol []string) SubUnsubRequest
- func SubUnsubPrivateTopics(subUnsub SubUnsub, streams []string) SubUnsubRequest
- func SubUnsubTradeTopics(subUnsub SubUnsub, symbol []string) SubUnsubRequest
- type Success
- type Trade
- type TradeEvent
- type TradeEventHandler
- type Trades
- type Wsclient
- func (c *Wsclient) Kline(symbol map[string]KlinePeriod, klineEventHandler KlineEventHandler, ...) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
- func (c *Wsclient) Orderbook(symbol []string, orderbookEventHandler OrderbookEventHandler, ...) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
- func (c *Wsclient) PrivateTrade(symbol []string, privateEventHandler PrivateEventHandler, ...) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
- func (c *Wsclient) SetJwt(jwtToken string, refreshToken string)
- func (c *Wsclient) Trade(symbol []string, tradeEventHandler TradeEventHandler, ...) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
Constants ¶
const ( PUBLIC_PATH = "/public" PRIVATE_PATH = "/private" SUB_UNSUB_SUCCESS = "success" SUB_UNSUB_ERROR = "error" )
Variables ¶
var ( WebsocketTimeout = time.Second * 60 WebsocketKeepalive = false )
var ErrNotLoggedIn = errors.New("not logged in")
Not logged in error
Functions ¶
This section is empty.
Types ¶
type ErrHandler ¶
type ErrHandler func(err error)
type ErrJSONUnmarshal ¶
json unmarshaling error
func (*ErrJSONUnmarshal) Error ¶
func (e *ErrJSONUnmarshal) Error() string
type ErrSubUnsub ¶
Subscribe Unsubscribe erros
func (*ErrSubUnsub) Error ¶
func (e *ErrSubUnsub) Error() string
type ErrWsReadMessage ¶
websocket read message error
func (*ErrWsReadMessage) Error ¶
func (e *ErrWsReadMessage) Error() string
type EventHandler ¶
type EventHandler func(message []byte)
type KlineEvent ¶
{ "btcusdc.kline-5m": [1659024300, 23935.01, 23935.01, 23935.01, 23935.01, 0] }
type KlineEventHandler ¶
type KlineEventHandler func(event *KlineEvent)
type KlinePeriod ¶
type KlinePeriod string
const ( PERIOD_1M KlinePeriod = "1m" PERIOD_5M KlinePeriod = "5m" PERIOD_15M KlinePeriod = "15m" PERIOD_30M KlinePeriod = "30m" PERIOD_1H KlinePeriod = "1h" PERIOD_2H KlinePeriod = "2h" PERIOD_4H KlinePeriod = "4h" PERIOD_6H KlinePeriod = "6h" PERIOD_12H KlinePeriod = "12h" PERIOD_1D KlinePeriod = "1d" PERIOD_3D KlinePeriod = "3d" PERIOD_1W KlinePeriod = "1w" )
type OrderbookData ¶
type OrderbookEvent ¶
type OrderbookEvent map[string]OrderbookData
Response for ask
{ "btcusdc.ob-inc": { "asks": ["23707.65", "0.034"], "sequence": 393494 } }
Response for bid
{ "btcusdc.ob-inc": { "asks": ["23707.65", "0.034"], "sequence": 393494 } }
type OrderbookEventHandler ¶
type OrderbookEventHandler func(event *OrderbookEvent)
type PrivateEvent ¶
type PrivateEvent struct { Trade PrivateTrade `json:"trade"` Order PrivateOrder `json:"order"` }
responses for trade
{ "trade": { "amount": "0.001", "created_at": 1659024869, "id": 448640, "market": "btcusdc", "order_id": 8840859, "price": "23829.22", "side": "buy", "taker_type": "buy", "total": "23.82922" } }
responses for order
{ "order": { "at": 1659024868, "avg_price": "23829.22", "created_at": 1659024868, "executed_volume": "0.001", "id": 8840859, "kind": "bid", "market": "btcusdc", "ord_type": "limit", "origin_volume": "0.001", "price": "24000.0", "remaining_volume": "0.0", "side": "buy", "state": "done", "trades_count": 1, "updated_at": 1659024869 } }
type PrivateEventHandler ¶
type PrivateEventHandler func(event *PrivateEvent)
type PrivateOrder ¶
type PrivateOrder struct { At int64 `json:"at"` AvgPrice string `json:"avg_price"` CreatedAt int64 `json:"created_at"` ExecutedVolume string `json:"executed_volume"` ID int64 `json:"id"` Kind string `json:"kind"` Market string `json:"market"` OrdType string `json:"ord_type"` OriginVolume string `json:"origin_volume"` Price string `json:"price"` RemainingVolume string `json:"remaining_volume"` Side string `json:"side"` State string `json:"state"` TradesCount int64 `json:"trades_count"` UpdatedAt int64 `json:"updated_at"` }
type PrivateTrade ¶
type SubUnsubEvent ¶
type SubUnsubEvent struct {
Success Success `json:"success"`
}
type SubUnsubEventHandler ¶
type SubUnsubEventHandler func(event *SubUnsubEvent)
type SubUnsubRequest ¶
func SubUnsubKlineTopics ¶
func SubUnsubKlineTopics(subUnsub SubUnsub, symbol map[string]KlinePeriod) SubUnsubRequest
helper function to form subscribe or unsubscribe request for kline topics
{ "event": "subscribe", "streams": ["btcusdc.kline-5m"] }
func SubUnsubOrderbookTopics ¶
func SubUnsubOrderbookTopics(subUnsub SubUnsub, symbol []string) SubUnsubRequest
helper function to form subscribe or unsubscribe request for orderbook topics
{ "event": "subscribe", "streams": ["btcusdc.ob-inc"] }
func SubUnsubPrivateTopics ¶
func SubUnsubPrivateTopics(subUnsub SubUnsub, streams []string) SubUnsubRequest
helper function to form subscribe or unsubscribe request for private topics
{ "event": "subscribe", "streams": ["trade", "order"] }
func SubUnsubTradeTopics ¶
func SubUnsubTradeTopics(subUnsub SubUnsub, symbol []string) SubUnsubRequest
helper function to form subscribe or unsubscribe request for trade topics
{ "event": "subscribe", "streams": ["btcusdc.trades"] }
type TradeEvent ¶
{ "btcusdc.trades": { "trades": [ { "amount": "0.001", "date": 1659023778, "price": "23935.01", "taker_type": "buy", "tid": 448639 } ] } }
type TradeEventHandler ¶
type TradeEventHandler func(event *TradeEvent)
type Wsclient ¶
type Wsclient struct {
// contains filtered or unexported fields
}
func (*Wsclient) Kline ¶
func (c *Wsclient) Kline(symbol map[string]KlinePeriod, klineEventHandler KlineEventHandler, subUnsubEventHandler SubUnsubEventHandler, errHandler ErrHandler) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
connects you to kline stream
func (*Wsclient) Orderbook ¶
func (c *Wsclient) Orderbook(symbol []string, orderbookEventHandler OrderbookEventHandler, subUnsubEventHandler SubUnsubEventHandler, errHandler ErrHandler) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
connects you to orderbook stream
func (*Wsclient) PrivateTrade ¶
func (c *Wsclient) PrivateTrade(symbol []string, privateEventHandler PrivateEventHandler, subUnsubEventHandler SubUnsubEventHandler, errHandler ErrHandler) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
subscribes to Trade data for authenticated user
func (*Wsclient) Trade ¶
func (c *Wsclient) Trade(symbol []string, tradeEventHandler TradeEventHandler, subUnsubEventHandler SubUnsubEventHandler, errHandler ErrHandler) (doneCh, stopCh chan struct{}, subUnsubCh chan SubUnsubRequest, err error)
connects you to trade stream