Documentation
¶
Index ¶
Constants ¶
const ( // Name is the name of the Bitstamp provider. Name = "bitstamp_api" // URL is the base URL of the Bitstamp API. The URL returns all prices, some // of which are not needed. URL = "https://www.bitstamp.net/api/v2/ticker/" )
Variables ¶
var DefaultAPIConfig = config.APIConfig{ Name: Name, Atomic: true, Enabled: true, Timeout: 3000 * time.Millisecond, Interval: 3000 * time.Millisecond, ReconnectTimeout: 2000 * time.Millisecond, MaxQueries: 1, Endpoints: []config.Endpoint{{URL: URL}}, }
DefaultAPIConfig is the default configuration for the Bitstamp API.
Functions ¶
func NewAPIHandler ¶
func NewAPIHandler( api config.APIConfig, ) (types.PriceAPIDataHandler, error)
NewAPIHandler returns a new Bitstamp PriceAPIDataHandler.
Types ¶
type APIHandler ¶
type APIHandler struct {
// contains filtered or unexported fields
}
APIHandler implements the PriceAPIDataHandler interface for Bitstamp. for more information about the Bitstamp API, refer to the following link: https://www.bitstamp.net/api/#section/What-is-API
func (*APIHandler) CreateURL ¶
func (h *APIHandler) CreateURL( tickers []types.ProviderTicker, ) (string, error)
CreateURL returns the URL that is used to fetch data from the Bitstamp API for the given tickers.
func (*APIHandler) ParseResponse ¶
func (h *APIHandler) ParseResponse( tickers []types.ProviderTicker, resp *http.Response, ) types.PriceResponse
ParseResponse parses the response from the Bitstamp API and returns a GetResponse. Each of the tickers supplied will get a response or an error. Note that the bitstamp API returns all prices, some of which are not needed. The response is filtered to only include the prices that are needed (i.e. the pairs that are in the cache).
type MarketTickerData ¶
MarketTickerData is the data returned by the Bitstamp API.
type MarketTickerResponse ¶
type MarketTickerResponse []MarketTickerData
MarketTickerResponse is the expected response returned by the Bitstamp API.
ex.
[
{ "ask": "2211.00", "bid": "2188.97", "high": "2811.00", "last": "2211.00", "low": "2188.97", "open": "2211.00", "open_24": "2211.00", "pair": "BTC/USD", "percent_change_24": "13.57", "side": "0", "timestamp": "1643640186", "volume": "213.26801100", "vwap": "2189.80" }
]