rtds

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RTDSMarketURL   = "wss://ws-subscriptions-clob.polymarket.com/ws/market"
	RTDSUserURL     = "wss://ws-subscriptions-clob.polymarket.com/ws/user"
	RTDSLiveDataURL = "wss://ws-live-data.polymarket.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CryptoPricePayload

type CryptoPricePayload struct {
	Symbol    string  `json:"symbol"`
	Timestamp int64   `json:"timestamp"`
	Value     float64 `json:"value"`
}

CryptoPricePayload represents crypto price data from Chainlink

type CryptoPriceUpdate

type CryptoPriceUpdate struct {
	Topic     string             `json:"topic"`
	Type      string             `json:"type"`
	Timestamp int64              `json:"timestamp"`
	Payload   CryptoPricePayload `json:"payload"`
}

CryptoPriceUpdate represents full crypto price update message

type OrderbookUpdate

type OrderbookUpdate struct {
	EventType string            `json:"event_type"` // "book"
	AssetID   string            `json:"asset_id"`
	Bids      []clob.PriceLevel `json:"bids"`
	Asks      []clob.PriceLevel `json:"asks"`
	Hash      string            `json:"hash"`
	Timestamp string            `json:"timestamp"` // RTDS sends string timestamp usually?
}

OrderbookUpdate represents an orderbook update from RTDS

func ParseOrderbookUpdates

func ParseOrderbookUpdates(msg []byte) ([]OrderbookUpdate, error)

ParseOrderbookUpdates parses a raw message into a slice of OrderbookUpdates RTDS can send a single object or an array of objects

type RTDSClient

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

RTDSClient handles real-time data subscriptions via WebSocket

func NewRTDSClient

func NewRTDSClient(ctx context.Context, config RTDSConfig) *RTDSClient

NewRTDSClient creates a new Real-Time Data Service client

func (*RTDSClient) Close

func (c *RTDSClient) Close()

Close closes the connection permanently (disables reconnect, cancels context).

func (*RTDSClient) Connect

func (c *RTDSClient) Connect() error

Connect establishes the WebSocket connection

func (*RTDSClient) Errors

func (c *RTDSClient) Errors() <-chan error

Errors returns the read-only channel for errors

func (*RTDSClient) Messages

func (c *RTDSClient) Messages() <-chan []byte

Messages returns the read-only channel for incoming messages

func (*RTDSClient) ResetConnection

func (c *RTDSClient) ResetConnection()

ResetConnection closes the current WebSocket connection and clears all subscriptions, but preserves the context so Connect() can re-establish a fresh connection. Use this between market cycles to cleanly switch subscriptions.

func (*RTDSClient) SubscribeCryptoPrices

func (c *RTDSClient) SubscribeCryptoPrices(symbols []string) error

SubscribeCryptoPrices subscribes to Binance crypto prices

func (c *RTDSClient) SubscribeCryptoPricesChainlink(symbols []string) error

SubscribeCryptoPricesChainlink subscribes to Chainlink crypto prices

func (*RTDSClient) SubscribeMarket

func (c *RTDSClient) SubscribeMarket(assetIDs []string) error

SubscribeMarket subscribes to market events (book, price_change, etc.)

func (*RTDSClient) SubscribeUser

func (c *RTDSClient) SubscribeUser(apiKey, secret, passphrase string, markets []string) error

SubscribeUser subscribes to user events (requires auth)

type RTDSConfig

type RTDSConfig struct {
	URL           string
	AutoReconnect bool
}

RTDSConfig configuration for RTDS Client

type RTDSEvent

type RTDSEvent struct {
	EventType string `json:"event_type"`
	AssetID   string `json:"asset_id"`
}

RTDSEvent represents a generic event wrapper

Jump to

Keyboard shortcuts

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