coinbase

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrRequireConfigParameters = "not correct input parameters"
)

Variables

This section is empty.

Functions

func GetWSCredentials

func GetWSCredentials() (string, string, string)

func NewCoinbaseClient

func NewCoinbaseClient(cfg *config.Config) (*client, error)

NewCoinbaseClient init client for Coinbase

func ParseResponse

func ParseResponse(message []byte) (interface{}, error)

Types

type Auth

type Auth struct {
	Key        string
	Secret     string
	Passphrase string
}

authentication for web sockets

func NewAuth

func NewAuth() *Auth

func (*Auth) GenerateSignature

func (a *Auth) GenerateSignature() (string, int64, error)

generate signature

type HeartbeatResponse

type HeartbeatResponse struct {
	Type        string    `json:"type"`
	Sequence    int64     `json:"sequence"`
	LastTradeID int64     `json:"last_trade_id"`
	ProductID   string    `json:"product_id"`
	Time        time.Time `json:"time"`
}

func (*HeartbeatResponse) ToHeartbeat

func (r *HeartbeatResponse) ToHeartbeat() (*entity.Heartbeat, error)

type OrderResponse

type OrderResponse struct {
	Response
	Time          time.Time `json:"time"`
	Sequence      int       `json:"sequence"`
	OrderID       string    `json:"order_id"`
	Size          string    `json:"size,omitempty"`  // Only for limit orders
	Price         string    `json:"price,omitempty"` // Only for limit orders
	Funds         string    `json:"funds,omitempty"` // Only for market orders
	Side          string    `json:"side"`
	OrderType     string    `json:"order_type"`
	ClientOID     string    `json:"client-oid"` // Note the hyphen in the JSON tag
	RemainingSize string    `json:"remaining_size,omitempty"`
	Reason        string    `json:"reason,omitempty"`
	TradeID       int64     `json:"trade_id,omitempty"`       // Only for match
	MakerOrderID  string    `json:"maker_order_id,omitempty"` // Only for match
	TakerOrderID  string    `json:"taker_order_id,omitempty"` // Only for match
}

OrderResponse to handler all order data (received, open, done, match, etc.)

func (*OrderResponse) ToOrderResponse

func (r *OrderResponse) ToOrderResponse() (*entity.Order, error)

Update the ToOrderResponse method to handle string conversions

type Response

type Response struct {
	Type      string `json:"type"`
	Message   string `json:"message,omitempty"`
	Reason    string `json:"reason,omitempty"`
	ProductID string `json:"product_id"`
}

Base Response struct

type ResponseType

type ResponseType int
const (
	Error ResponseType = iota
	Subscriptions
	Unsubscribe
	Heartbeat
	Ticker
	Level2
	Received
	Open
	Done
	Match
	Change
)

func (ResponseType) String

func (r ResponseType) String() string

func (*ResponseType) UnmarshalJSON

func (r *ResponseType) UnmarshalJSON(v []byte) error

type Subscribe

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

type SubscribeHeartbeat

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

type TickerResponse

type TickerResponse struct {
	Response
	BestBid string `json:"best_bid"`
	BestAsk string `json:"best_ask"`
}

TickerResponse for ticker data

func (*TickerResponse) ToTicker

func (r *TickerResponse) ToTicker() (*entity.Ticker, error)

Conversion methods

Jump to

Keyboard shortcuts

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