coincap

package module
v0.0.0-...-72e0b07 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

coincap-go

coincap.io api wrapper in golang.

Documentation

Overview

Package coincap is a simple coincap.io API wrapper library. Note, that in many structs json.Number is used instead of string or float64. This is because for some unknown reason coincap may send same fields as numbers or as strings.

Index

Constants

View Source
const (
	HistoryIntervalAll     = ""
	HistoryInterval1Day    = "1day"
	HistoryInterval7Days   = "7day"
	HistoryInterval30Days  = "30day"
	HistoryInterval90Days  = "90day"
	HistoryInterval180Days = "180day"
	HistoryInterval365Days = "365day"
)

HistoryInterval* consts are used in History() request.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client send API requests and parses responses. It also can be used for subscription on websocket.

func New

func New() *Client

New returns new Client.

func (*Client) Coins

func (c *Client) Coins() ([]string, error)

Coins requests /coins path.

func (*Client) CoinsXCP

func (c *Client) CoinsXCP() ([]string, error)

CoinsXCP requests coins/xcp path

func (*Client) CoinsXCPAll

func (c *Client) CoinsXCPAll() ([]string, error)

CoinsXCPAll requests coins/xcp/all path.

func (*Client) Front

func (c *Client) Front() ([]Front, error)

Front requests /front path.

func (*Client) FrontXCP

func (c *Client) FrontXCP() ([]Front, error)

FrontXCP requests front/xcp path.

func (*Client) Global

func (c *Client) Global() (Global, error)

Global requests /global path.

func (*Client) History

func (c *Client) History(symb, interval string) (*History, error)

History requests /history path for given symbol.

interval can be either empty (returns all history on a coin),
or one of the HistoryInterval* consts.

func (*Client) Map

func (c *Client) Map() ([]Mapping, error)

Map requests /map path.

func (*Client) Page

func (c *Client) Page(symb string) (*Page, error)

Page requests /page path for given symbol.

func (*Client) SubscribeTrades

func (c *Client) SubscribeTrades(dataChan chan<- *Trade, stopChan <-chan bool) error

SubscribeTrades subscribes for websocket messages on 'trades' channel. All incoming messages are sent to 'dataChan'. If there are errors during subscription, it returns an error immediately. Otherwise, it blocks, waiting for an error, or stop signal. If an error occures, it will be returned as the result.

dataChan - a channel for Trade messages.
stopChan - a channel to cancel or reset ws subscribtion.
	close it or send 'true' to stop subscribtion.
	send 'false' to reconnect. May be useful, if updates stalled.

type Front

type Front struct {
	Long          string
	Short         string
	Shapeshift    bool
	Price         json.Number
	Cap24hrChange json.Number
	Mktcap        json.Number
	Perc          json.Number
	Supply        json.Number
	USDVolume     json.Number
	Volume        json.Number
	VwapData      *json.Number
	VwapDataBTC   *json.Number
}

Front is a reply for /front path.

type Global

type Global struct {
	BTCPrice      json.Number
	BTCCap        json.Number
	AltCap        json.Number
	Dom           json.Number
	BitnodesCount json.Number
	TotalCap      json.Number
	VolumeAlt     json.Number
	VolumeBtc     json.Number
	VolumeTotal   json.Number
}

Global is a websocket message from 'global' channel, and a reply for /global path.

type History

type History struct {
	Price     [][2]json.Number
	MarketCap [][2]json.Number `json:"market_cap"`
	Volume    [][2]json.Number
}

History is a reply for /history path.

type Mapping

type Mapping struct {
	Name    string
	Symbol  string
	Aliases []string
}

Mapping is a reply for /map path.

type Page

type Page struct {
	Global
	ID           string
	Type         string
	IDD          string `json:"_id"`
	DisplayName  string `json:"display_name"`
	Status       string
	PriceUSD     json.Number `json:"price_usd"`
	PriceEUR     json.Number `json:"price_eur"`
	PriceBTC     json.Number `json:"price_btc"`
	PriceETH     json.Number `json:"price_eth"`
	PriceZEC     json.Number `json:"price_zec"`
	PriceLTC     json.Number `json:"price_ltc"`
	MarketCap    json.Number `json:"market_cap"`
	Cap24hChange json.Number `json:"cap24hrChange"`
	Supply       json.Number
	Volume       json.Number
	Price        json.Number
	VWAP24h      json.Number `json:"vwap_h24"`
}

Page is a reply for /page path.

type Trade

type Trade struct {
	Msg  TradeMessage
	Data TradeData
}

Trade contains trade message and an optional trade data.

type TradeData

type TradeData struct {
	ExchangeID string `json:"exchange_id"`
	MarketID   string `json:"market_id"`
	Price      json.Number
	Raw        struct {
		ID        string
		TimeStamp time.Time
		Quantity  json.Number
		Price     json.Number
		Total     json.Number
		FillType  string
		OrderType string
	}
	TimestampMs int64 `json:"timestamp_ms"`
	Volume      json.Number
}

TradeData is a piece of information about a trade.

type TradeMessage

type TradeMessage struct {
	ExchangeID string `json:"exchange_id"`
	MarketID   string `json:"market_id"`
	Coin       string
	Msg        Front
}

TradeMessage is a websocket message from 'trades' channel.

Jump to

Keyboard shortcuts

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