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: 16 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	OptionsMarketStreamBaseURL = "wss://nbstream.binance.com/eoptions"
	CombinedStreamRouter       = "/stream"
)

Functions

This section is empty.

Types

type BookDepthTopicParam

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

type IndexPrice

type IndexPrice struct {
	EventType  string `json:"e"`
	EventTime  int64  `json:"E"`
	Symbol     string `json:"s"`
	IndexPrice string `json:"p"`
}

type Kline

type Kline struct {
	EventType string `json:"e"`
	EventTime int64  `json:"E"`
	Symbol    string `json:"s"`
	Kline     struct {
		StartTime             int64  `json:"t"`
		CloseTime             int64  `json:"T"`
		Symbol                string `json:"s"`
		Interval              string `json:"i"`
		FirstTradeID          int64  `json:"F"`
		LastTradeID           int64  `json:"L"`
		OpenPrice             string `json:"o"`
		ClosePrice            string `json:"c"`
		HighPrice             string `json:"h"`
		LowPrice              string `json:"l"`
		BaseAssetVolume       string `json:"v"`
		TradesNum             int64  `json:"n"`
		IsClosed              bool   `json:"x"`
		QuoteAssetTradeAmount string `json:"q"`
		TakerTradeVolume      string `json:"V"`
		TakerTradeAmount      string `json:"Q"`
	} `json:"k"`
}

type KlineTopicParam

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

type Listener

type Listener func(any)

type MarkPrice

type MarkPrice struct {
	EventType string `json:"e"`
	EventTime int64  `json:"E"`
	Symbol    string `json:"s"`
	MarkPrice string `json:"mp"`
}

type OpenInterest

type OpenInterest struct {
	EventType               string `json:"e"`
	EventTime               int64  `json:"E"`
	Symbol                  string `json:"s"`
	OpenInterestInContracts string `json:"o"`
	OpenInterestInUSDT      string `json:"h"`
}

type OptionsMarketStreamCfg

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

	Logger *slog.Logger
}

type OptionsMarketStreamClient

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

func (*OptionsMarketStreamClient) AddListener

func (o *OptionsMarketStreamClient) AddListener(event string, listener Listener) *emission.Emitter

func (*OptionsMarketStreamClient) Close

func (o *OptionsMarketStreamClient) Close() error

func (*OptionsMarketStreamClient) Get24HourTickerByUnderlyingAndexpirationTopic

func (o *OptionsMarketStreamClient) Get24HourTickerByUnderlyingAndexpirationTopic(underlying, expiration string) (string, error)

Get24HourTickerByUnderlyingAndexpirationTopic 24hr ticker info by underlying asset and expiration date. E.g.ETH@ticker@220930

func (*OptionsMarketStreamClient) Get24HourTickerTopic

func (o *OptionsMarketStreamClient) Get24HourTickerTopic(symbol string) (string, error)

func (*OptionsMarketStreamClient) GetBookDepthTopic

func (o *OptionsMarketStreamClient) GetBookDepthTopic(params *BookDepthTopicParam) (string, error)

func (*OptionsMarketStreamClient) GetBookDiffDepthTopic

func (o *OptionsMarketStreamClient) GetBookDiffDepthTopic(symbol string) (string, error)

func (*OptionsMarketStreamClient) GetIndexPriceTopic

func (o *OptionsMarketStreamClient) GetIndexPriceTopic(underlyingIndex string) (string, error)

GetIndexPriceTopic e.g ETHUSDT Underlying index stream.

func (*OptionsMarketStreamClient) GetKlineTopic

func (o *OptionsMarketStreamClient) GetKlineTopic(params *KlineTopicParam) (string, error)

func (*OptionsMarketStreamClient) GetListeners

func (o *OptionsMarketStreamClient) GetListeners(event string, argument any) *emission.Emitter

func (*OptionsMarketStreamClient) GetMarkPriceTopic

func (o *OptionsMarketStreamClient) GetMarkPriceTopic(underlying string) (string, error)

GetMarkPriceTopic The mark price for all option symbols on specific underlying asset. E.g.ETH@markPrice

func (*OptionsMarketStreamClient) GetOpenInterestTopic

func (o *OptionsMarketStreamClient) GetOpenInterestTopic(underlying, expiration string) (string, error)

GetOpenInterestTopic Option open interest for specific underlying asset on specific expiration date. E.g.ETH@openInterest@221125

func (*OptionsMarketStreamClient) GetTradeTopic

func (o *OptionsMarketStreamClient) GetTradeTopic(symbol string) (string, error)

GetTradeTopic The Trade Streams push raw trade information for specific symbol or underlying asset. E.g.ETH@trade

func (*OptionsMarketStreamClient) IsConnected

func (o *OptionsMarketStreamClient) IsConnected() bool

IsConnected returns the WebSocket connection state

func (*OptionsMarketStreamClient) Open

func (o *OptionsMarketStreamClient) Open() error

func (*OptionsMarketStreamClient) RemoveListener

func (o *OptionsMarketStreamClient) RemoveListener(event string, listener Listener) *emission.Emitter

func (*OptionsMarketStreamClient) Subscribe

func (o *OptionsMarketStreamClient) Subscribe(topics []string) error

func (*OptionsMarketStreamClient) UnSubscribe

func (o *OptionsMarketStreamClient) UnSubscribe(topics []string) error

type OrderbookDepth

type OrderbookDepth struct {
	EventType            string     `json:"e"`
	TransactionEventTime int64      `json:"T"`
	Symbol               string     `json:"s"`
	UpdateID             int64      `json:"u"`
	PU                   int64      `json:"pu"`
	Bids                 [][]string `json:"b"`
	Asks                 [][]string `json:"a"`
}

type Ticker

type Ticker struct {
	EventType            string `json:"e"`
	EventTime            int64  `json:"E"`
	Symbol               string `json:"s"`
	OpeningPrice         string `json:"o"`
	HighPrice            string `json:"h"`
	LowPrice             string `json:"l"`
	LatestPrice          string `json:"c"`
	TradingVolume        string `json:"V"`
	TradingAmount        string `json:"A"`
	PriceChangePercent   string `json:"P"`
	PriceChange          string `json:"p"`
	LastTradeVolume      string `json:"Q"`
	FirstTradeID         string `json:"F"`
	LastTradeID          string `json:"L"`
	NumberOfTrades       int64  `json:"n"`
	BestBuyPrice         string `json:"bo"`
	BestSellPrice        string `json:"ao"`
	BestBuyQuantity      string `json:"bq"`
	BestSellQuantity     string `json:"aq"`
	BuyImplied           string `json:"b"`
	SellImplied          string `json:"a"`
	Delta                string `json:"d"`
	Theta                string `json:"t"`
	Gamma                string `json:"g"`
	Vega                 string `json:"v"`
	ImpliedVolatility    string `json:"vo"`
	MarkPrice            string `json:"mp"`
	BuyMaximumPrice      string `json:"hl"`
	SellMinimumPrice     string `json:"ll"`
	EstimatedStrikePrice string `json:"eep"`
}

type Trade

type Trade struct {
	EventType          string `json:"e"`
	EventTime          int64  `json:"E"`
	Symbol             string `json:"s"`
	TradeID            string `json:"t"`
	Price              string `json:"p"`
	Quantity           string `json:"q"`
	BuyOrderID         string `json:"b"`
	SellOrderID        string `json:"a"`
	TradeCompletedTime int64  `json:"T"`
	Direction          string `json:"S"`
}

Jump to

Keyboard shortcuts

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