coinbase

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package coinbase defines the connectivity with Coinbase Exchange.

Index

Constants

View Source
const (
	WebSocketURL               = "wss://ws-feed.exchange.coinbase.com"
	WebSocketRequestsPerSecond = 10
)

Connection parameters for Coinbase Exchange. These are only provided for convenience in testing - operational values should be in the environment.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection wraps a Coinbase websocket connection.

func Factory

func Factory(
	url string,
	symbol string,
	onQuote func(*mkt.Quote),
	onTrade func(*mkt.Trade),
	onError func(error),
	limiter *utl.RateLimiter,
	lifetime time.Duration,
) *Connection

Factory is the [dma.ConnectionFactory] for a Connection.

func (*Connection) Close

func (x *Connection) Close()

Close the connection.

func (*Connection) Open

func (x *Connection) Open()

Open the connection.

type MessageType

type MessageType struct {
	Type    string `json:"type"`    // Values are "ticker" or "error".
	Message string `json:"message"` // Present when type is "error".
}

MessageType is a minimal Coinbase Exchange websocket message.

type Request

type Request struct {
	Type       string   `json:"type"`
	ProductIDs []string `json:"product_ids"`
	Channels   []string `json:"channels"`
}

Request is a Coinbase Exchange websocket request.

type Ticker

type Ticker struct {
	Symbol  string `json:"product_id"`
	BidPx   string `json:"best_bid"`
	BidSize string `json:"best_bid_size"`
	AskPx   string `json:"best_ask"`
	AskSize string `json:"best_ask_size"`
	LastQty string `json:"last_size"`
	LastPx  string `json:"price"`
	TradeID int64  `json:"trade_id"`
}

Ticker is a Coinbase Exchange websocket ticker message.

Jump to

Keyboard shortcuts

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