websocketmarket

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUBSCRIBE   = "SUBSCRIBE"
	UNSUBSCRIBE = "UNSUBSCRIBE"
)
View Source
const (
	MaxTryTimes = 5
)

Variables

View Source
var (
	SpotMarketStreamBaseURL = "wss://data-stream.binance.vision"
	CombinedStreamRouter    = "/stream"
)

Functions

This section is empty.

Types

type BookDepthTopicParam

type BookDepthTopicParam struct {
	Symbol      string `validate:"required"`
	Level       int    `validate:"required,oneof=5 10 20"`
	UpdateSpeed string `validate:"required,oneof=1000ms 100ms"`
}

type BookDiffDepthTopicParam

type BookDiffDepthTopicParam struct {
	Symbol      string `validate:"required"`
	UpdateSpeed string `validate:"required,oneof=1000ms 100ms"`
}

type KlineTopicParam

type KlineTopicParam struct {
	Symbol   string                  `validate:"required"`
	Interval spotutils.KlineInterval `validate:"required,oneof=1s 1m 3m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1M"`
}

type Listener

type Listener func(any)

type SpotMarketStreamCfg

type SpotMarketStreamCfg struct {
	Debug         bool
	BaseURL       string `validate:"required"`
	AutoReconnect bool   `validate:"required"`

	Logger *slog.Logger
}

type SpotMarketStreamClient

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

func NewSpotMarketStreamClient

func NewSpotMarketStreamClient(cfg *SpotMarketStreamCfg) (*SpotMarketStreamClient, error)

func (*SpotMarketStreamClient) AddListener

func (m *SpotMarketStreamClient) AddListener(event string, listener Listener) *emission.Emitter

func (*SpotMarketStreamClient) Close

func (m *SpotMarketStreamClient) Close() error

func (*SpotMarketStreamClient) GetAggTradeTopic

func (m *SpotMarketStreamClient) GetAggTradeTopic(symbol string) (string, error)

func (*SpotMarketStreamClient) GetAllMarketMiniTickersTopic

func (m *SpotMarketStreamClient) GetAllMarketMiniTickersTopic() (string, error)

func (*SpotMarketStreamClient) GetAllMarketTickersTopic

func (m *SpotMarketStreamClient) GetAllMarketTickersTopic() (string, error)

func (*SpotMarketStreamClient) GetBookDepthTopic

func (m *SpotMarketStreamClient) GetBookDepthTopic(params *BookDepthTopicParam) (string, error)

func (*SpotMarketStreamClient) GetBookDiffDepthTopic

func (m *SpotMarketStreamClient) GetBookDiffDepthTopic(params *BookDiffDepthTopicParam) (string, error)

func (*SpotMarketStreamClient) GetBookTickerTopic

func (m *SpotMarketStreamClient) GetBookTickerTopic(symbol string) (string, error)

func (*SpotMarketStreamClient) GetKlineTopic

func (m *SpotMarketStreamClient) GetKlineTopic(params *KlineTopicParam) (string, error)

func (*SpotMarketStreamClient) GetListeners

func (m *SpotMarketStreamClient) GetListeners(event string, argument any) *emission.Emitter

func (*SpotMarketStreamClient) GetMiniTickerTopic

func (m *SpotMarketStreamClient) GetMiniTickerTopic(symbol string) (string, error)

func (*SpotMarketStreamClient) GetTickerTopic

func (m *SpotMarketStreamClient) GetTickerTopic(symbol string) (string, error)

func (*SpotMarketStreamClient) GetTradeTopic

func (m *SpotMarketStreamClient) GetTradeTopic(symbol string) (string, error)

func (*SpotMarketStreamClient) IsConnected

func (m *SpotMarketStreamClient) IsConnected() bool

IsConnected returns the WebSocket connection state

func (*SpotMarketStreamClient) Open

func (m *SpotMarketStreamClient) Open() error

func (*SpotMarketStreamClient) RemoveListener

func (m *SpotMarketStreamClient) RemoveListener(event string, listener Listener) *emission.Emitter

func (*SpotMarketStreamClient) Subscribe

func (m *SpotMarketStreamClient) Subscribe(topics []string) error

func (*SpotMarketStreamClient) UnSubscribe

func (m *SpotMarketStreamClient) UnSubscribe(topics []string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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