rest

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package rest provides a client for using the Cryptowatch REST API.

Index

Constants

This section is empty.

Variables

View Source
var APIErrorResponse = errors.New("API error response")

Functions

This section is empty.

Types

type ExchangeDescr

type ExchangeDescr struct {
	ID     int                 `json:"id"`
	Symbol string              `json:"symbol"`
	Name   string              `json:"name"`
	Active bool                `json:"active"`
	Routes ExchangeDescrRoutes `json:"routes"`
}

type ExchangeDescrBrief

type ExchangeDescrBrief struct {
	ID     int    `json:"id"`
	Symbol string `json:"symbol"`
	Name   string `json:"name"`
	Route  string `json:"route"`
	Active bool   `json:"active"`
}

type ExchangeDescrRoutes

type ExchangeDescrRoutes struct {
	Markets string `json:"markets"`
}

type MarketDescr

type MarketDescr struct {
	ID       int    `json:"id"`
	Exchange string `json:"exchange"`
	Pair     string `json:"pair"`
	Active   bool   `json:"active"`
	Route    string `json:"route"`
}

type MockV2Client

type MockV2Client struct {
	C *cache.Cache
}

func NewMockV2Client

func NewMockV2Client() *MockV2Client

func (*MockV2Client) GetAssetByID

func (mc *MockV2Client) GetAssetByID(id common.AssetID) (
	common.Asset, error,
)

func (*MockV2Client) GetAssetBySymbol

func (mc *MockV2Client) GetAssetBySymbol(symbol common.AssetSymbol) (
	common.Asset, error,
)

func (*MockV2Client) GetMarketByID

func (mc *MockV2Client) GetMarketByID(id common.MarketID) (
	common.Market, error,
)

func (*MockV2Client) GetMarketBySymbol

func (mc *MockV2Client) GetMarketBySymbol(ms common.MarketSymbol) (
	common.Market, error,
)

type PairDescr

type PairDescr struct {
	ID      int           `json:"id"`
	Symbol  string        `json:"symbol"`
	Route   string        `json:"route"`
	Base    PairSideDescr `json:"base"`
	Quote   PairSideDescr `json:"quote"`
	Markets []MarketDescr `json:"markets"`
}

type PairSideDescr

type PairSideDescr struct {
	ID     int    `json:"id"`
	Symbol string `json:"symbol"`
	Name   string `json:"name"`
	Fiat   bool   `json:"fiat"`
	Route  string `json:"route"`
}

type RESTClient

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

func NewRESTClient

func NewRESTClient(params *RESTClientParams) *RESTClient

func (*RESTClient) GetAssetByID

func (c *RESTClient) GetAssetByID(id common.AssetID) (
	common.Asset, error,
)

func (*RESTClient) GetAssetBySymbol

func (c *RESTClient) GetAssetBySymbol(symbol common.AssetSymbol) (
	common.Asset, error,
)

func (*RESTClient) GetExchangeBySymbol

func (c *RESTClient) GetExchangeBySymbol(xchSymbol common.ExchangeSymbol) (
	common.Exchange, error,
)

GetMarketBySymbol returns Market object based on exchange, base, and quote.

func (*RESTClient) GetExchangeDescr

func (c *RESTClient) GetExchangeDescr(exchangeSymbol string) (*ExchangeDescr, error)

func (*RESTClient) GetExchangeMarketsDescr

func (c *RESTClient) GetExchangeMarketsDescr(exchangeSymbol string) ([]MarketDescr, error)

func (*RESTClient) GetExchangesIndex

func (c *RESTClient) GetExchangesIndex() ([]ExchangeDescrBrief, error)

func (*RESTClient) GetMarket

func (c *RESTClient) GetMarket(params common.MarketParams) (
	common.Market, error,
)

GetMarket returns the Market based on an ID or symbol

func (*RESTClient) GetMarketByID

func (c *RESTClient) GetMarketByID(id common.MarketID) (
	common.Market, error,
)

GetMarketByID returns a Market object based on the market's ID.

func (*RESTClient) GetMarketBySymbol

func (c *RESTClient) GetMarketBySymbol(params common.MarketSymbol) (
	common.Market, error,
)

GetMarketBySymbol returns Market object based on exchange, base, and quote.

func (*RESTClient) GetMarketDescr

func (c *RESTClient) GetMarketDescr(exchangeSymbol, pairSymbol string) (MarketDescr, error)

func (*RESTClient) GetMarketSummaries

func (c *RESTClient) GetMarketSummaries() (map[string]common.SummaryUpdate, error)

GetMarketSummaries returns a map from market symbol like "<exchange>:<pair>" to the corresponding summary.

func (*RESTClient) GetMarketsIndex

func (c *RESTClient) GetMarketsIndex() ([]MarketDescr, error)

func (*RESTClient) GetOHLC

func (c *RESTClient) GetOHLC(
	exchangeSymbol, pairSymbol string,
) (map[common.Period][]common.Interval, error)

GetOHLC returns a map from a period (represented as a number of seconds: 60, 180, etc) to a slice of OHLC candles for that period, in the time ascending order.

func (*RESTClient) GetOrderBook

func (c *RESTClient) GetOrderBook(
	exchangeSymbol string, pairSymbol string,
) (common.OrderBookSnapshot, error)

func (*RESTClient) GetPairDescr

func (c *RESTClient) GetPairDescr(symbol string) (PairDescr, error)

func (*RESTClient) GetPairsIndex

func (c *RESTClient) GetPairsIndex() ([]PairDescr, error)

func (*RESTClient) GetPrice

func (c *RESTClient) GetPrice(
	exchangeSymbol string, pairSymbol string,
) (decimal.Decimal, error)

GetPrice returns latest price on the given market.

func (*RESTClient) GetSummary

func (c *RESTClient) GetSummary(
	exchangeSymbol, pairSymbol string,
) (common.SummaryUpdate, error)

func (*RESTClient) GetTrades

func (c *RESTClient) GetTrades(
	exchangeSymbol string, pairSymbol string,
) ([]common.PublicTrade, error)

GetTrades returns latest trades on the given market, sorted in ascending order.

type RESTClientParams

type RESTClientParams struct {
	URL    string
	APIKey string
}

type V2

type V2 interface {
	GetMarketBySymbol(common.MarketSymbol) (common.Market, error)
	GetMarketByID(common.MarketID) (common.Market, error)
	GetAssetByID(common.AssetID) (common.Asset, error)
	GetAssetBySymbol(common.AssetSymbol) (common.Asset, error)
}

Jump to

Keyboard shortcuts

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