bitcoinity

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyPayload json.RawMessage = []byte("{}")

Functions

This section is empty.

Types

type Currency

type Currency string
const (
	USD Currency = "USD"
	EUR Currency = "EUR"
	GBP Currency = "GBP"
	AUD Currency = "AUD"
	JPY Currency = "JPY"
	CAD Currency = "CAD"
)

type Event

type Event string
const (
	EventPhxJoin  Event = "phx_join"
	EventPhxReply Event = "phx_reply"
	EventNewMsg   Event = "new_msg"
)

type Exchange

type Exchange string
const (
	Coinbase Exchange = "coinbase"
	Bitfinex Exchange = "bitfinex"
	Bitstamp Exchange = "bitstamp"
	Kraken   Exchange = "kraken"
	Gemini   Exchange = "gemini"
)

type GetTickerRequest

type GetTickerRequest struct {
	Currency Currency
	Exchange Exchange
	Span     Span
}

type GetTickerResponse

type GetTickerResponse struct {
	TickerLife       int      `json:"ticker_life"`
	VolumeResolution int      `json:"volume_resolution"`
	PriceChange      string   `json:"price_change"`
	PriceHigh        string   `json:"price_high"`
	PriceLow         string   `json:"price_low"`
	Buys             []Trade  `json:"buys"`
	Sells            []Trade  `json:"sells"`
	Lasts            []Trade  `json:"lasts"`
	Volume           []Volume `json:"volume"`
}

func GetTicker

func GetTicker(
	ctx context.Context, req *GetTickerRequest,
) (*GetTickerResponse, error)

type Handler

type Handler func(*Message)

type MarketData

type MarketData struct {
	Currency Currency    `json:"currency"`
	Exchange Exchange    `json:"exchange_name"`
	Trade    MarketTrade `json:"trade"`
}

type MarketPayload

type MarketPayload struct {
	Data MarketData `json:"data"`
}

type MarketTrade

type MarketTrade struct {
	Amount   float64  `json:"amount"`
	Date     float64  `json:"date"`
	Exchange Exchange `json:"exchange_name"`
	Price    float64  `json:"price"`
}

type Message

type Message struct {
	Event   Event           `json:"event"`
	Topic   Topic           `json:"topic"`
	Ref     *MessageId      `json:"ref"`
	Payload json.RawMessage `json:"payload"`
}

type MessageId

type MessageId string

type Span

type Span string
const (
	Span10Minutes Span = "10m"
	Span1Hour     Span = "1h"
	Span12Hours   Span = "12h"
	Span24Hours   Span = "24h"
	Span3Days     Span = "3d"
	Span7Days     Span = "7d"
	Span30Days    Span = "30d"
	Span6Months   Span = "6m"
	Span2Years    Span = "2y"
	SpanAll       Span = "all"
)

type Topic

type Topic string
const TopicAll Topic = "all"

func MarketTopic

func MarketTopic(e Exchange, c Currency) Topic

type Trade

type Trade struct {
	Timestamp int64
	Price     float64
}

func (*Trade) UnmarshalJSON

func (t *Trade) UnmarshalJSON(b []byte) error

type Volume

type Volume struct {
	Timestamp int64
	Size      float64
}

func (*Volume) UnmarshalJSON

func (v *Volume) UnmarshalJSON(b []byte) error

type Websocket

type Websocket interface {
	Join(Topic, Handler) error
	Shutdown() error
}

func GetWebsocket

func GetWebsocket() (Websocket, error)

Jump to

Keyboard shortcuts

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